[PR #78] [MERGED] GLM VRAM tier: STRATA_GLM_VRAM_EVICT=lru - refill a layer's spares by evicting its least recently used expert (opt-in) #318

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

📋 Pull Request Information

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

Base: main ← Head: pr-vram-lru


📝 Commits (1)

  • 3791f7e GLM VRAM tier: STRATA_GLM_VRAM_EVICT=lru - the spare refill evicts the least recently used resident instead of the least-used by the aged counts (opt-in)

📊 Changes

2 files changed (+10 additions, -2 deletions)

View changed files

📝 README.md (+1 -0)
📝 src/core/glm_fast_path.cu (+9 -2)

📄 Description

What

fast_boundary refills each layer's spares by evicting the layer's least-used resident by the aged counts (recency
breaks ties). With STRATA_GLM_VRAM_EVICT=lru it evicts the least recently used resident instead. One switch, read
once; the default path is untouched. README row added.

Why

The aged counts halve every 4096 routes, so a resident that was frequent a while ago outlives one that is in use now;
a freshly promoted expert (cold, or it would not have been in RAM) has a low count and is often the next one evicted.
How much that matters depends on how many misses are promoted - i.e. fetched over PCIe rather than computed by the
CPU lane.

Measured on Ryzen 9 5900X + 128 GB DDR4, RTX 3090 + 3060 (both x8), v1.0.30 with this patch, warm 21K API test
(fresh 21K prompt, then 2,500 tokens at 21K depth); the test's prompts gave identical answers run to run, so the
baseline's tier numbers repeated exactly:

VRAM hits (2,500-token answer) decode @21K 2nd 300-token reply
Maya-L, RAM_GB=96 (+ NVMe tier), calibrated plan, default eviction 54.5 % (twice) 11.45 tok/s 13.4 tok/s
the same, STRATA_GLM_VRAM_EVICT=lru 55.9 % 11.75 tok/s 14.2 tok/s
Maya-M, RAM_RESIDENT=1, CPU_PLAN=012234567 (at most one PCIe fetch a route), default 64.6 % 19.75 tok/s
the same, lru 64.5 % 19.63 tok/s

So: +2.6 % decode where the plan promotes (Maya-L's calibrated plan here), no change where it hardly does. Route
traces replayed through a model of these rules (details and the bounds in a separate issue) agree: LRU gains most on
the half with the smaller pool and with plans that fetch more over PCIe.

Checks run on this branch: builds (sm_75, sm_86); glm_dsa_parity, glm_ffn_parity, glm_hc_parity,
glm_kda_parity, glm_layer_parity --selftest: all PASS; python -m unittest serve.test_server serve.test_tools serve.test_mcp serve.test_detok: OK; the 21K API test above with the switch on and off on the real model.


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


🔄 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/78 **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-vram-lru` --- ### 📝 Commits (1) - [`3791f7e`](https://github.com/mw00/project-maya/commit/3791f7e7fb2754fd7d2e09d9c48e704591e13e34) GLM VRAM tier: STRATA_GLM_VRAM_EVICT=lru - the spare refill evicts the least recently used resident instead of the least-used by the aged counts (opt-in) ### 📊 Changes **2 files changed** (+10 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+1 -0) 📝 `src/core/glm_fast_path.cu` (+9 -2) </details> ### 📄 Description ## What `fast_boundary` refills each layer's spares by evicting the layer's least-used resident by the aged counts (recency breaks ties). With `STRATA_GLM_VRAM_EVICT=lru` it evicts the least recently used resident instead. One switch, read once; the default path is untouched. README row added. ## Why The aged counts halve every 4096 routes, so a resident that was frequent a while ago outlives one that is in use now; a freshly promoted expert (cold, or it would not have been in RAM) has a low count and is often the next one evicted. How much that matters depends on how many misses are promoted - i.e. fetched over PCIe rather than computed by the CPU lane. Measured on Ryzen 9 5900X + 128 GB DDR4, RTX 3090 + 3060 (both x8), v1.0.30 with this patch, warm 21K API test (fresh 21K prompt, then 2,500 tokens at 21K depth); the test's prompts gave identical answers run to run, so the baseline's tier numbers repeated exactly: | | VRAM hits (2,500-token answer) | decode @21K | 2nd 300-token reply | |---|---:|---:|---:| | Maya-L, `RAM_GB=96` (+ NVMe tier), calibrated plan, default eviction | 54.5 % (twice) | 11.45 tok/s | 13.4 tok/s | | the same, `STRATA_GLM_VRAM_EVICT=lru` | **55.9 %** | **11.75 tok/s** | **14.2 tok/s** | | Maya-M, `RAM_RESIDENT=1`, `CPU_PLAN=012234567` (at most one PCIe fetch a route), default | 64.6 % | 19.75 tok/s | | | the same, `lru` | 64.5 % | 19.63 tok/s | | So: +2.6 % decode where the plan promotes (Maya-L's calibrated plan here), no change where it hardly does. Route traces replayed through a model of these rules (details and the bounds in a separate issue) agree: LRU gains most on the half with the smaller pool and with plans that fetch more over PCIe. **Checks run on this branch:** builds (sm_75, sm_86); `glm_dsa_parity`, `glm_ffn_parity`, `glm_hc_parity`, `glm_kda_parity`, `glm_layer_parity` `--selftest`: all PASS; `python -m unittest serve.test_server serve.test_tools serve.test_mcp serve.test_detok`: OK; the 21K API test above with the switch on and off on the real model. --- *The code, the measurements and this description were produced with the help of Claude, an AI assistant by Anthropic.* --- <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:09 +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#318
No description provided.