Qwen4-35B-A3B GGUF on Your Own Device: A 20 KiB-per-Token Cache, a 20B N-gram Table, and Which Build Fits 16, 24 and 48 GB A developer parsed the GGUF header and config of Qwen4-35B-A3B, Qwen's Apache 2.0 35B-parameter mixture-of-experts model with 3B active parameters and a native 1,048,576-token context, to estimate on-device memory costs. Because only 10 of 40 layers use full attention, the KV cache comes to about 20 KiB per token in BF16 (20 GiB at 1M tokens), versus 80 KiB if all layers were standard GQA, while the 30 Gated DeltaNet layers hold a fixed 60 MiB recurrent state that does not grow with context. The author cautions that the fit tables for 16, 24 and 48 GB devices are plans rather than measurements. Qwen released Qwen4-35B-A3B on December 3, 2026 under Apache 2.0: 35B parameters, about 3B active per token, 256 experts, 40 layers, and a native 1,048,576-token window. Community GGUF builds appeared within hours. We read the model config and parsed a real GGUF header the Q4 K M file of Chungulus/Qwen4-35B-A3B-GGUF to answer the on-device question: what does it cost in memory? All sizes below come from the Hugging Face file listings and the parsed header. Fit tables are plans, not measurements: run your own prompt before you rely on them. Sources: Qwen/Qwen4-35B-A3B https://huggingface.co/Qwen/Qwen4-35B-A3B , Chungulus/Qwen4-35B-A3B-GGUF https://huggingface.co/Chungulus/Qwen4-35B-A3B-GGUF , tomngdev/Qwen4-35B-A3B-GGUF https://huggingface.co/tomngdev/Qwen4-35B-A3B-GGUF . The model card describes a hybrid layout: ten repeats of three Gated DeltaNet layers linear attention followed by one Qwen Sparse Attention layer, with a mixture-of-experts feed-forward after each. From config.json : | Field | Value | |---|---| | Layers | 40 30 linear attention, 10 full attention | | Hidden size | 2048 | | Experts | 256 routed, 8 active per token, plus 1 shared, intermediate size 512 | | Attention heads | 16 query, 2 KV, head dimension 256 | | Linear attention heads | 32 value, 16 query/key, head dimension 128 | | Sparse attention budget | 2048 tokens per query indexer with 4 heads, 1 shared key head, dimension 128 | | Vocabulary | 248,320 | | Context | 1,048,576 native | | Extras | multi-token prediction layer, vision encoder 27 layers , 4-branch gated residual | | License | Apache 2.0 | The card also lists a "20B n-gram embedding" on top of the 35B, and says the architecture "improves model quality without extra compute or accelerator memory overhead". That sentence is the key to the file sizes below: the n-gram table is a lookup, not a layer that every token multiplies through. Only layers with full attention keep a per-token key and value cache. We counted them in the config: 10 of 40, with 2 KV heads of dimension 256. full layers, kv heads, head dim = 10, 2, 256 bf16 = 2 bytes per token = full layers 2 kv heads head dim bf16 K and V print per token, per token / 1024 20480 bytes - 20.0 KiB for ctx in 32 768, 131 072, 262 144, 1 048 576 : print ctx, round per token ctx / 2 30, 3 , "GiB" 32K 0.625, 128K 2.5, 256K 5.0, 1M 20.0 If all 40 layers were ordinary GQA layers with the same shape, the figure would be 80 KiB per token, four times larger. This is a counterfactual we computed to show the effect of the hybrid design, not a model that exists. Two caveats. First, the sparse attention indexer keeps its own key 1 head, dimension 128 . If a runtime caches it in BF16 that could add up to 2.5 KiB per token across the 10 layers; we did not measure what each runtime allocates. Second, the 2048-token budget limits how much the model reads per step, not how much you store. The cache still grows with the prompt. With an 8-bit KV cache type the per-token figure drops to about 10.6 KiB Q8 0 stores 34 bytes per 32 values, computed . Whether your build supports a quantized cache for this architecture is something to test, not assume. Gated DeltaNet layers carry a fixed-size recurrent state instead of a growing cache. From the config, the state per layer is value heads times key dimension times value dimension: 32 x 128 x 128 = 524,288 values. In FP32 mamba ssm dtype is float32 that is 2 MiB per layer, 60 MiB for all 30 layers . A short convolution state kernel size 4 adds a small amount on top. The point for edge deployment: this part does not grow when you go from 8K to 800K tokens. We downloaded the first 24 MiB of the Q4 K M file the GGUF header with all tensor descriptors and summed tensor sizes by role. The header reports architecture qwen4exp , 40 blocks, 256 experts, 8 used, and 882 tensors. | Group | Size in the Q4 K M file | |---|---| | Routed expert tensors gate, up, down | 18.16 GiB | | Everything else attention, linear attention, shared expert, routers, output, embeddings, gated residual | 1.79 GiB | | per layer token embd.weight , shape 128 x 160,003,584, Q5 0 | 13.11 GiB | | File total | 33.07 GiB | The n-gram table holds 128 x 160,003,584 = 20.48 billion values, which matches the "20B n-gram embedding" in the card. One row is 128 values, 88 bytes in Q5 0. Each token needs a few such rows, not the whole table. That is why other builders ship it as a separate file engram- .gguf or ple- .gguf and tell you to add it with --shard . The consequence for planning: the number to compare against your VRAM is the core , not the file total. Whether your runtime keeps the table in system memory or maps it from disk depends on the build and flags, so read the load log. From the file listing of Chungulus/Qwen4-35B-A3B-GGUF shards summed, GiB : | Build | Core | Embedding file | Total | |---|---|---|---| | Q2 K | 12.25 | 10.73 Q4 0 | 22.98 | | Q3 K S | 14.31 | 10.73 Q4 0 | 25.04 | | Q3 K M | 15.83 | 10.73 Q4 0 | 26.56 | | Q3 K L | 17.12 | 10.73 Q4 0 | 27.85 | | IQ4 XS | 17.88 | 10.73 IQ4 NL | 28.61 | | IQ4 NL | 18.83 | 10.73 IQ4 NL | 29.56 | | Q4 K S | 18.74 | 13.11 Q5 0 | 31.85 | | Q4 K M | 19.96 computed | 13.11 bundled | 33.08 | | Q5 K S | 22.59 | 14.31 Q5 1 | 36.90 | | Q5 K M | 23.31 | 14.31 Q5 1 | 37.62 | | Q6 K | 26.86 | 20.27 Q8 0 | 47.13 | | Q8 0 | 34.75 | 20.27 Q8 0 | 55.02 | A separate release by tomngdev uses llama-quantize --target-bpw and offers Q4 K XL 23.15 GiB core, target 5.5366 bits per weight and Q6 K XL 32.13 GiB, 7.6860 , with the embedding as engram-Q8 0.gguf 20.27 GiB or engram-IQ4 NL.gguf 10.73 GiB . Its card includes a multi-token-prediction head quantized to Q8 0 and a llama.cpp command using --spec-type draft-mtp . The Chungulus bundle also lists an F16 vision projector of 0.84 GiB. The embedding precision is a separate choice from the core precision. Q4 K S pairs an 18.74 GiB core with a Q5 0 table, while IQ4 NL pairs an 18.83 GiB core with an IQ4 NL table that is 2.4 GiB smaller. We have no quality numbers for these combinations, so we do not rank them. Plan = core + cache at BF16 + 60 MiB recurrent state + about 1.5 GiB for compute buffers our assumption; it varies with batch size and runtime . | GPU | Build core | Cache bound | Plan total | |---|---|---|---| | 16 GB | Q2 K 12.25 GiB | 0.63 GiB at 32K | about 14.4 GiB | | 24 GB | IQ4 XS 17.88 GiB | 2.5 GiB at 128K | about 21.9 GiB | | 24 GB | Q4 K M 19.96 GiB | 0.63 GiB at 32K | about 22.1 GiB | | 32 GB | Q6 K 26.86 GiB | 2.5 GiB at 128K | about 30.9 GiB | | 48 GB | Q8 0 34.75 GiB | 5.0 GiB at 256K | about 41.3 GiB | The n-gram table is not in these totals. Budget 10.7 to 20.3 GiB of system RAM or fast SSD for it 13.11 GiB for Q4 K M , and 0.84 GiB more for the vision projector if you want images. The MoE structure also makes partial expert offload to system RAM an option for smaller cards, but we have not measured its speed and we give no number. Quality is the open column. The official card links a benchmark image, and we have not rerun any of it on the quantized files, so we make no claim about how much each build keeps. Test on your own task. The Chungulus card points to a pinned llama.cpp commit for Qwen4 support 59b7165 . Build that, start from the first shard, and add the embedding file with --shard : hf download Chungulus/Qwen4-35B-A3B-GGUF \ --include "Qwen4-35B-A3B-IQ4 XS- .gguf" "ple-Qwen4-35B-A3B-IQ4 NL.gguf" \ --local-dir . llama-server -m Qwen4-35B-A3B-IQ4 XS-00001-of-00003.gguf \ --shard ple-Qwen4-35B-A3B-IQ4 NL.gguf \ -ngl 99 -c 131072 Add --mmproj mmproj-Qwen4-35B-A3B-F16.gguf for images. Official sampling advice from the card: thinking mode temperature=1.0, top p=0.95, top k=20 ; non-thinking temperature=0.7, top p=0.80, top k=20, presence penalty=1.5 . Thinking is controlled with reasoning effort xhigh , high , low , off . A quick audit you can repeat: fetch the first 24 MiB of your file, list the tensors, and sum the bytes of per layer token embd.weight versus the rest. It takes a minute and tells you what you are about to place in memory. Is Qwen4-35B-A3B open? The weights are on Hugging Face under Apache 2.0, in Transformers format, and the card names vLLM, SGLang, llama.cpp, ollama, MLX and LiteRT-LM as supported. Why does a 35B model need only about 20 GiB of core weights at 4 bits? The card's 35B figure covers the transformer and experts, while the separate 20B n-gram embedding is a lookup table. In the Q4 K M file, experts take 18.16 GiB and everything else 1.79 GiB. How much memory does a 1M-token prompt need? Cache: 20 GiB at BF16 by our computation plus possible indexer keys , plus 60 MiB of recurrent state. That is on top of the weights, so it is a workstation figure, not a phone figure. Does the cache really stop growing in the linear layers? Yes: their state is fixed at 60 MiB in FP32 for all 30 layers, independent of prompt length. Which quant should I start with? For 24 GB, IQ4 XS with a 128K context is the plan with the most headroom in our table. For 16 GB, Q2 K at 32K. Run your own evaluation before you ship either.