Skip to content
Inference Academy

Qwen4-35B-A3B explained: hybrid attention, n-gram embeddings and benchmarks

Alibaba's first open Qwen4 model: a 35B mixture-of-experts with about 3B active parameters, a hybrid of Gated DeltaNet linear attention and Qwen Sparse Attention, 20B of n-gram embeddings that can live in system RAM, a native 1M-token context, image and video input, multi-token prediction and an Apache-2.0 licence. What each piece does, how small its cache really is, how its benchmarks compare, and what it means for serving.

Key takeaways

  • Qwen4-35B-A3B is a mixture-of-experts model: 35B parameters with about 3B active per token, plus 20B of n-gram embeddings and a 2B multi-token-prediction module.
  • Three of every four layers use linear attention with a fixed-size state; only 10 of 40 keep a KV cache, so a 1M-token context needs about 20 GiB in BF16.
  • The 20B n-gram embedding table is a lookup, not compute, so engines can keep it in system RAM and leave only about 40 GB of FP8 weights on the GPU.
  • On Qwen's chart it ties the larger Qwen3.8-Flash-Next 6 to 6 across 12 benchmarks, trailing most on terminal and frontier coding tasks.
  • It is Apache-2.0, takes text, images and video, and has four reasoning-effort levels from off to xhigh.

By

7 min read

Share
On this page

Qwen released Qwen4-35B-A3B this week, the first open-weights model of the Qwen4 series (its weights appeared on Hugging Face on 3 December 2026, with Hugging Face's launch post on 4 December). It is small enough to run on a single workstation GPU or a large Mac, yet Qwen's own chart puts it level with its much larger Qwen3.8-Flash-Next: ahead on half of the tasks it reports and behind on the other half.

What makes it interesting for anyone who serves models is the architecture: almost every trick for cheap long-context inference is in one model. This article explains each piece from the model card, its config.json, the vLLM and SGLang recipes and Hugging Face's launch post. For running it yourself, see how to run Qwen4-35B-A3B locally.

#At a glance

Qwen4-35B-A3B
Parameters 35B (about 3B active per token), plus 20B n-gram embedding and 2B multi-token prediction
Layers 40: 10 blocks of 3 Gated DeltaNet layers and 1 Qwen Sparse Attention layer
Experts 256 routed (8 active per token) plus 1 shared, expert width 512
Hidden size 2,048
Context window 1,048,576 tokens, natively
Inputs Text, images and video (27-layer vision encoder)
Reasoning Thinking on by default; effort levels xhigh, high, low, off
Licence Apache-2.0
Checkpoints BF16, FP8, plus community GGUF and MLX quantisations

Sources disagree slightly on the active parameter count: the model card and vLLM say 3B activated, Hugging Face's post says about 3.8B. The difference is likely what gets counted (embeddings, the shared expert, the vision encoder); for speed estimates, use the larger figure.

#A mixture of experts with tiny experts

Each MoE layer has 256 experts plus a shared one, and a router sends each token to 8 of them. Each expert is narrow (an intermediate size of 512), so a token touches only about a tenth of the 35B parameters. That is why decode is fast: at batch 1, each token reads about 3 to 4 GB of weights in FP8, far less than a dense 30B model (mixture-of-experts inference explained).

The catch is the usual one for MoE models: memory follows the total, not the active count. Every expert has to be resident, so the GPU still needs room for all 35B parameters.

#Hybrid attention: why the cache is so small

Qwen4's layers come in groups of four:

  • Three Gated DeltaNet layers. This is a form of linear attention: instead of keeping every past token's keys and values, each head keeps a fixed-size state (a 128 × 128 matrix per head here) and updates it with every token. Its memory does not grow with the context.
  • One Qwen Sparse Attention layer. This is full attention with grouped-query heads (16 query heads, 2 KV heads of size 256), plus a lightweight indexer that picks which parts of the context each query attends to, with a budget of 2,048 tokens.

So only 10 of the 40 layers keep a KV cache. Working it out from config.json:

Cache per sequence 32K tokens 1M tokens
KV cache if all 40 layers used full attention (BF16) 2.5 GiB 80 GiB
Qwen4's 10 full-attention layers (BF16) 640 MiB 20 GiB
Gated DeltaNet state (30 layers, FP32) 60 MiB, fixed 60 MiB, fixed

Each full-attention layer stores 2×2×256=1,0242 \times 2 \times 256 = 1{,}024 values per token, 20 KiB per token across the 10 layers in BF16. The vLLM recipe goes further, storing the KV cache in NVFP4, which it says is about 3.6 times smaller than BF16. That brings a full 1M-token sequence down to roughly 5.6 GiB.

The sparse-attention indexer is what keeps attention cost in check at long context: even when the KV cache holds a million tokens, each query reads only the parts the indexer selects. Our lesson on linear attention and hybrid models covers the trade-offs: linear layers compress the past into a fixed state, so recall of exact details from far back relies on the full-attention layers.

One practical consequence: prefix caching works differently with a recurrent state. An engine cannot cut a cached prefix at any token; it has to store state checkpoints. vLLM enables prefix caching in its recipe and SGLang keeps its radix cache on NVIDIA GPUs, but check the hit rate on your own workload rather than assuming it behaves like a pure-attention model (KV cache explained).

#N-gram embeddings: 20B parameters that cost no compute

The most unusual part is the per-layer n-gram embedding (PLE): a table of 10 million entries for common bigrams and trigrams, added at layer 2. Qwen says it improves quality "without extra compute or accelerator memory overhead", and the numbers show how: it is a lookup, so each token reads a handful of rows rather than multiplying by the whole table.

That is why engines can keep the table in system RAM. vLLM offloads it to host memory by default: the GPU holds about 39.7 GB of weights in FP8 (72.7 GB in BF16), and the host needs about 20.5 GB (41 GB) for the table. SGLang's measurements on an RTX PRO 6000 show that offloading the table cut peak GPU memory from about 47 to 28 GiB, with only a few percent less speed. It also explains the odd download size: the BF16 repository holds about 57 billion parameters, not 35.

#Multi-token prediction built in

Qwen4 ships a 2B multi-token-prediction (MTP) module, a small extra layer trained to guess several tokens ahead. Engines use it for speculative decoding without a separate draft model: vLLM's recipe drafts 3 tokens per step, and SGLang reports an average of 3.3 to 3.5 tokens accepted per step in its single-GPU tests. Hugging Face's post reports 22% faster generation with MTP in llama.cpp on an Apple M5 with a 4-bit quantisation.

#Benchmarks

Qwen's chart compares the model with its own larger Qwen3.8-Flash-Next and Qwen3.8-27B, and with Inkling2 Mini. Some scores are cited from Artificial Analysis and Mercor's leaderboards; Work360 is Qwen's own benchmark.

Benchmark Qwen4-35B-A3B Qwen3.8-Flash-Next Qwen3.8-27B Inkling2 Mini
DeepSWE v1.1 61.8 58.7 42.2 48.2
Terminal Bench 4.1 21.2 24.2 5.6 5.6
FrontierCode-AA 2.0 16.1 27.1 14.9 15.1
NL2Repo 51.7 48.1 42.3 41.8
Work360 (Qwen's own) 42.9 43.7 37.1 30.4
APEX Agents v1.1 59.0 61.0 47.5 50.9
AA-Briefcase v1.1 (Elo) 1486 1567 1391 1263
AutomationBench-AA 57.9 55.9 48.2 41.8
HealthBench Professional 47.4 34.8 29.8 45.7
GPQA 86.9 91.7 89.2 86.9
Chartography 27.8 24.6 27.8 22.1
VideoIndex 52.9 51.4 51.9 44.0

Against Qwen3.8-Flash-Next it is ahead on 6 of the 12 and behind on 6, with the largest gaps in its disfavour on FrontierCode-AA 2.0 (16.1 against 27.1) and the Briefcase Elo. Against models of its own size it leads almost everywhere: it beats Qwen3.8-27B on 10 of 12 (tying on Chartography, behind on GPQA) and Inkling2 Mini on 11 (tying on GPQA). All of these are on Qwen's chosen benchmarks and settings, with thinking on; run your own evaluation before you swap it into a product (evaluating cost and latency).

#Reasoning effort, and why low is not always cheaper

Qwen4 thinks by default (reasoning_effort="high"), with xhigh, low and off as the other levels. The model card makes a point worth repeating for anyone running agents: lower effort can mean more failed attempts and retries, so total time and tokens per task can go up. Measure cost per completed task, not per call. Recommended sampling is temperature 1.0, top-p 0.95 and top-k 20 with thinking on, and temperature 0.7, top-p 0.8, top-k 20 and a presence penalty of 1.5 with it off. With thinking on, Qwen suggests allowing up to 262,144 tokens of reasoning and 131,072 of final answer.

#What it means for inference engineers

  • Long context becomes a single-GPU feature. With a 20 GiB BF16 cache for a million tokens, or a few GiB in NVFP4, long-context serving no longer needs a cluster for one sequence.
  • System RAM is part of the memory budget now. Plan host RAM for the n-gram table, just as you plan GPU memory for the KV cache.
  • Speculative decoding is free to try. The MTP head ships with the model.
  • Engine support is new. At launch vLLM and SGLang used dedicated qwen4 images (SGLang support was not yet in a release), and the tokenizer needs trust_remote_code. Pin the image you tested.

Sources: Qwen4-35B-A3B model card and config.json, vLLM recipe, SGLang cookbook, Hugging Face launch post. Cache sizes are our arithmetic from config.json; benchmark scores are as published by Qwen on 4 December 2026.

newsmodelsmoelocalserving

Found this useful?

Send it to someone who is learning the same thing.

Share this article

Preparing for an interview?

Next: the lesson behind this article

Linear attention, DeltaNet and KDA: how hybrid models keep the cache small

Why the KV cache grows with every token, how linear attention swaps it for a fixed-size state, why that state forgets, how the delta rule, gates and Kimi Delta Attention fix it, how chunking puts i… The opening is free to read; Pro unlocks the rest, the labs and the certificate.

Free 5-day email course

Why LLM inference is slow and how to make it fast. One short email a day for five days, each built on a free lesson, then the occasional new lesson or offer. Unsubscribe in one click.