{
  "id": "qwen4-35b-a3b",
  "title": "Qwen4-35B-A3B with experts in RAM, CPU-side cache misses and the built-in MTP drafter",
  "summary": "Qwen's 35B-A3B hybrid MoE (Unsloth UD-Q4_K_M, 23.7 GB plus an 11.5 GB n-gram table) on stock llama.cpp at 131k: experts in RAM, a 3800 MiB MoE cache with misses computed on the CPU, q8_0 KV and the built-in MTP drafter. 61.4 tok/s decode (stock 37.2), 54.9 at 32k, needles exact at 124.5k.",
  "status": "measured",
  "updated": "2026-12-04",
  "use_cases": [
    "coding",
    "agents",
    "long-context",
    "moe-offload"
  ],
  "model": {
    "name": "Qwen4-35B-A3B",
    "hf_repo": "Qwen/Qwen4-35B-A3B",
    "params": "35B-A3B",
    "architecture": "MoE hybrid (30 Gated DeltaNet + 10 Qwen Sparse Attention blocks, 256 experts top-8 + shared, n-gram embedding table, MTP head)",
    "license": "Apache-2.0"
  },
  "weights": {
    "format": "GGUF",
    "quant": "UD-Q4_K_M (imatrix)",
    "size_gb": 35.18,
    "source": "https://huggingface.co/unsloth/Qwen4-35B-A3B-GGUF",
    "file": "Qwen4-35B-A3B-UD-Q4_K_M-00001-of-00002.gguf",
    "revision": "3ef64303abd0e81681d257437fc35d1ab0d49519",
    "notes": "Two files: the model (23.66 GB) and the n-gram table as IQ4_NL (11.52 GB, -00002-of-00002). The MTP head is inside the model file."
  },
  "engine": {
    "name": "llama.cpp",
    "repo": "https://github.com/ggml-org/llama.cpp",
    "version": "master at 59b716523",
    "cuda": "sm_86 build"
  },
  "hardware": {
    "gpu": "NVIDIA GeForce RTX 3060",
    "vram_gb": 12,
    "ram_gb": 62,
    "cpu": "Intel Core i5-12500",
    "disk": "NVMe SSD",
    "os": "Linux",
    "notes": "The desktop is on the same card (about 1.9 GB during these runs). Experts are read from page cache; the memory cap was 44 GB."
  },
  "serve": {
    "command": "./serve.sh",
    "script": "serve.sh",
    "port": 8112,
    "api": "OpenAI-compatible /v1 (llama-server)",
    "key_flags": [
      "QW_PROFILE=default|nospec|stock",
      "--cpu-moe --moe-cache-mib 3800 --moe-cache-cpu-share 0.95",
      "--spec-type draft-mtp --spec-draft-n-max 2 --spec-draft-n-ubatch 64",
      "-ot per_layer_token_embd=CPU --load-mode mmap --lazy-mode on",
      "-ctk q8_0 -ctv q8_0 -ub 1024 -c 131072",
      "chat_template_kwargs enable_thinking false per request",
      "QW_OMP_PASSIVE=1 (OpenMP threads sleep: about half the CPU time, 4-9% less decode)"
    ]
  },
  "context_tokens": 131072,
  "placement": "Every routed expert in RAM with llama.cpp's MoE cache holding hot experts in 3800 MiB of VRAM and 95% of cache misses computed on the CPU; attention, DeltaNet, shared experts, LM head, the q8_0 KV cache (10 sparse-attention blocks) and the MTP context on the GPU; the n-gram table read from the NVMe on demand.",
  "results": [
    {
      "metric": "decode",
      "label": "default (MTP n 2, q8_0 KV, 3800 MiB MoE cache), empty context, thinking off, coding answers, median of three runs",
      "value": 61.4,
      "unit": "tok/s",
      "baseline": 37.2,
      "ceiling": 120,
      "headline": true,
      "source": "qwen4-35b-a3b/RESULTS.md:32"
    },
    {
      "metric": "decode",
      "label": "default at 32k depth",
      "value": 54.9,
      "unit": "tok/s",
      "baseline": 35.7,
      "headline": true,
      "source": "qwen4-35b-a3b/RESULTS.md:33"
    },
    {
      "metric": "decode",
      "label": "default at 120k depth",
      "value": 42.5,
      "unit": "tok/s",
      "source": "qwen4-35b-a3b/RESULTS.md:34"
    },
    {
      "metric": "decode",
      "label": "nospec profile, empty context",
      "value": 49.9,
      "unit": "tok/s",
      "source": "qwen4-35b-a3b/RESULTS.md:32"
    },
    {
      "metric": "prefill",
      "label": "8k prompt, default",
      "value": 458.8,
      "unit": "tok/s",
      "baseline": 376.3,
      "source": "qwen4-35b-a3b/RESULTS.md:35"
    },
    {
      "metric": "prefill",
      "label": "8k prompt, nospec profile",
      "value": 617.0,
      "unit": "tok/s",
      "baseline": 376.3,
      "source": "qwen4-35b-a3b/RESULTS.md:35"
    },
    {
      "metric": "prefill",
      "label": "32k prompt, default",
      "value": 430.2,
      "unit": "tok/s",
      "baseline": 375.8,
      "source": "qwen4-35b-a3b/RESULTS.md:36"
    },
    {
      "metric": "prefill",
      "label": "124.5k prompt, default",
      "value": 431.7,
      "unit": "tok/s",
      "source": "qwen4-35b-a3b/RESULTS.md:37"
    },
    {
      "metric": "ttft",
      "label": "124.5k prompt, default",
      "value": 288,
      "unit": "s",
      "source": "qwen4-35b-a3b/RESULTS.md:37"
    },
    {
      "metric": "needles",
      "label": "3/3 exact at 64.4k and 124.5k (49% / 95% of the window)",
      "value": "3/3",
      "unit": "found",
      "headline": true,
      "source": "qwen4-35b-a3b/RESULTS.md:38"
    },
    {
      "metric": "quality",
      "label": "codeeval, thinking on (effort low)",
      "value": "8/8",
      "unit": "tasks",
      "source": "qwen4-35b-a3b/RESULTS.md:74"
    },
    {
      "metric": "quality",
      "label": "codeeval, thinking off",
      "value": "7/8",
      "unit": "tasks",
      "source": "qwen4-35b-a3b/RESULTS.md:75"
    },
    {
      "metric": "vram_peak",
      "label": "card total incl. desktop, default",
      "value": 11774,
      "unit": "MiB",
      "source": "qwen4-35b-a3b/RESULTS.md:39"
    },
    {
      "metric": "ram_peak",
      "label": "RSS, default",
      "value": 29374,
      "unit": "MiB",
      "source": "qwen4-35b-a3b/RESULTS.md:40"
    },
    {
      "metric": "startup",
      "label": "ready, warm page cache, default",
      "value": "2-3",
      "unit": "s",
      "source": "qwen4-35b-a3b/RESULTS.md:41"
    }
  ],
  "caveats": [
    "The native 1M window does not fit: KV is 13.6 KB per token at q8_0. This recipe serves 131k.",
    "Unsloth's guide command does not load on 12 GB: its -ot switches --fit off and every layer goes to the card.",
    "The MTP drafter costs 25% of prefill; QW_PROFILE=nospec serves without it.",
    "Quant drift is not measured: no Q8_0 or BF16 reference fits on disk. Vision and tool calls are not measured.",
    "reasoning_effort off in chat_template_kwargs fails with a template error on this build; enable_thinking false works.",
    "Decode on the default read 59.4-63.3 tok/s over three runs; 61.4 is the median."
  ],
  "credits": [
    "qwen",
    "unsloth",
    "llama-cpp",
    "ggml-org",
    "huggingface",
    "0xsero",
    "rcarmo"
  ],
  "findings": [],
  "contributor": {
    "name": "David Hatley",
    "github": "davidghatley"
  },
  "$schema": "https://davidghatley.github.io/3060-recipes/schema/recipe.schema.json",
  "url": "https://davidghatley.github.io/3060-recipes/recipes/qwen4-35b-a3b/",
  "folder": "https://github.com/davidghatley/3060-recipes/tree/main/qwen4-35b-a3b"
}
