[GH-ISSUE #79] Expert-cache study on a RAM-bound DDR4 box: replayed route traces - past-only eviction rules saturate, perfect hindsight would cut off-card time ~20 %, near misses do not predict #29

Closed
opened 2026-10-29 21:19:23 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @sociolog on GitHub (Oct 10, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/79

Notes from a weekend of trying to raise the VRAM hit rate on a RAM-bound box (Ryzen 9 5900X, 128 GB DDR4-3200, RTX
3090 + 3060 at x8), in case they save someone the same dead ends. Everything below is Maya-M, split 30
(76 / 51 slots a layer), RAM_RESIDENT=1, CPU_PLAN=012234567, v1.0.30.

Method

STRATA_GLM_ROUTE_LOG traces of a warm 21K API test (~3,100 generated tokens, ~159K routes), replayed through a model
of the tier rules: per layer n - 3 residents + kSpares 3; the route kernel's split of a route's RAM-tier misses (the
CPU lane takes plan[f] of them, the coldest by dcnt; the rest are fetched and land in spares - the only way into
VRAM); counts aged every 4096 routes; spares refilled at each token boundary. Validated against the live tier bits in
the same trace: 65.0 % vs live 65.4 % (3090 half), 60.1 % vs 61.5 % (3060 half). Cost proxy per layer:
max(CPU-lane experts x 0.31 ms, PCIe fetches x 0.66 ms) - the calibration's numbers.

Results (VRAM hits on the 3090 / 3060 half; off-card ms a token of the slower half)

eviction at the spare refill 3090 3060 off-card
the engine (least aged count, recency breaks ties) 65.0 % 60.1 % 19.3 ms
LRU 64.7 % 62.0 % 19.5 ms
segmented LRU (probation / protected, 60-90 % protected) 64.7-65.0 % 62.0-62.5 % 19.3-19.5 ms
least aged count among the not re-used since promotion 64.7-64.9 % 59.6-59.9 % 19.3-19.4 ms
reuse-interval prediction (EWMA of each expert's gaps) 58-60 % 53-56 % 22+ ms
"near misses" (ranks 9..24 of the route) as soft counts (0.1 / 0.3 / 0.6 a hit) worse with weight 19.1 / 19.6 / 20.3 ms
near misses as recency about LRU 19.3-19.4 ms
Belady (perfect hindsight), same promotion rules 72.8 % 70.3 % 15.3 ms
LRU + copying CPU-lane misses into spares too (~72 extra copies a token) 66.6 % 64.1 % 18.6 ms
Belady + copying everything 82.7 % 80.3 % 10.0 ms
  • Past-only rules saturate: every practical rule lands within ~2 % of the engine's; the 8-10 points to Belady need
    a predictor of the next tokens' routes. The route's next-ranked experts (near misses) are not one - giving them
    weight makes it worse.
  • The plan decides how much eviction can matter: with 012234567 only ~14 of ~76 off-card experts a token (3090
    half) are fetched (and can be promoted); the rest go to the CPU lane. Live, lru was +2.6 % on Maya-L with the
    calibrated plan and +0 % on Maya-M with 012234567 (#78).
  • The CPU lane is near the RAM limit, not the kernel's: ggml's one-token IQ2_S dot (the lane's path) does 5.7 GB/s
    on one thread whether the expert is in L3 or DRAM (compute-bound), but six threads reach 29.9 GB/s, twelve threads on
    twelve cores only 32.3, all 24 threads 37.3 - this box's practical read rate for that pattern. A faster kernel would
    buy little here; more RAM bandwidth (or fewer bytes a token) is what moves decode.

If useful I can PR the near-miss extension of the route log (| n0 .. n15 after the tier masks, only with
STRATA_GLM_ROUTE_LOG) and the trace simulator (Python, one file) as a tool for this kind of study.


The study, the measurements and this report were produced with the help of Claude, an AI assistant by Anthropic.

Originally created by @sociolog on GitHub (Oct 10, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/79 Notes from a weekend of trying to raise the VRAM hit rate on a RAM-bound box (Ryzen 9 5900X, 128 GB DDR4-3200, RTX 3090 + 3060 at x8), in case they save someone the same dead ends. Everything below is Maya-M, split 30 (76 / 51 slots a layer), `RAM_RESIDENT=1`, `CPU_PLAN=012234567`, v1.0.30. ## Method `STRATA_GLM_ROUTE_LOG` traces of a warm 21K API test (~3,100 generated tokens, ~159K routes), replayed through a model of the tier rules: per layer `n - 3` residents + `kSpares` 3; the route kernel's split of a route's RAM-tier misses (the CPU lane takes `plan[f]` of them, the coldest by `dcnt`; the rest are fetched and land in spares - the only way into VRAM); counts aged every 4096 routes; spares refilled at each token boundary. Validated against the live tier bits in the same trace: 65.0 % vs live 65.4 % (3090 half), 60.1 % vs 61.5 % (3060 half). Cost proxy per layer: max(CPU-lane experts x 0.31 ms, PCIe fetches x 0.66 ms) - the calibration's numbers. ## Results (VRAM hits on the 3090 / 3060 half; off-card ms a token of the slower half) | eviction at the spare refill | 3090 | 3060 | off-card | |---|---:|---:|---:| | the engine (least aged count, recency breaks ties) | 65.0 % | 60.1 % | 19.3 ms | | LRU | 64.7 % | 62.0 % | 19.5 ms | | segmented LRU (probation / protected, 60-90 % protected) | 64.7-65.0 % | 62.0-62.5 % | 19.3-19.5 ms | | least aged count among the not re-used since promotion | 64.7-64.9 % | 59.6-59.9 % | 19.3-19.4 ms | | reuse-interval prediction (EWMA of each expert's gaps) | 58-60 % | 53-56 % | 22+ ms | | "near misses" (ranks 9..24 of the route) as soft counts (0.1 / 0.3 / 0.6 a hit) | worse with weight | | 19.1 / 19.6 / 20.3 ms | | near misses as recency | about LRU | | 19.3-19.4 ms | | **Belady (perfect hindsight), same promotion rules** | **72.8 %** | **70.3 %** | **15.3 ms** | | LRU + copying CPU-lane misses into spares too (~72 extra copies a token) | 66.6 % | 64.1 % | 18.6 ms | | Belady + copying everything | 82.7 % | 80.3 % | 10.0 ms | - **Past-only rules saturate**: every practical rule lands within ~2 % of the engine's; the 8-10 points to Belady need a predictor of the next tokens' routes. The route's next-ranked experts (near misses) are not one - giving them weight makes it worse. - **The plan decides how much eviction can matter**: with `012234567` only ~14 of ~76 off-card experts a token (3090 half) are fetched (and can be promoted); the rest go to the CPU lane. Live, `lru` was +2.6 % on Maya-L with the calibrated plan and +0 % on Maya-M with `012234567` (#78). - **The CPU lane is near the RAM limit, not the kernel's**: ggml's one-token IQ2_S dot (the lane's path) does 5.7 GB/s on one thread whether the expert is in L3 or DRAM (compute-bound), but six threads reach 29.9 GB/s, twelve threads on twelve cores only 32.3, all 24 threads 37.3 - this box's practical read rate for that pattern. A faster kernel would buy little here; more RAM bandwidth (or fewer bytes a token) is what moves decode. If useful I can PR the near-miss extension of the route log (`| n0 .. n15` after the tier masks, only with `STRATA_GLM_ROUTE_LOG`) and the trace simulator (Python, one file) as a tool for this kind of study. --- *The study, the measurements and this report were produced with the help of Claude, an AI assistant by Anthropic.*
Author
Owner

@mw00 commented on GitHub (Oct 10, 2026):

Thank you, this maps the ceiling clearly.

  • Practical eviction rules all land within ~2% of each other, and hindsight would add 8-10 points. So the next gain needs a predictor of the next tokens' routes, not a better eviction rule.
  • The plan sets how much eviction matters. It only touches the experts that are fetched; the CPU lane's never enter VRAM.

Both PRs would be welcome:

  • The trace simulator in tools/, with a short note in its docstring on how to make a trace and what the model of the tier rules leaves out.
  • The near-miss columns in the route log, as long as they are written only with STRATA_GLM_ROUTE_LOG and the decode path is unchanged without it.

#78 (your LRU option) is in review.

<!-- gh-comment-id:6096930287 --> @mw00 commented on GitHub (Oct 10, 2026): Thank you, this maps the ceiling clearly. - **Practical eviction rules all land within ~2% of each other, and hindsight would add 8-10 points.** So the next gain needs a predictor of the next tokens' routes, not a better eviction rule. - **The plan sets how much eviction matters.** It only touches the experts that are fetched; the CPU lane's never enter VRAM. Both PRs would be welcome: - **The trace simulator** in `tools/`, with a short note in its docstring on how to make a trace and what the model of the tier rules leaves out. - **The near-miss columns in the route log,** as long as they are written only with `STRATA_GLM_ROUTE_LOG` and the decode path is unchanged without it. #78 (your LRU option) is in review.
Author
Owner

@mw00 commented on GitHub (Oct 12, 2026):

Closing this study as noted: the next gain is in predicting the next tokens' routes, not in a better eviction rule. The trace simulator and the near-miss columns are still welcome as PRs any time.

<!-- gh-comment-id:6125944331 --> @mw00 commented on GitHub (Oct 12, 2026): Closing this study as noted: the next gain is in predicting the next tokens' routes, not in a better eviction rule. The trace simulator and the near-miss columns are still welcome as PRs any time.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#29
No description provided.