[PR #91] [MERGED] tools/glm_tier_replay.py: replay STRATA_GLM_ROUTE_LOG traces through a model of the GLM VRAM expert tier (the engine's rules and alternatives), with tests #329

Closed
opened 2026-10-29 21:24:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/91
Author: @sociolog
Created: 10/10/2026
Status: ✅ Merged
Merged: 10/10/2026
Merged by: @mw00

Base: main ← Head: pr-tier-replay


📝 Commits (1)

  • 5ab8992 tools/glm_tier_replay.py: replay STRATA_GLM_ROUTE_LOG traces through a model of the GLM VRAM expert tier (the engine's rules and alternatives), with tests

📊 Changes

2 files changed (+384 additions, -0 deletions)

View changed files

➕ tools/glm_tier_replay.py (+289 -0)
➕ tools/test_glm_tier_replay.py (+95 -0)

📄 Description

What

As offered on #79: the replay behind that study, cleaned up as a tool - tools/glm_tier_replay.py and its tests.

It models the fast path's VRAM tier as the engine runs it - per-layer residents + 3 spares seeded from the pack's
expert_usage.txt, aged counts halved every 4096 routes, the CPU lane's plan taking the coldest misses, PCIe fetches
promoted into free spares, the token-boundary refill evicting the lowest aged count, the draft's MTP_KEEP - and
replays a route log through it with the engine's policy or an alternative (LRU, segmented LRU, protect-recent, reuse
distance, near-miss-weighted counts, near-miss recency), with Belady (hindsight) as the ceiling. "live" is the hit
rate the trace's own masks show, so a replay validates itself: on a Maya-M trace (RTX 3090 + 3060, split 30, 76 / 51
slots a layer, plan 012234567) the engine's policy gives 65.1 / 60.2 % against the live 65.4 / 61.5 %.

The docstring says how to record a trace (STRATA_GLM_ROUTE_LOG=<prefix>, the usage file of the run, the slot counts
and the plan from the engine's log) and what the model leaves out: time is a per-route max of CPU-lane and PCIe counts
with no overlap between layers or devices and no prompt reads; the RAM tier and the disk are one level; the
prefetch's copies are not modelled (trace with STRATA_GLM_PREFETCH_N unset to validate).

It reads route lines with or without the near-miss columns of #90. tools/glm_cache_sim.py stays as it is: the
design-phase LFU-pool simulator over its own trace format.

Checks

  • tools/test_glm_tier_replay.py, 7 tests (parsing with and without near misses, token counting, the most-used
    experts staying resident, the plan sending misses to the CPU lane, spares under LRU against the engine's rule, the
    draft layer outside the hit rate, the command line): python -m unittest discover -s tools -p test_glm_tier_replay.py OK;
  • the same numbers as the script behind #79 on the same trace, for all 11 policies compared there;
  • a fresh trace with #90's near misses replays (32,373 + 17,985 routes);
  • two new files only; merges cleanly with every open PR.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mw00/project-maya/pull/91 **Author:** [@sociolog](https://github.com/sociolog) **Created:** 10/10/2026 **Status:** ✅ Merged **Merged:** 10/10/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `pr-tier-replay` --- ### 📝 Commits (1) - [`5ab8992`](https://github.com/mw00/project-maya/commit/5ab8992740f126f5df72af7567067d2ff40d52bb) tools/glm_tier_replay.py: replay STRATA_GLM_ROUTE_LOG traces through a model of the GLM VRAM expert tier (the engine's rules and alternatives), with tests ### 📊 Changes **2 files changed** (+384 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `tools/glm_tier_replay.py` (+289 -0) ➕ `tools/test_glm_tier_replay.py` (+95 -0) </details> ### 📄 Description ## What As offered on #79: the replay behind that study, cleaned up as a tool - `tools/glm_tier_replay.py` and its tests. It models the fast path's VRAM tier as the engine runs it - per-layer residents + 3 spares seeded from the pack's `expert_usage.txt`, aged counts halved every 4096 routes, the CPU lane's plan taking the coldest misses, PCIe fetches promoted into free spares, the token-boundary refill evicting the lowest aged count, the draft's `MTP_KEEP` - and replays a route log through it with the engine's policy or an alternative (LRU, segmented LRU, protect-recent, reuse distance, near-miss-weighted counts, near-miss recency), with Belady (hindsight) as the ceiling. "live" is the hit rate the trace's own masks show, so a replay validates itself: on a Maya-M trace (RTX 3090 + 3060, split 30, 76 / 51 slots a layer, plan `012234567`) the engine's policy gives 65.1 / 60.2 % against the live 65.4 / 61.5 %. The docstring says how to record a trace (`STRATA_GLM_ROUTE_LOG=<prefix>`, the usage file of the run, the slot counts and the plan from the engine's log) and what the model leaves out: time is a per-route max of CPU-lane and PCIe counts with no overlap between layers or devices and no prompt reads; the RAM tier and the disk are one level; the prefetch's copies are not modelled (trace with `STRATA_GLM_PREFETCH_N` unset to validate). It reads route lines with or without the near-miss columns of #90. `tools/glm_cache_sim.py` stays as it is: the design-phase LFU-pool simulator over its own trace format. ## Checks - `tools/test_glm_tier_replay.py`, 7 tests (parsing with and without near misses, token counting, the most-used experts staying resident, the plan sending misses to the CPU lane, spares under LRU against the engine's rule, the draft layer outside the hit rate, the command line): `python -m unittest discover -s tools -p test_glm_tier_replay.py` OK; - the same numbers as the script behind #79 on the same trace, for all 11 policies compared there; - a fresh trace with #90's near misses replays (32,373 + 17,985 routes); - two new files only; merges cleanly with every open PR. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:24:16 +07:00
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#329
No description provided.