A 90% Cache Hit Rate Stalls 57% of Layers
Paging experts from SSD for a mixture-of-experts model sounds fine at a 90% hit rate. But a layer needs eight experts, and it stalls if any one misses: 1 - 0.9^8 = 57%. Measured per-pick hit rates on a real 35B model were 97-99%, which is the number that matters, and a synthetic skew model was 20 points too pessimistic.
Summary
When a mixture-of-experts model does not fit in memory, you keep a pool of hot experts on the GPU and read the rest from SSD. Cache hit rate is the number everyone quotes. For top-8 routing it is the wrong number to stop at: a layer cannot proceed until all eight of its experts are present, so one miss stalls the whole layer.
The arithmetic
With per-pick hit rate h, a layer stalls with probability 1 - h^8. A 40-layer model has 40 chances per token.
| per-pick hit rate | layers that stall | stalled layers per token (of 40) |
|---|---|---|
| 0.80 | 83% | 33 |
| 0.90 | 57% | 23 |
| 0.95 | 34% | 13 |
| 0.98 | 15% | 6 |
| 0.99 | 8% | 3 |
Each stall costs a submit and a read-back plus the SSD read. We first priced the read-back at about 0.9 ms, which would make paging pay only above roughly a 0.98 per-pick hit rate; see the correction below, which lowers that cost.
Synthetic skew was too pessimistic; measurement was not
Before measuring, we modelled routing as a Zipf distribution over 256 experts with a static resident set. At 68% residency that predicted 68% (flat) to 84% (moderately skewed) hits and needed strong skew for 90%. Our native Metal engine had already traced a real run of the 35B model: with a global least-recently-used pool at 64% residency, the warm miss rate was 1.2-2.6% (per-pick hit 97.4-98.8%), and at 80% residency about 2.6 misses per 320 picks. Real routing is temporally sticky, which a static distribution cannot capture.
Gotchas
Cold start looks terrible. The same pool measured 63% hit at 64 tokens, 86% at 256 and 91% at 512. A cache measurement means nothing until the run is several times the pool size.
Prefetch had nothing to predict. In the trace, none of the misses recurred within 32 passes and 70% recurred after more than 256; the previous pass named none of them. Residency, not prefetch, was the lever.
One shared pool beat per-layer pools at the same bytes (27% fewer expert copies at 512 tokens), because routing is not uniform across layers.
The sync, not the disk, was the bill. 43 command buffers per pass against 1 resident: 100 ms of CPU inside a 142 ms pass.
Key takeaways
- For top-k routing, compute 1 - h^k before accepting a hit rate.
- Measure on real traces, long enough to pass the cold start, instead of modelling skew.
- Spend effort on residency (smaller experts, a better pool) before prediction.
- Count the synchronisation points; they cost more than the reads.
Correction (2026-10-17, same day)
The 0.9 ms figure was an earlier measurement of one synchronised token against a pipelined one, and we wrongly applied it to every layer. Measured directly on a 16 GB laptop in Chrome, a submit plus a 4-byte read-back after each of 40 tiny layers costs 0.235 ms per layer (9.4 ms per token, p99 11.2 ms), against 0.3 ms for a single read-back at the end of the token. A stalled layer therefore costs well under a millisecond plus its disk reads, and at a 64% pool the roughly 6 stalled layers per token cost about 1.5 ms of waiting. The 0.98 threshold above was derived with the wrong cost and is too strict; a 0.95-0.98 hit rate can be acceptable. The 1 - h^8 arithmetic is unchanged.
Second correction (2026-10-17, later)
The correction above priced only the read-back. Running the whole loop with real routing replayed from the traces, the larger cost is fetching the missing experts: about 1.4-1.9 ms per stalled layer through the browser's fetch plus a GPU upload (the missing experts of one layer load in parallel, so the cost follows stalled layers, not experts). At a 64% pool and clinical English, 3.3% of picks missed and fetching added about 16 ms per token on top of a floor of about 18 ms for the compute and the per-layer round trips; at a 75% pool the fetch cost fell to about 6 ms. So a hit rate of 0.95-0.98 is workable but not free: the 64% pool cost roughly 35 ms a token against 26 ms at 75%. The 1 - h^8 arithmetic stands.
Follow @robotnurseio on X for the short version.
Everything in these notes I also do for hire: local AI set up on hardware you own, configured on-site, then handed over with enough documentation that you do not need me afterward. If that sounds more useful than another weekend of reading forum threads, the details are at /work. No obligation from an email, and the posts stay free either way.