Skip to content
المشاريع

حول

Byte-exact 3-tier (VRAM + RAM + Engram NVMe) local fit calculator & llama.cpp -ot command generator for Qwen4-35B-A3B — verified at 43.8 tok/s on 8GB RTX 5060

الذكاء الاصطناعي وتعلّم الآلة

كيف تُقاس هذه الأرقام

النمو المقاس للنجوم

خلال 24 ساعة
جارٍ جمع السجل
خلال 7 أيام
جارٍ جمع السجل
خلال 15 يومًا
جارٍ جمع السجل
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

Qwen4-35B-A3B Local Fit & Offload Calculator

Byte-exact 3-Tier Memory Planner (GPU VRAM + System RAM + Engram NVMe SSD) & llama.cpp Command Generator for Qwen/Qwen4-35B-A3B.

Live Web Tool: https://odeenchang.github.io/qwen4-local-fit/


Why Generic VRAM Calculators Fail on Qwen4-35B-A3B

Standard params × bits calculators overestimate Qwen4-35B-A3B's memory requirements by 2×–4× because Qwen4 introduces three architectural shifts that fundamentally change local deployment math:

  1. 20.5B Engram (per_layer_token_embd) Lazy SSD Offloading (--lazy-mode auto):
    • The massive 20.5B n-gram embedding table at layer 2 (11.52 GB in IQ4_NL, 15.36 GB in Q5_1, 21.76 GB in Q8_0, 40.96 GB in BF16) stays on your NVMe SSD and is paged on demand—not loaded into VRAM or pinned RAM.
  2. 82–88% Routed MoE Experts (-ot):
    • Parsing the actual GGUF headers shows that all 40 layers of Attention + Gated DeltaNet + Shared Experts + Embeddings + Norms total only 1.89 – 3.04 GB across 1-bit to 6-bit quants!
    • By keeping 100% of non-expert layers + KV Cache on GPU and offloading only excess routed experts (-ot "blk\.(\d+)\.ffn_.*_exps\.=CPU"), even an 8 GB VRAM + 16 GB (14 GiB usable) RAM laptop can run Qwen4-35B-A3B smoothly without OOM.
  3. 3:1 Hybrid Attention KV Cache (30 Gated DeltaNet + 10 Qwen Sparse Attention):
    • 30 layers use constant-size recurrent state (~62.5 MB/slot fixed, independent of context length).
    • Only 10 layers allocate KV cache (2 KV heads × 256 head_dim), costing just 20.1 KiB/tok (FP16) or 10.7 KiB/tok (Q8_0) — ~75% smaller than a standard 40-layer GQA model. At 128K context (Q8_0), total cache is only ~1.46 GB.

Exact Parsed Tensor Breakdown (Selected GGUFs)

All tensor counts and byte footprints in data.js were parsed directly from the official Hugging Face GGUF headers of unsloth/Qwen4-35B-A3B-GGUF and ggml-org/Qwen4-35B-A3B-GGUF:

Quant Source Total Backbone Non-Expert (Attn+DeltaNet+Shared+Embd) Routed MoE Experts Engram Table (SSD)
UD-IQ1_S unsloth 9.74 GB 1.89 GB 7.85 GB 11.52 GB (IQ4_NL)
UD-IQ2_XXS unsloth 11.87 GB 2.10 GB 9.76 GB 11.52 GB (IQ4_NL)
UD-Q2_K_XL unsloth 16.15 GB 2.43 GB 13.72 GB 11.52 GB (IQ4_NL)
UD-IQ3_XXS unsloth 17.20 GB 2.57 GB 14.63 GB 11.52 GB (IQ4_NL)
UD-Q3_K_XL unsloth 19.35 GB 2.76 GB 16.59 GB 11.52 GB (IQ4_NL)
UD-Q4_K_M unsloth 23.65 GB 2.95 GB 20.70 GB 11.52 GB (IQ4_NL)
Q4_K_M ggml-org 21.92 GB 2.41 GB 19.50 GB 14.08 GB (Q5_0)
Q6_K ggml-org 29.24 GB 2.81 GB 26.42 GB 21.76 GB (Q8_0)
Q8_0 ggml-org 37.63 GB 3.41 GB 34.23 GB 21.76 GB (Q8_0)

Real Hardware Verification (RTX 5060 8 GB Laptop + 14 GiB Usable RAM + NVMe)

  • GPU: NVIDIA GeForce RTX 5060 Laptop GPU (8 GB VRAM, GB206)
  • CPU / RAM: Intel Core i7-14650HX (16C/24T) · 14.0 GiB Usable RAM
  • NVMe SSD: SAMSUNG MZVL81T0HELB-00BTW (PM9C1a PCIe Gen4 NVMe) (Measured: Seq R 1.85 GB/s, Seq W 1.17 GB/s, Rand 256KB R 0.83 GB/s, Rand 4KB 62.0 µs)
  • Runtime: llama.cpp b12973 (CUDA 12.8) · unsloth/Qwen4-35B-A3B-GGUF (UD-IQ2_XXS + Engram IQ4_NL)
Configuration Quant & Offload Filled Context Peak VRAM Peak RSS RAM Prefill (tok/s) Decode (tok/s) Measurement
MoE-Aware Hybrid UD-IQ2_XXS · 13/41 MoE GPU · Q8_0 KV 32,768 6.12 GiB 9.49 GiB — 36.47 12 threads · 1 run, no warmup
MoE-Aware Hybrid UD-IQ2_XXS · 13/41 MoE GPU · Q8_0 KV 65,536 6.55 GiB 8.57 GiB — 26.17 12 threads · 1 run, no warmup
All Routed Experts CPU UD-IQ2_XXS · -ngl 99 -ot exps=CPU · Q8_0 KV 131,072 4.85 GiB 11.42 GiB — 19.35 12 threads · 1 run, no warmup
Optimized MoE-Aware Hybrid UD-IQ2_XXS · 13/41 MoE GPU · Q8_0 KV 131,072 7.43 GiB 11.46 GiB 851.64 22.13 16 threads · 3 runs + warmup

Decode uses llama-bench -d <filled depth> -p 0 -n 128; the 128 output tokens bring the total context to the value shown. Prefill is measured independently with -p 130944 -n 0. These are not short-request speeds at an allocated context size. The previous table used a 163-token prompt for every row and has been replaced. See bench/extreme-results-20261205/EXTREME_CONTEXT_RESULTS.md and bench/optimization-results-20261205/ for raw logs and telemetry.

The calculator's decode estimate is now calibrated against the cold-run filled-context curve at 4K/32K/64K/128K instead of the withdrawn short-request numbers. The Q4 KV estimate includes the measured 64K dequantization penalty. Other GPUs/quants remain model-based estimates; results beyond 128K are labeled as extrapolations rather than measurements.

Run Locally / Customize

Zero dependencies, pure static HTML/CSS/ES modules:

git clone https://github.com/OdeenChang/qwen4-local-fit.git
cd qwen4-local-fit
python3 -m http.server 8000

Tests

node --experimental-default-type=module --test tests/calculator.test.mjs

The regression suite covers built-in and custom VRAM/RAM reserves, including the requested 3 GB VRAM scenario and finite accounting across all 21 quants.

Aggressive Launch Playbook

License

Apache-2.0 — Built by Yuyang Zhang (OdeenChang).

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…