--- title: "Qwen4 35B A3B on the 48 GB Mac mini: first benchmarks" date: 2026-12-05 categories: [ai, llm, macmini] layout: post description: "Qwen4-35B-A3B arrived two days after my Qwen 3.8 measurements. The official NVFP4 tag is 36 GB on a 48 GB machine, so the question was whether it fits at all, what the MTP head buys on a 3B-active model, and what it changes for the pi coding agent that runs on this server." --- [Qwen4-35B-A3B](https://huggingface.co/Qwen/Qwen4-35B-A3B) shipped on December 3, two days after I finished the [thinking-off measurement](./2026-11-30-qwen38-pi-adapted-thinking-off.md) of the pi-adapted Qwen 3.8 27B that serves from my [Mac mini LLM server](./2026-10-13-macmini-local-llm-setup.md). It is a very different model from the 27B dense one: 35B total parameters with about 3B active per token, a 20B n-gram embedding table that is looked up rather than computed, a 2B multi-token prediction head, hybrid linear and sparse attention, a native 1M-token context, and vision. This post is the first day's answer to three questions: does the official tag fit in 48 GB at all, what do the new architecture and the MTP head do to the two rates that matter on this machine, and what has to change so the [pi](https://github.com/earendil-works/pi) coding agent can use it. ## Fitting 36 GB into 48 GB The official `qwen4:35b-a3b-nvfp4` tag is 35.9 GB, and the M4 Pro has 48 GB of unified memory. The budget that adds up: | piece | size | |---|---| | model artifact (core, n-gram table, vision projector, MTP head) | 35.9 GB | | of which wired for compute, as `/api/ps` reports it | 24.5 GB | | macOS, headless, plus the server | about 4-5 GB | The pleasant surprise is the middle line: the 20B n-gram table is looked up, not computed, and the MLX runner does not hold it in wired memory, so the GPU-side footprint is 24.5 GB, not 36. The model stays resident indefinitely (the server runs a 48 h keep-alive), and after an hour of serving, decode showed no swap-degraded drift. Two settings do the heavy lifting. The context window stays at 32768 (`OLLAMA_CONTEXT_LENGTH`), not the native 1M: at 32k the hybrid attention's cache is small, and the window is a memory knob anyway. And **only one model is resident at a time**: Ollama's own accounting says the 36 GB tag and the 18 GB 27B tag do not fit together, so a request for one evicts the other. That works, but loading the big model costs 6 s from a warm page cache and about 2.5-3.5 min cold, so two clients that insist on different tags spend their time swapping models instead of serving requests. I watched that happen while a background agent task was still defaulting to the 27B during the first benchmark pass: every qwen4 request paid a full reload. Everything on this server now defaults to the same tag. Ollama 0.40.21 is required (the registry refuses the pull on anything older, and the model was added in that release). The upgrade was the usual [brew-then-plist dance](./2026-11-30-ollama-04019-macmini.md), except this time the `mlx_metal_v4` runner name survived the version bump, so the plist pin did not need editing. ## The two rates Same method as the previous posts: `bench_ollama.py` in [lora-merge-tools](https://github.com/zonca/lora-merge-tools), run over the network from my work server, three decode runs of 256 tokens, prefill measured at 2k and 8k prompt tokens, model unloaded before its first request so the load time is real. | model | cold load | decode | prefill 2k | prefill 8k | |---|---|---|---|---| | `qwen3.8:27b-nvfp4` | 5.4 s | 28.0 tok/s | 113 tok/s | 109 tok/s | | `qwen3.8-pi:27b-nvfp4` | 6.1 s | 20.8 tok/s | 110 tok/s | 107 tok/s | | `qwen4:35b-a3b-nvfp4` | 3.0 s | **56.8 tok/s** | **295 tok/s** | **432 tok/s** | The load column is from a warm page cache; the first cold load of the 36 GB, straight after the download, took 156 s. Decode is the median of three runs; every run's wall time matched its generation time to within half a second, so the machine served one thing at a time. (The first benchmark pass, run while a background agent task was still defaulting to the 27B, is the cautionary tale: each qwen4 request paid a full reload while the two models evicted each other, and one 27B decode run sharing the runner with the other client dropped to 1.3 tok/s. The numbers above are the clean re-run, with the queue empty.) **Decode doubles**: 56.8 tok/s against 28.0 for the base 27B, at a much bigger total model. The multi-token prediction head is in the artifact, and the MLX runner's speculative decoder is the same mechanism that pushes the 27B past its own bandwidth bound (28.7 tok/s measured against a physical limit of about 15). For a 3B-active model the bandwidth bound is higher, so the rate alone proves less than it does for the 27B; the remote evidence is the acceptance signature: counting numbers decodes at 56.6 tok/s while random word salad decodes at 43.6 tok/s, the same content-predictability spread MTP shows on the 27B, and the server's `speculative decode stats` log lines are the direct proof for anyone at the machine. **Prefill is the bigger news for an agent.** The 27B's 100-130 tok/s prefill floor was the entire cost model of agent turns on this machine: a turn cost `context / 110` seconds, a cold 26k-token pi session cost about four and a half minutes before the first token, and the difference between a cached turn (10-30 s) and a post-compaction turn (300-400 s) was the difference between a tolerable and an unusable agent. Qwen4 prefills at 295 tok/s at 2k and 432 tok/s at 8k, and it gets faster with length: the hybrid attention keeps the per-token cache small and the sparse mixture-of-experts batches well, so the fixed costs amortize. The same cold 26k session now costs about a minute. ## Thinking, off by configuration The model thinks by default: `/api/show` reports `thinking` values `false, low, medium, high, xhigh, max` with `high` as the default. The OpenAI-compatible endpoint ignores `think` and `enable_thinking` and only honours `reasoning_effort`, exactly like Qwen 3.8 on [0.40.19](./2026-11-30-ollama-04019-macmini.md), so pi's model entry carries `"thinkingLevelMap": {"off": "none"}` and `defaultThinkingLevel` stays `off`. Verified on the running server: `"reasoning_effort": "none"` answers "OK" with one completion token and no reasoning block, the default reasons before answering "42", and the reasoning arrives as a separate `reasoning` field pi can ignore. The context window entry stays 32768, so pi's compaction behaves as before. ## What changed for pi The tag is now the default everywhere pi runs on my work server: my interactive sessions and the background agent that processes my Trello cards share one `~/.pi/agent/` configuration, so one change covers both. The model entry in `models.json` declares the 32k window and the thinking map, `settings.json` points `defaultModel` at the new tag with the same compaction override as the old ones, and the two 27B tags stay enabled for side-by-side comparison. Verified end to end: a fresh `pi --print` session answers on the new tag, and the server's loaded-model list shows `qwen4:35b-a3b-nvfp4` being pulled in to serve it. ## What is still missing: the pi adapter The `qwen3.8-pi` tag exists because [harness-hub](https://huggingface.co/harness-hub) trained a pi adapter for that exact base model, which I [merged into the weights](./2026-11-21-qwen38-pi-adapted-merged-fp16.md). For Qwen4 the same team announced harness adapters on December 4, but training is still running and nothing is published yet. So today's default is the base tag; when the adapter lands, the merge recipe is unchanged, and the interesting measurement will be the same one as last time: whether the adapter cuts turns, not tokens per second. ## Reproduce ```bash python3 bench_ollama.py --url http://127.0.0.1:11434 \ --models qwen4:35b-a3b-nvfp4 qwen3.8:27b-nvfp4 qwen3.8-pi:27b-nvfp4 \ --runs 3 --decode-tokens 256 --prefill-lengths 2000 8000 ```