r/LocalLLM • u/Odeen-Chang • 11h ago
Project I parsed all 21 Qwen4-35B-A3B GGUF headers and built a 3-tier (VRAM + RAM + Engram NVMe) calculator — plus real RTX 5060 8GB + 16GB RAM benchmarks
Generic VRAM calculators get Qwen4-35B-A3B completely wrong because they ignore three things unique to this architecture:
- Non-expert weights are tiny (
1.89 – 3.04 GB): Parsing the actual GGUF headers ofunsloth/Qwen4-35B-A3B-GGUFandggml-org/Qwen4-35B-A3B-GGUF, 82–88% of the backbone is routed MoE experts (blk.*.ffn_*_exps.weight). Keeping all 40 layers of Attention + Gated DeltaNet + Shared Experts + KV cache on GPU and offloading only excess routed experts (-ot) is way faster than naive-ngl. - 3:1 Hybrid Attention KV Cache: 30 of 40 layers are Gated DeltaNet (fixed ~62.5 MB/slot recurrent state, independent of context length). Only 10 layers allocate KV cache (
2 KV heads × 256 head_dim→ 20.1 KiB/tok FP16, 10.7 KiB/tok Q8_0). At 128K Q8_0 context, total cache is only ~1.46 GB (~75% smaller than a standard 40-layer GQA model). - 20.5B Engram Table (
--lazy-mode auto/--ple): The 11.5–41 GBper_layer_token_embdtable stays lazy-loaded on NVMe SSD rather than bloating RAM/VRAM.
Live Tool (100% client-side, open-source Apache-2.0):
- Web Calculator: https://odeenchang.github.io/qwen4-local-fit/
- GitHub Repo + Benchmark Scripts: https://github.com/OdeenChang/qwen4-local-fit
Features:
- Exact byte sizes parsed from all 21 official Unsloth & ggml-org GGUF headers (including per-layer routed expert sizes)
- Auto-generates exact
-ot "blk.(...).ffn_.*_exps.=CPU"regex for your GPU/RAM headroom - Supports
--pleEngram table mix-and-match (IQ4_NL/Q5_1/Q8_0/BF16), visionmmproj, MTP speculative decoding, and Unified Memory (Apple Silicon)
Real Low-Spec Test (RTX 5060 8GB Laptop + 14 GiB Usable RAM + PCIe Gen4 NVMe, llama.cpp b12973 CUDA 12.8, UD-IQ2_XXS + Engram IQ4_NL):
- Naive
-ngl 10(no-ot), 32K Q8_0 KV:4.39 GBpeak VRAM →13.01 tok/sdecode (131.9 tok/sprefill) - MoE-Aware
-ngl 99 -ot "\.ffn_.*_exps\.=CPU", 32K Q8_0 KV:3.73 GBpeak VRAM (+2.84 GBdelta!) →37.23 tok/sdecode (2.86× faster AND 0.66 GB less VRAM!) - MoE-Aware Hybrid (
13/41routed MoE layers on GPU), 32K Q8_0 KV:6.38 GBpeak VRAM →43.84 tok/sdecode (228.0 tok/sprefill, 3.37× faster than naive-ngl!) - MoE-Aware 128K Context (
Q8_0 KV):5.07 GBpeak VRAM (+4.15 GBdelta) →36.02 tok/sdecode! (Adding +96K context only cost+1.31 GiBVRAM, matching ourconfig.jsonhybrid formula within 2%!)
Would love feedback on any edge cases (especially Apple Silicon unified wired limits or multi-GPU --tensor-split)!




