Qwen4-35b-A3b Local Coding Setup: Llama.cpp, vLLM & VRAM Guide
Build a Qwen4-35B-A3B local coding setup using llama.cpp GGUF or vLLM FP8, with real VRAM math for its 20.5B n-gram table and 1M context window.
Alibaba's Qwen team released Qwen4-35B-A3B on Hugging Face under Apache 2.0 on December 4, 2026, and the hardware math caught plenty of developers off guard. Despite the 35B name, the full checkpoint carries roughly 56B to 57B parameters on disk because of a 20.5B n-gram embedding table.
A fast Qwen4-35B-A3B local coding setup depends on one trick: keeping the active Mixture-of-Experts backbone on your GPU while streaming that 20.5B embedding table from system RAM or an NVMe SSD. Do that right, and you get ~3.8B active parameters per token plus a native 1M context window on consumer hardware.
Key Takeaways
- Separate weights from embeddings: The ~35B MoE backbone needs fast VRAM or unified memory, while the ~20.5B Per-Layer N-gram Embedding (PLE) table offloads cleanly to RAM or NVMe.
- Use llama.cpp for single-user machines: Pair Unsloth dynamic GGUF quants with
--lazy-mode autoand--spec-type draft-mtpon 24GB GPUs or 32GB–64GB Apple Silicon Macs.- Use vLLM for shared endpoints: Serve the official Apache 2.0 FP8 checkpoint when you have 80GB+ of GPU memory and need concurrent agentic tool calls.
- Right-size your context: A 32K–128K window keeps latency crisp and memory predictable even though the architecture supports 1,048,576 tokens natively.
Why Qwen4-35B-A3B Changes Local Coding Hardware Math
Qwen4-35B-A3B stays fast on local rigs because only ~3.8B parameters fire on each generated token, while its hybrid attention stack keeps long-context memory growth under control. That architecture explains why the model looks oversized on disk yet behaves like a much smaller engine during inference.
Before you size a GPU or download weights, break down the three distinct pieces inside the checkpoint:
- MoE Backbone (~35B total, ~3.8B active): Routes every token through 256 experts with top-8 active experts plus 1 shared expert.
- Per-Layer N-gram Embedding Table (~20.5B): Often called PLE or Engram, this lookup table sits at layer 2 and absorbs factual and token-pattern recall without adding heavy matrix math.
- Multi-Token Prediction Head (~2B): A built-in MTP head that enables native speculative decoding so the model can draft multiple tokens per step.
Attention design does the other half of the heavy lifting. Qwen4-35B-A3B uses a 3:1 ratio of Gated DeltaNet linear attention layers to Qwen Sparse Attention (QSA) layers, which sharply cuts KV-cache growth across its native 1,048,576-token window.
As Sebastian Raschka's 2026 analysis of open-weight models highlights, hybrid linear-and-sparse attention paired with aggressive MoE sparsity is what closed the practical gap between local checkpoints and frontier APIs. Early local LLM coding benchmarks back that up: Qwen4-35B-A3B posts 61.8 on DeepSWE in official release charts and lands around 62% on early localized LiveCodeBench Q4 runs.
Those scores signal a real threshold for daily repository work. You can hand the model multi-file edits, trace call chains across services, and iterate on failing tests locally without paying per-token API fees.
VRAM, System RAM, and Quantization Tradeoffs
Your quantization choice decides whether Qwen4-35B-A3B runs entirely in GPU memory or splits cleanly across VRAM and system RAM. Because PLE lookups touch only a tiny slice of the 20.5B table per token, offloading PLE to host RAM or fast NVMe barely dents generation speed.
Offloading MoE layers is a different story. Every token multiplies through 8 routed experts and 1 shared expert across the stack, so pushing MoE weights over PCIe throttles throughput immediately. Always prioritize keeping the ~35B MoE backbone and KV cache in GPU memory first.
Weight sizing scales predictably from the ~57B total parameter count:
- BF16 (~114GB raw weights): Reserve this for multi-GPU enterprise nodes or fine-tuning runs.
- Official FP8 (~57GB on disk): Published at Qwen/Qwen4-35B-A3B-FP8, designed for single 80GB GPUs or tensor-parallel workstations.
- Unsloth Dynamic 4-Bit GGUF (
UD-Q4_K_M): Shrinks the ~35B MoE backbone plus 2B MTP head to roughly 20GB–22GB of active working memory, leaving the PLE table to stream lazily. - Unsloth Dynamic 3-Bit GGUF: Pulls the core working set lower still, creating extra KV-cache headroom on 24GB GPUs and 32GB Macs.
| Hardware Tier | Recommended Runtime & Quant | Where the 20.5B PLE Lives | Best Coding Use Case |
|---|---|---|---|
| 24GB GPU + 64GB RAM | llama.cpp + Unsloth 3-bit or UD-Q4_K_M |
Streamed from RAM / NVMe via --lazy-mode auto |
Single-developer IDE autocomplete and terminal agents |
| 32GB–64GB Apple Silicon | llama.cpp + Unsloth 3-bit (32GB) or UD-Q4_K_M (64GB) |
Unified memory with lazy paging on 32GB rigs | Quiet laptop local LLM coding setup up to 64K context |
| 80GB GPU or Multi-GPU | vLLM or SGLang + official FP8 checkpoint | Resident in GPU VRAM | Team endpoint and concurrent agentic tool calls |
Pro Tip On a 24GB card, start with
UD-Q4_K_Mat a 32K context window before dropping to a 3-bit quant. Coding precision usually benefits more from 4-bit MoE weights than from stretching context past 64K.
Step-by-Step Local Setup With Llama.cpp and Unsloth GGUF
For a single developer workstation or MacBook Pro, a Qwen4-35B-A3B llama.cpp GGUF build gives you the fastest path to responsive interactive coding. Update or compile llama.cpp from a build dated December 4, 2026 or later so hybrid DeltaNet/QSA layers, PLE lazy loading, and MTP speculative drafting work out of the box.
Pull your quantized weights from unsloth/Qwen4-35B-A3B-GGUF, which ships day-zero dynamic 3-bit and 4-bit GGUF files. Launch an OpenAI-compatible local server with lazy embedding streaming and built-in MTP drafting enabled:
llama-server \
-hf unsloth/Qwen4-35B-A3B-GGUF:UD-Q4_K_M \
--lazy-mode auto \
--spec-type draft-mtp \
--ctx-size 32768 \
--n-gpu-layers 99 \
--host 127.0.0.1 \
--port 8080This command keeps the quantized MoE backbone on your GPU, streams the 20.5B PLE table on demand, and activates the bundled 2B MTP head to accelerate code generation.
If llama-server throws an out-of-memory error during startup on a 24GB GPU, lower --n-gpu-layers a few layers at a time or switch to a dynamic 3-bit GGUF file before cutting --ctx-size below 32768.
Measuring Speed, MTP Acceptance, and I/O Bottlenecks
Once the server starts, run a realistic multi-file diff prompt and inspect the slot timing lines printed in the llama-server terminal output. Watch three signals rather than guessing by feel:
- Prompt eval vs. generation tokens/sec: Slow generation with low GPU utilization usually means MoE layers spilled over PCIe.
- MTP draft acceptance rate: Code has predictable syntax, so
--spec-type draft-mtpshould post steady acceptance; if latency climbs on low-memory rigs, test with MTP disabled to compare. - Disk and RAM read spikes: Watch
iostaton Linux, Activity Monitor on macOS, ornvidia-smiduring the first two prompts—once hot n-grams cache in system RAM, SSD reads should drop sharply.
High-Throughput Self-Hosted Setup With vLLM and FP8
Switch to a Qwen4-35B-A3B vLLM FP8 deployment when you have dedicated datacenter or multi-GPU hardware and run parallel coding agents. The official Qwen/Qwen4-35B-A3B-FP8 checkpoint ships with day-zero serving support in both vLLM and SGLang.
On a dual-GPU workstation (such as two 48GB cards) or a single 80GB GPU, launch the OpenAI-compatible server with tensor parallelism and an explicit context cap:
vllm serve Qwen/Qwen4-35B-A3B-FP8 \
--tensor-parallel-size 2 \
--max-model-len 131072 \
--trust-remote-code \
--host 127.0.0.1 \
--port 8000Set --tensor-parallel-size 1 on a single 80GB card, and adjust --max-model-len to match your remaining VRAM budget after loading the ~57GB FP8 weights.
Single-user latency often feels snappier on llama.cpp with --spec-type draft-mtp, while vLLM pulls ahead the moment multiple agent loops fire concurrent tool calls. For a deeper look at sizing vLLM flags across self-hosted coding models, see our Amazon Ergo Coding Setup: Benchmarks, vLLM, and Bedrock Guide.
Watch Out Never leave
--max-model-lenuncapped at the native 1,048,576 tokens on an 80GB box—vLLM pre-allocates KV-cache blocks at startup and will OOM immediately. Also verify native FP8 GPU hardware support before pulling the checkpoint, and budget extra cold-start time while ~57GB of weights stream from disk.
Wiring Qwen4-35B-A3B Into Your Coding Workflow
Both llama-server (http://localhost:8080/v1) and vllm serve (http://localhost:8000/v1) expose standard OpenAI-compatible endpoints, so plugging them into terminal agents and IDE extensions takes seconds. Export your base URL and a placeholder key before launching your preferred CLI harness:
export OPENAI_BASE_URL="http://localhost:8080/v1"
export OPENAI_API_KEY="local-qwen4"Point your editor extension or coding agent at that local URL and pick the served model name in its custom provider settings. If you are deciding which harness fits your daily flow best, our Cursor vs. Windsurf vs. Claude Code: 2026 Pricing & Setup Guide walks through local and hybrid provider setups.
Resist the urge to dump an entire monorepo into the 1M context window on every turn. Curated 32K–128K prompts keep prefill fast, reduce attention dilution, and stop verbose tool schemas from bloating every loop—a pattern we also cover in Best MCP Servers for Claude Code: Lean Setup & Token Tradeoffs.
Qwen4-35B-A3B also supports multimodal inputs, which makes local UI screenshot debugging practical. Drop a broken layout screenshot alongside the relevant component CSS and let the model pinpoint spacing or overflow issues without sending staging screenshots to a third-party cloud.
Where Local Inference Wins and Where Hosted Models Still Lead
An Apache 2.0 Qwen4-35B-A3B rig easily replaces paid API calls for private repositories, boilerplate refactors, test generation, and high-frequency agent loops where token bills add up fast. Zero network round-trips and complete data control are hard to beat once your server is humming.
Frontier hosted models still hold an edge on gnarly cross-system architecture bugs, ambiguous product specs, and rare edge cases where maximum reasoning depth outweighs cost. Treat your local server as the default workhorse and escalate only the hardest tickets to a hosted frontier endpoint.
Frequently Asked Questions
How Much VRAM and RAM Do I Need to Run Qwen4-35B-A3B Locally?
For a smooth llama.cpp setup with Unsloth dynamic 3-bit or UD-Q4_K_M GGUF weights, plan on a 24GB GPU paired with 64GB of system RAM, or a 32GB–64GB Apple Silicon Mac. Running the official FP8 checkpoint in vLLM without CPU offloading requires an 80GB GPU or a multi-GPU setup with at least ~64GB–96GB of combined VRAM.
Why Is Qwen4-35B-A3B ~56B Parameters on Disk If It Is Named 35B-A3B?
The 35B-A3B name refers to the ~35B Mixture-of-Experts backbone (~3.8B active parameters per token). On top of that backbone, the checkpoint includes a ~20.5B Per-Layer N-gram Embedding (PLE) table at layer 2 and a ~2B Multi-Token Prediction head, bringing total on-disk parameters to roughly 56B–57B.
Should I Use Llama.cpp With Unsloth GGUF or vLLM With FP8 for Local Coding?
Pick llama.cpp with Unsloth GGUF if you are a solo developer on a 24GB GPU or Apple Silicon Mac, since --lazy-mode auto offloads the 20.5B PLE table and --spec-type draft-mtp speeds up single-stream generation. Pick vLLM with Qwen/Qwen4-35B-A3B-FP8 when you have 80GB+ of VRAM and need high throughput across concurrent agent requests or teammates.
Can Qwen4-35B-A3B Actually Use Its 1M Context Window on Consumer Hardware?
The 3:1 Gated DeltaNet linear attention to Qwen Sparse Attention ratio drastically shrinks KV-cache growth compared to standard dense transformers, making very long windows far cheaper. Even so, consumer 24GB–64GB rigs run much faster and stay well inside memory limits when you cap active coding sessions between 32K and 128K tokens.
Engineering workflows, AI coding tools, and developer guides published on DuneBook.