Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path →
Qwen4-Coder,
explained.
Passing 80% on SWE-Verified used to mean a frontier API and a data-center bill. Qwen4-Coder does it — reportedly ~82% — as an open, Apache-2.0 model on a MacBook. The magic isn't a bigger model; it's a smarter shape. A mixture-of-experts stores 32 billion parameters but wakes only 3 billion per token, and that one fact splits the two things everyone conflates: how much you must hold versus how fast you can run.
What changes against every rung below: the same lever, pulled the other way
Rungs 1 to 4 use sparsity to build models that would otherwise be unaffordable to run — enormous capacity at tolerable cost per token, on a cluster. This rung uses the identical mechanism for the opposite purpose: to make a genuinely capable model fit on a single machine someone owns. Nothing about the architecture is new here; what is new is recognising which of the two numbers matters for which constraint.
The arithmetic is worth doing explicitly, because it is the whole argument. What has to fit in memory is the total parameter count times the bits per parameter, divided by eight for bytes — so total parameters set whether the model loads at all. What sets how fast tokens come out is the active parameter count, because decoding one token reads only the weights that token's routing selects, and single-token decode is limited by memory bandwidth rather than arithmetic. Total parameters buy capability and cost you capacity; active parameters cost you speed. A mixture of experts lets you choose them separately, and on a laptop the right choice is as much total as will fit and as little active as the task tolerates.
Stated in the ladder's units, as the page carries them: 32B total with about 3B active — the same decoupling shape as rung 3's 671B/37B, at a fiftieth of the size — released under Apache 2.0, and reportedly reaching 82% on SWE-Verified while running on a MacBook. If that number holds, the interesting quantity is not the score but the ratio: a coding benchmark result in the frontier range from a model that needs no cluster, no API and no network.
The shape: 32B stored, 3B awake
Qwen4-Coder is a mixture-of-experts, the coding-specialized successor to Qwen3: roughly 32B total parameters split across many experts, with a router that activates only about 3B per token — under 10%. Every token flows through the shared layers plus a handful of routed experts; the other experts sit dormant for that token.
That's the entire trick behind "a strong coder on a laptop." A dense 32B model would need 32B of everything — memory and compute — on every token. The MoE keeps the 32B of knowledge but pays roughly 3B of compute. To see why that fits a Mac, you have to separate two costs people usually lump together.
The decoupling: storage ≠ speed
Running a model locally has two independent bills. Storage: every weight must live in memory, because the router might pick any expert on any token — so you hold all 32B. Speed: decoding is memory-bandwidth bound, and per token the hardware only reads the weights it actually uses — the active ~3B. A dense model ties these together; an MoE cuts the knot.
all experts
storage = total
~3B active
decode reads 3B
You buy the RAM for a 32B model and get the throughput of a 3B one. That asymmetry is the whole product.
Does it fit? The napkin math
Storage is just arithmetic: bytes = parameters × bits ÷ 8. In 4-bit, 32B parameters weigh about 16 GB of bare weights (nearer 18 GB once per-group scales are stored) — which still slides into a 24 GB Mac's unified memory with a little room for the KV cache and the OS. In 16-bit it would be 64 GB and wouldn't fit; quantization is what makes it a laptop model.
Fits ⟺ store ≤ VRAM/unified RAM. Speed is a separate line: bandwidth ÷ active-bytes, so it's the 3B — not the 32B — that sets tokens/sec.
"Can I run it?" is really two questions. Does it fit? is answered by total params and your quant level. Is it fast enough? is answered by active params and your memory bandwidth. An MoE is engineered to make the second answer far better than the first would suggest.
82% on SWE-Verified — locally
SWE-Verified is the hard one: real GitHub issues where a patch counts only if it applies and turns the failing tests green without breaking the passing ones. Reaching ~82% on it is frontier-class agentic coding — and this page reports Qwen4-Coder as the first open, Mac-runnable model to clear 80% there (it cites no primary source, so treat that as a claim to verify).
The significance isn't the two-point benchmark bump; it's where the capability now lives. A genuinely useful coding agent that runs offline, with open weights and an Apache-2.0 licence, changes who can build with it and under what constraints — no per-token API meter, no data leaving the machine.
Why it matters
Qwen4-Coder is the clearest proof yet that the sparse-MoE recipe has made local-first coding agents real. The playbook it validates is exactly the one in the local LLM stack and on-device AI handbooks: pick an MoE so RAM sizing and speed decouple, quantize to fit, and you get a capable model without a data center.
It also sharpens a mental model worth keeping: for any local model, compute the two numbers separately. Total × bits ÷ 8 tells you if it loads; active params vs your bandwidth tells you if it's usable. Dense models make those two move together; every strong on-device release from here will be an MoE precisely to pull them apart.
The line it continues: Qwen3. The stack it powers: Local LLM Stack. The fit math in depth: On-Device AI.
How a 32B-total, 3B-active coder runs on one machine, step by step
This page has no primary source, and the release details a reader would want, such as layer and expert counts, the attention design, context length, training data and the agentic training recipe, are not given here, so this section does not invent them. What can be described exactly is the procedure any sparse mixture-of-experts model of this shape goes through on a single machine, using the page's figures of 32B total and about 3B active parameters.
- Quantize the weights. A 4-bit format stores each weight as a 4-bit integer plus a shared scale, and often an offset, for each small group of weights. With groups of 64 and two 16-bit values per group, the real cost is 4.5 bits per weight, so 32B parameters take about 18 GB rather than the 16 GB of the bare 4-bit arithmetic. Many formats also keep the embeddings and other sensitive layers at higher precision.
- Load everything. All experts must be resident, because the router can pick any of them for any token at any layer. Total parameters decide whether the model loads at all.
- Prefill the prompt. A coding agent's prompt holds instructions, tool output, file contents and diffs, often tens of thousands of tokens. Prefill processes all of them in parallel through every layer, filling the KV cache. This phase is limited by arithmetic, roughly 2 FLOPs per active parameter per token plus attention, so on a laptop a long prompt can take many seconds before the first output token appears.
- Decode one token at a time. For each new token, every layer runs attention over the KV cache, then its router picks a few experts and only their weights are read. Decoding a single sequence does little arithmetic per byte read, so speed is set by memory bandwidth: the bytes read per token are about active parameters × bits ÷ 8, plus the KV cache for the whole context.
- Keep the KV cache in budget. The cache grows linearly with context: per token, 2 × layers × key-value heads × head size × bytes per value. Sparsity in the experts does nothing to shrink it, so at long context it competes with the weights for the same memory and adds to every decode step's reads.
- Run the agent loop. For benchmarks like SWE-bench Verified the model sits inside a scaffold that reads the repository, proposes edits, runs commands and tests, and feeds the results back as new prompt tokens, repeating until it submits a patch. Every turn is another prefill and decode, so total time depends on both phases.
- Score the patch. The benchmark applies the final patch to the repository and runs the issue's tests. The task counts as resolved only if the previously failing tests now pass and the previously passing tests still pass.
Steps 3 and 4 are why "fast on a laptop" needs two numbers: prompt-processing speed, which scales with compute and active parameters, and generation speed, which scales with bandwidth and the bytes read per token.
The memory and decode-speed bounds for a sparse model
Ntotal = 32B,Nactive ≈ 3B— the page's figures;b— bits per weight;g— the quantization group size, with two 16-bit values (a scale and an offset) per group, so 4-bit at g = 64 gives beff = 4.5.MKV(L)— the key-value cache for L tokens: keys and values (the 2), for every layer, key-value head and head dimension, at Bkv bytes per value.Mother— runtime buffers, activations and everything else on the machine.BW— memory bandwidth in bytes per second. The bound assumes every needed byte is read once per token, so real speeds land below it.
At the extremes: at short context MKV ≈ 0, and speed is set by the active weights alone. As L grows, the KV term grows without limit, and at long enough context it, not the experts, dominates both memory and speed. A dense 32B model has Nactive = Ntotal, so the same bandwidth buys about a tenth of the speed.
What is reported, and what it does and does not show
The page cites no primary source, so the model-specific figures below are claims to verify, not measured results.
| Claim | Value on this page | What it rests on |
|---|---|---|
| Total parameters | 32B | Reported on this page; sets the memory bill |
| Active parameters per token | About 3B | Reported on this page; sets decode speed |
| License | Apache 2.0 | Reported on this page; check the license file shipped with the weights |
| SWE-bench Verified | About 82% | Reported on this page, unverified; scaffold, turn limit and attempts not given |
| Weights at 16, 8 and 4 bits | 64, 32 and 16 GB | Arithmetic, 32B × bits ÷ 8; about 18 GB at 4 bits once group scales are counted |
The benchmark itself is well documented. SWE-bench (Jimenez and colleagues, 2024) collected 2,294 real GitHub issues from 12 popular Python repositories. SWE-bench Verified is a 500-task subset that OpenAI had human annotators screen in 2024 for well-specified issues and fair tests. An 82% score means about 410 of those 500 issues resolved.
What the claim has to survive
Scores on agentic benchmarks move with the scaffold: the tools offered, the turn limit and the number of attempts allowed. Two numbers on the same benchmark are often not comparable. The tasks come from public repositories that predate recent training corpora, so a model trained on a large code crawl cannot easily be shown not to have seen the fixes. And a score produced at full precision does not predict the quantized copy a laptop runs: lower precision generally costs some quality, with losses usually small at 8 bits and larger and more model-dependent at 4 bits and below, so a 4-bit result has to be measured rather than assumed.
Where this stands, and what would settle it
The benchmark figure is vendor-reported and should be treated as such. Two specific cautions apply to this class of claim rather than to this model in particular. First, agentic coding benchmarks are scored by running tests in a harness, and results are sensitive to the scaffold — the retrieval, the retry policy, the number of attempts — so two reported numbers on the same benchmark are frequently not measuring the same thing. Second, benchmarks drawn from public repositories carry a standing contamination risk, and a model trained on a large code corpus cannot easily be shown not to have seen the fixes.
There is also a cost that the headline hides: running locally in practice means running quantised, and quantisation is not free. The memory arithmetic above is exactly what makes that trade visible — fewer bits per parameter is how a large total fits, and quality is what is spent to get there. A published score at full precision is not a prediction of what a reader will experience at four bits.
What would settle it: independent evaluation on held-out tasks under a disclosed scaffold, and quality measurements at the quantisation levels people actually deploy rather than at the precision the score was produced with. Whatever those show, the structural point on this rung stands on its own and does not depend on the number — sparsity is a dial between storage and speed, and pointing it at consumer hardware is a use nobody had in mind when rung 1 was written.
Two bills: does it fit, and is it fast?
"Can I run this MoE?" is two separate calculations, and both are one-liners. Storage is total params × bits ÷ 8 — that's what has to fit in RAM. Speed is bandwidth ÷ active-bytes — and it depends on the ~3B active experts, not the 32B stored. Watch a 32B model fit a 24 GB Mac at 4-bit while decoding at the speed of a 3B one, and watch fp16 blow the budget. Change the total, active, bit-width, RAM, and bandwidth.
Write the body of decode_tps. Everything else in the file is
already written; this is the function the paper is about. Press ▶ Run to check it against
the 5 assertions below — they start red.
- Storage sizes on TOTAL params; compute uses only ACTIVE
- 4-bit is 4x smaller than fp16
- 32B at 4-bit (~16GB) fits a 24GB Mac but not an 8GB one
- Decode speed is set by ACTIVE params, not total
- The active fraction is under 10% of the stored model
Questions people ask about Qwen4-Coder
What is Qwen4-Coder's architecture?
Based on what this page reports, Qwen4-Coder is a sparse mixture-of-experts model with about 32 billion parameters in total, of which about 3 billion are active for any one token, released under the Apache 2.0 license as the coding-focused successor to Qwen3. The page cites no primary source and does not give the number of layers, the number of experts and how many are routed per token, the attention design, the context length or the training data, so those should be read from the official model card rather than assumed. For comparison, the earlier Qwen3-Coder-30B-A3B, which has a similar total-to-active shape, is documented with 48 layers and 128 experts, 8 of them active per token.
How much memory does a 32B mixture-of-experts coder need at 4, 8 and 16 bits?
For the weights alone, total parameters times bits divided by eight: about 16 GB at 4 bits, 32 GB at 8 bits and 64 GB at 16 bits for 32 billion parameters. Real 4-bit files are a little larger, because each small group of weights also stores a scale and often an offset; with groups of 64 and two 16-bit values per group, that is 4.5 bits per weight, about 18 GB. On top of the weights you need the KV cache, which grows with context length, plus runtime buffers and the operating system. A 24 GB machine can therefore hold the 4-bit model with a moderate context, while the 8-bit model needs a larger machine.
How fast will a 3B-active model generate tokens on a laptop?
An upper bound is memory bandwidth divided by the bytes read per token. At 4.5 effective bits per weight, 3 billion active parameters are about 1.7 GB per token, so a machine with 200 GB/s of bandwidth tops out near 120 tokens per second before counting the KV cache, and real runtimes reach only part of that bound. Reads from the KV cache are added for every token and grow with context, so generation slows as a conversation or repository context gets long. Prompt processing is a separate limit: it is compute-bound, so a long agent prompt can take noticeably longer to read than the reply takes to write.
What does an 82% score on SWE-bench Verified mean?
SWE-bench Verified is a set of 500 real GitHub issues from popular Python repositories, screened by human annotators in 2024 so that each issue is clearly specified and its tests are fair. A model, working inside an agent scaffold that can read files, edit code and run commands, must produce a patch; the task counts as resolved only if the issue's failing tests now pass and the tests that passed before still pass. An 82% score means about 410 of the 500 issues resolved. The number depends heavily on the scaffold, the turn limit and the number of attempts allowed, so it is only comparable with scores reported under the same setup.
Does running a model at 4 bits change its benchmark score?
Usually somewhat, and it has to be measured rather than assumed. Published scores are normally produced at the precision the developer evaluated, typically 16 bits, while a laptop runs a quantized copy. Quality losses at 8 bits are often small; at 4 bits they vary by model, by quantization method and by task, and long multi-step tasks such as agentic coding can be more sensitive than single-answer benchmarks, because small errors can compound across many steps. The fair check is to run the same benchmark, with the same scaffold, on the exact quantized file you intend to deploy, and compare it with the full-precision score.
4 questions to test what you just read
Work each one out before you open it — a number, a prediction or a reason, not a definition. Producing the answer is what makes it stick. Your progress is kept on this device.
A 4-bit format uses groups of 64 weights with a 16-bit scale and a 16-bit offset per group. What is the real size of 32B parameters?
Show answer
Each group adds 32 bits over 64 weights, 0.5 bits per weight, for 4.5 bits in total. 32 × 10^9 × 4.5 / 8 ≈ 18 GB, not 16, which leaves 2 GB less headroom on a 24 GB machine.
At 4.5 bits per weight and 200 GB/s, what is the decode ceiling for 3B active parameters, and for a dense 32B model?
Show answer
3B: 3 × 10^9 × 4.5 / 8 ≈ 1.69 GB per token, so about 118 tokens/s. Dense 32B: 18 GB per token, about 11 tokens/s. Same memory footprint, about a tenth of the speed for the dense model.
Context grows from 4K to 128K tokens. What happens to decode speed, and why does the mixture of experts not help?
Show answer
It falls: every new token must read the KV cache for the whole context, which grows 32×. Sparsity only cuts the expert weights read; unless the attention itself is sparse or linear, the cache is read in full, so at long context it can rival or exceed the active weights in bytes per token.
Why is it a bad idea to keep only the frequently used experts in memory and fetch the rest from an SSD on demand?
Show answer
The router can pick any expert, in every layer, for every token, so even rarely used experts are needed constantly over a long generation. An SSD delivers a few GB/s, roughly two orders of magnitude below unified-memory bandwidth, so every miss stalls decoding; the full set has to stay resident.
One model, many experts
Sparsity: route each token to a few experts and buy parameter count without paying for it at inference. 2017 idea, 2026 frontier default.
- 1Mixture of Experts2017
- 2Switch Transformer2022
- 3DeepSeek-V32024
- 4DeepSeek-V42026
- 5Qwen4-Coder2026
Explore the topic
See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.
More Paper Breakdowns
- Attention Is All You NeedThe paper that introduced the Transformer — the architecture underneath GPT, BERT, Claude, and Gemini. Self-attention, Query/Key/Value, multi-head attention, positional encoding, and the real BLEU results, explained in depth with analogies and animated visuals, not just equations.Read →
- BERTThe paper that made "pre-train once, fine-tune anywhere" the default for NLP. Bidirectional context, masked language modeling, next-sentence prediction, the [CLS]/[SEP] tokens, and the GLUE sweep — explained with analogies, not just equations.Read →
- Chain-of-Thought PromptingShow a model a few worked examples with their reasoning and it starts solving problems it used to fail. Why reasoning emerges only at scale, the GSM8K jump, zero-shot "Let's think step by step", and how CoT seeded modern reasoning models.Read →
- LoRAThe paper that made fine-tuning affordable. Freeze the giant pretrained model and train two tiny low-rank matrices instead — up to 10,000x fewer trainable parameters, no extra inference latency, and swappable per-task adapters. The road to QLoRA and PEFT.Read →
- Direct Preference OptimizationRLHF without the RL. Align a model to human preference pairs with one simple classification-style loss — no separate reward model, no unstable reinforcement learning. Why "your LM is secretly a reward model", and how DPO became the default alignment method.Read →
- ChinchillaThe compute-optimal scaling law that said models were too big. Parameters and training tokens should scale together — ~20 tokens per parameter — so a 70B model trained on 1.4T tokens beat the 280B giants. Why every model since trains on trillions of tokens.Read →