FreeAIModelsForSure/MiniCPM5-1B-Q8
Qwen3.6-27B MTP (TQ3_4S) GGUF Chat (Free CPU Tier)
This Hugging Face Space runs the Qwen3.6-27B-MTP-TQ3_4S.gguf model from YTan2000/Qwen3.6-27B-MTP-TQ3_4S entirely on the free CPU tier (2 vCPUs, 16 GB RAM) using llama-cpp-python and a Gradio chat UI.
Why Docker + multi-stage build with a custom llama.cpp fork?
Hugging Face's native Python/Gradio SDK installs llama-cpp-python from source, which on the free tier:
- Takes 15-30+ minutes to compile the C++ backend.
- Often hits the build timeout, leaving the Space in a failed state.
The Docker SDK lets us control the build. We use a two-stage multi-stage build with a custom llama.cpp fork:
- Builder stage — downloads the
llama-cpp-python==0.3.32sdist, replaces its bundledvendor/llama.cppwith a checkout of `turbo-tan/llama.cpp-tq3`, and compiles the wheel from source with OpenBLAS acceleration. ~20-30 min, cached by HF Spaces. - Runtime stage — slim image that just copies the pre-compiled wheel. No compilation at runtime, fast cold start.
Why a custom fork (not stock llama-cpp-python)?
The model file Qwen3.6-27B-MTP-TQ3_4S.gguf uses GGML tensor type 46 (TQ3_4S — TurboQuant 3-bit with four u8 per-8 scales). Stock llama.cpp (any version, including the one bundled with llama-cpp-python==0.3.32) only supports types 0-42 and fails with:
gguf_init_from_reader: tensor 'blk.0.attn_gate.weight' has invalid
ggml type 46. should be in [0, 42)The turbo-tan/llama.cpp-tq3 fork adds:
So the model loads and runs on CPU, using the reference (non-SIMD) dequantization path. Performance is modest (~1-3 tok/s on 2 vCPUs) but functional.
Why compile from source (not pre-built wheel)?
The abetlen pre-built CPU wheel index tops out at 0.3.19 (March 2026). PyPI itself ships sdist-only for every llama-cpp-python release — there are no pre-built Linux wheels anywhere for versions newer than 0.3.19. Even if a wheel existed, it would bundle stock llama.cpp (no TQ3_4S). Source compilation against the fork is the only option.
Why Debian-slim (not Alpine)?
We compile from source, so the .so is linked against the builder's libc. We use python:3.10-slim-bookworm (Debian 12, glibc 2.36) because:
- It's the standard build environment for llama.cpp (fewer quirks).
- OpenBLAS dev packages are well-tested on Debian.
- Trixie (Debian 13, GCC 14, glibc 2.41) has known llama.cpp build issues.
- The runtime image only needs
libopenblas0+libgomp1(~10 MB).
Files
Runtime Configuration
Pinned versions (audited 2026-07-04)
Local run
docker build -t qwen36-27b-cpu .
docker run --rm -p 7860:7860 qwen36-27b-cpuOpen <http://localhost:7860> in your browser.
Notes & caveats
- Cold start: First boot spends a few minutes downloading the GGUF file from the Hub into the Space's ephemeral cache. Free-tier Spaces have no persistent storage, so this happens on every cold start.
- Q1_K quality: This is the most aggressive quantization. Output quality is noticeably degraded vs. Q4KM, but the RAM footprint is small enough to fit the free tier alongside the OS and Gradio.
- Throughput: Expect ~3-8 tokens/sec on 2 vCPUs for a 27B model. Long prompts (near the 4096 context) will be slower due to prompt processing.
