[PR #352] [MERGED] GLM: a prompt's lending keeps the more recently used experts in RAM - 40% fewer disk reads after a fresh prompt #481

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/352
Author: @merbanan
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @mw00

Base: main ← Head: pr/lend-park-lru


📝 Commits (1)

  • 0397902 GLM: a prompt's lending keeps the more recently used experts in RAM - 40% fewer disk reads after a fresh prompt

📊 Changes

4 files changed (+44 additions, -15 deletions)

View changed files

📝 docs/SETTINGS.md (+1 -0)
📝 src/core/glm_fast_path.cu (+9 -6)
📝 src/core/glm_fast_state.hpp (+3 -2)
📝 src/core/glm_prefill.cu (+31 -7)

📄 Description

What

When a prompt borrows the expert pool's tail (lend_range, about 450–600 experts on Maya-S24 on one V100), each expert that leaves VRAM is moved into the RAM tier. It goes over a RAM expert whose LFU count is strictly lower. A tail expert is likewise relocated over a main-slot expert only when that expert's count is strictly lower.

The counts age: every 32,768 routing events halve them all. So most experts sit at the same small value, often 0. On a tie, the expert leaving VRAM went to disk, or the wrong RAM expert did. The answer that follows then reads it back from disk.

With this change, on equal counts the less recently used expert goes, and on equal recency the one with lower long-term usage goes. This applies both to the park and to the relocation. STRATA_GLM_LEND_PARK_LRU=0 (or MAYA_GLM_LEND_PARK_LRU=0) keeps the strict rule. Only where experts are placed changes, never which experts run. The new setting has a row in docs/SETTINGS.md.

STRATA_GLM_TIER_DIAG also gets a fifth disk-read cause, "lend-evicted": RAM experts the lending itself evicted. It now prints every STRATA_GLM_TIER_DIAG_EVERY boundaries (default 64). That is how the cause was found.

Measured

One Tesla V100-PCIE-32GB with a 7950X and 62 GB of RAM, GLM-5.3-Flash Maya-S24, STRATA_GLM_PREFILL_SUB=1024. Same build (main v1.1.20 + this PR), two rounds each, STRATA_GLM_LEND_PARK_LRU=0 vs the new default. Each run is one engine serving five requests in turn:

  • an 8K code prompt, fresh;
  • the same prompt again, cached;
  • a 24K code prompt, fresh;
  • the same prompt again, cached;
  • the 8K prompt again.

Each request decodes 512 greedy tokens. The disk-read counts come from STRATA_GLM_TIER_DIAG.

After the fresh 24K prompt (the second time the run lends):

strict this PR
disk reads over the 512 tokens 667 / 555 399 / 319
… of them RAM experts the lending evicted 499 / 431 273 / 215
decode tok/s 25.6 / 26.4 26.7 / 27.3
VRAM hit rate 66.6 / 68.0% 67.6 / 69.0%

The cached requests are unchanged.

On our development branch, with the same harness over four rounds: 520–578 → 309–337 disk reads, and decode 30.8–32.5 → 32.9–33.4 tok/s.

Not fixed: the first prompt after a load still sends about 420 of the ~455 lent experts to disk, with either rule. At that point the RAM tier's counts are above those of the experts leaving VRAM. That happens once per server start.

Builds: native (sm_70). tools/check_hip_compat.py passes; there are no new CUDA calls.


🔄 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/352 **Author:** [@merbanan](https://github.com/merbanan) **Created:** 10/21/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `pr/lend-park-lru` --- ### 📝 Commits (1) - [`0397902`](https://github.com/mw00/project-maya/commit/03979029bf308affa8f15a505916c0ae8c47fd88) GLM: a prompt's lending keeps the more recently used experts in RAM - 40% fewer disk reads after a fresh prompt ### 📊 Changes **4 files changed** (+44 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `docs/SETTINGS.md` (+1 -0) 📝 `src/core/glm_fast_path.cu` (+9 -6) 📝 `src/core/glm_fast_state.hpp` (+3 -2) 📝 `src/core/glm_prefill.cu` (+31 -7) </details> ### 📄 Description ## What When a prompt borrows the expert pool's tail (`lend_range`, about 450–600 experts on Maya-S24 on one V100), each expert that leaves VRAM is moved into the RAM tier. It goes over a RAM expert whose LFU count is strictly lower. A tail expert is likewise relocated over a main-slot expert only when that expert's count is strictly lower. The counts age: every 32,768 routing events halve them all. So most experts sit at the same small value, often 0. On a tie, the expert leaving VRAM went to disk, or the wrong RAM expert did. The answer that follows then reads it back from disk. With this change, on equal counts the less recently used expert goes, and on equal recency the one with lower long-term usage goes. This applies both to the park and to the relocation. `STRATA_GLM_LEND_PARK_LRU=0` (or `MAYA_GLM_LEND_PARK_LRU=0`) keeps the strict rule. Only where experts are placed changes, never which experts run. The new setting has a row in docs/SETTINGS.md. `STRATA_GLM_TIER_DIAG` also gets a fifth disk-read cause, "lend-evicted": RAM experts the lending itself evicted. It now prints every `STRATA_GLM_TIER_DIAG_EVERY` boundaries (default 64). That is how the cause was found. ## Measured One Tesla V100-PCIE-32GB with a 7950X and 62 GB of RAM, GLM-5.3-Flash Maya-S24, `STRATA_GLM_PREFILL_SUB=1024`. Same build (main v1.1.20 + this PR), two rounds each, `STRATA_GLM_LEND_PARK_LRU=0` vs the new default. Each run is one engine serving five requests in turn: - an 8K code prompt, fresh; - the same prompt again, cached; - a 24K code prompt, fresh; - the same prompt again, cached; - the 8K prompt again. Each request decodes 512 greedy tokens. The disk-read counts come from `STRATA_GLM_TIER_DIAG`. After the fresh 24K prompt (the second time the run lends): | | strict | this PR | |---|---|---| | disk reads over the 512 tokens | 667 / 555 | 399 / 319 | | … of them RAM experts the lending evicted | 499 / 431 | 273 / 215 | | decode tok/s | 25.6 / 26.4 | 26.7 / 27.3 | | VRAM hit rate | 66.6 / 68.0% | 67.6 / 69.0% | The cached requests are unchanged. On our development branch, with the same harness over four rounds: 520–578 → 309–337 disk reads, and decode 30.8–32.5 → 32.9–33.4 tok/s. **Not fixed:** the first prompt after a load still sends about 420 of the ~455 lent experts to disk, with either rule. At that point the RAM tier's counts are above those of the experts leaving VRAM. That happens once per server start. Builds: native (sm_70). `tools/check_hip_compat.py` passes; there are no new CUDA calls. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:25:54 +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#481
No description provided.