[PR #103] [MERGED] GLM trunk keep (opt-in, changes the answers): the model's own layers leave out their lowest-ranked off-card experts, as the draft block does - per layer (STRATA_GLM_TRUNK_KEEP / STRATA_GLM_TRUNK_KEEP_MAP) #339

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

📋 Pull Request Information

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

Base: main ← Head: pr-trunk-keep-v2


📝 Commits (2)

  • 039dbb5 GLM trunk keep (opt-in, changes the answers): STRATA_GLM_TRUNK_KEEP= / STRATA_GLM_TRUNK_KEEP_MAP= - the model's own routes leave their lowest-ranked off-card experts out, as the draft block does; README row
  • 8eb7bef README: the Maya-L row of STRATA_GLM_TRUNK_KEEP as its gain

📊 Changes

3 files changed (+25 additions, -3 deletions)

View changed files

📝 README.md (+1 -0)
📝 src/core/glm_fast_path.cu (+23 -2)
📝 src/kernels/cuda/glm_fast.cu (+1 -1)

📄 Description

What

The draft block already leaves out the experts it is missing from VRAM past STRATA_GLM_MTP_KEEP. This applies the
same rule to the model's own (trunk) layers, as a switch for RAM-bound splits that would rather be faster than exact:

  • STRATA_GLM_TRUNK_KEEP=<n> (1-8): a trunk route leaves its experts that are not in VRAM out from route rank n on
    (the plan entry is null, as for the draft). Experts in VRAM are always computed. Unset (8) = bit-identical to today.
  • STRATA_GLM_TRUNK_KEEP_MAP=<one digit per layer>: the same, layer by layer (digit i = layer i's n; 8 = all; layers
    past the string's end take STRATA_GLM_TRUNK_KEEP). The draft layer keeps MTP_KEEP whatever the map says.

Why it pays: the lowest-ranked experts carry the least weight and are the coldest, so they are the ones most often off
the card. Why per layer: GLM-5.3's layers differ by an order of magnitude in how much they notice.

How much each layer notices

STRATA_GLM_SCORE on 1,135 held-out tokens, KL to the same model with nothing left out, measured with the CPU lane off
(every expert on the GPU, so the rounding never changes and a repeat gives KL 0.000000). Keep 5 in one band of MoE
layers at a time:

layers at keep 5 Maya-M Maya-L
3-7 0.040 0.028
8-12 0.034 0.029
13-17 0.035 0.029
18-22 0.026 0.020
23-29 0.012 0.010
30-34 0.003 0.003
35-39 0.0015 0.0015
40-44 0.002 0.003

The last third hardly notices; the first two thirds do, on both quants.

Measured

Ryzen 9 5900X + 128 GB DDR4, RTX 3090 + 3060 (x8 each), this on v1.0.31 or v1.0.32 (rows marked 32) - the same
math: v1.0.32 loading the cards one after another gives v1.0.31's scores to the last digit; loading them at once
gives the 3060 one more expert slot per layer, +2 % decode. Speed: warm 21K API test (a fresh 21K prompt, then 2,500
tokens at 21K depth), two runs each, default sampling. Quality: as above.

Maya-M (RAM_RESIDENT=1, CPU_PLAN=012234567, prefetch on), against 20.0 tok/s with nothing left out:

KL to Maya-M same top token decode @21K
uniform keep 7 0.032 93.7 % 21.8
uniform keep 6 0.053 91.2 % 24.6
map: 5 on 23-44 0.015 96.5 % 22.7
map: 5 on 23-29, 4 on 30-44, split 28 (32) 0.018 95.3 % 24.6 (31: 24.1)

Once the 3060's half is light, the 3090's paces the pipelined decode; moving two layers to the 3060 (split 28) is
where the last step comes from. Cutting deeper on 30-44 (keep 3) gave no more speed.

Maya-L (RAM_GB=96, 14 % of the experts on the SSD), against ~11.7 tok/s with nothing left out:

KL to Maya-L same top token decode @21K
the same map, its own split (29) (32) 0.017 95.8 % 14.05
the same map, split 27 (32) 0.0165 95.7 % 14.75 (five runs)
keep 4 on 23-44, split 27 (32) 0.020 95.5 % 15.4 (two runs)

On code (1,135 tokens of a Python file, same clean gate): Maya-M with the map 0.0165, Maya-L 0.0177 - the same as on
prose. For scale: Maya-M itself is KL 0.103 away from Maya-L on the prose, so the map moves each model by about a
sixth of the M-to-L gap.

Not included: leaving out only the SSD's experts

We also tried STRATA_GLM_TRUNK_KEEP_DISK=<n>: leave out only the experts that would come from the disk, from rank n
on. It acts in the sensitive early layers too: on Maya-L with the map, _DISK=4 raises the KL from 0.017 to 0.040
(code: 0.018 to 0.046; _DISK=7: 0.027) and on v1.0.32 did not decode faster (map + _DISK=4 at the auto split
14.8 tok/s, the map alone at split 27 14.75 - five runs each; Maya-L's runs scatter +-5 %). Left out of this PR.

With #76

#76's kernel (and #96's, which builds on it) takes skip_from < 8 to mean "a draft route" and then also leaves out
every expert that is only on disk, whatever its rank. With this PR a trunk route can have skip_from < 8 too, so
after both, a kept trunk layer on a split with an SSD tier would drop its disk-only experts at every rank - not what
either PR means. An explicit flag for the draft route in RouteArgs (or layer == the draft layer) keeps both rules
apart. Happy to rebase onto #76 and add that, whichever lands first. Textually this PR adds no conflict with #76.

Checks

On this branch (one commit on v1.0.33), RTX 3090 + 3060, built for sm_75/86:

  • the 5 GLM parity selftests (dsa, ffn, hc, kda, layer) pass;
  • unset = as before, by STRATA_GLM_SCORE on 1,135 held-out tokens: with the cards loaded one after another, Maya-M
    scores exactly as a stock build (NLL 1.30094, KL 0.018989 to the stock reference, the same 114,052 CPU-lane
    experts); with the CPU lane off, KL 0.000000 to the stock references on Maya-M and Maya-L;
  • TRUNK_KEEP_MAP as above gives the same scores as the build we measured it on (KL 0.017538 to the full Maya-M,
    cards loaded one after another).
  • Test-merged with the open PRs: #92, #98 and #101 clean; #76, #86, #88 and #96 already conflict with main, and this
    adds no conflict to theirs.

🤖 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/103 **Author:** [@sociolog](https://github.com/sociolog) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `pr-trunk-keep-v2` --- ### 📝 Commits (2) - [`039dbb5`](https://github.com/mw00/project-maya/commit/039dbb5f39292969b4fceac1dfb4e71ff5ac567b) GLM trunk keep (opt-in, changes the answers): STRATA_GLM_TRUNK_KEEP=<n> / STRATA_GLM_TRUNK_KEEP_MAP=<digit per layer> - the model's own routes leave their lowest-ranked off-card experts out, as the draft block does; README row - [`8eb7bef`](https://github.com/mw00/project-maya/commit/8eb7befad699ca0dca9184bb22107d988085f86f) README: the Maya-L row of STRATA_GLM_TRUNK_KEEP as its gain ### 📊 Changes **3 files changed** (+25 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+1 -0) 📝 `src/core/glm_fast_path.cu` (+23 -2) 📝 `src/kernels/cuda/glm_fast.cu` (+1 -1) </details> ### 📄 Description ## What The draft block already leaves out the experts it is missing from VRAM past `STRATA_GLM_MTP_KEEP`. This applies the same rule to the model's own (trunk) layers, as a switch for RAM-bound splits that would rather be faster than exact: - `STRATA_GLM_TRUNK_KEEP=<n>` (1-8): a trunk route leaves its experts that are not in VRAM out from route rank n on (the plan entry is null, as for the draft). Experts in VRAM are always computed. Unset (8) = bit-identical to today. - `STRATA_GLM_TRUNK_KEEP_MAP=<one digit per layer>`: the same, layer by layer (digit i = layer i's n; 8 = all; layers past the string's end take `STRATA_GLM_TRUNK_KEEP`). The draft layer keeps `MTP_KEEP` whatever the map says. Why it pays: the lowest-ranked experts carry the least weight and are the coldest, so they are the ones most often off the card. Why per layer: GLM-5.3's layers differ by an order of magnitude in how much they notice. ## How much each layer notices `STRATA_GLM_SCORE` on 1,135 held-out tokens, KL to the same model with nothing left out, measured with the CPU lane off (every expert on the GPU, so the rounding never changes and a repeat gives KL 0.000000). Keep 5 in one band of MoE layers at a time: | layers at keep 5 | Maya-M | Maya-L | |---|---|---| | 3-7 | 0.040 | 0.028 | | 8-12 | 0.034 | 0.029 | | 13-17 | 0.035 | 0.029 | | 18-22 | 0.026 | 0.020 | | 23-29 | 0.012 | 0.010 | | 30-34 | 0.003 | 0.003 | | 35-39 | 0.0015 | 0.0015 | | 40-44 | 0.002 | 0.003 | The last third hardly notices; the first two thirds do, on both quants. ## Measured Ryzen 9 5900X + 128 GB DDR4, RTX 3090 + 3060 (x8 each), this on v1.0.31 or v1.0.32 (rows marked 32) - the same math: v1.0.32 loading the cards one after another gives v1.0.31's scores to the last digit; loading them at once gives the 3060 one more expert slot per layer, +2 % decode. Speed: warm 21K API test (a fresh 21K prompt, then 2,500 tokens at 21K depth), two runs each, default sampling. Quality: as above. **Maya-M** (`RAM_RESIDENT=1`, `CPU_PLAN=012234567`, prefetch on), against 20.0 tok/s with nothing left out: | | KL to Maya-M | same top token | decode @21K | |---|---:|---:|---:| | uniform keep 7 | 0.032 | 93.7 % | 21.8 | | uniform keep 6 | 0.053 | 91.2 % | 24.6 | | map: 5 on 23-44 | 0.015 | 96.5 % | 22.7 | | **map: 5 on 23-29, 4 on 30-44, split 28** (32) | **0.018** | 95.3 % | **24.6** (31: 24.1) | Once the 3060's half is light, the 3090's paces the pipelined decode; moving two layers to the 3060 (split 28) is where the last step comes from. Cutting deeper on 30-44 (keep 3) gave no more speed. **Maya-L** (`RAM_GB=96`, 14 % of the experts on the SSD), against ~11.7 tok/s with nothing left out: | | KL to Maya-L | same top token | decode @21K | |---|---:|---:|---:| | the same map, its own split (29) (32) | 0.017 | 95.8 % | 14.05 | | **the same map, split 27** (32) | **0.0165** | 95.7 % | **14.75** (five runs) | | keep 4 on 23-44, split 27 (32) | 0.020 | 95.5 % | 15.4 (two runs) | On code (1,135 tokens of a Python file, same clean gate): Maya-M with the map 0.0165, Maya-L 0.0177 - the same as on prose. For scale: Maya-M itself is KL 0.103 away from Maya-L on the prose, so the map moves each model by about a sixth of the M-to-L gap. ## Not included: leaving out only the SSD's experts We also tried `STRATA_GLM_TRUNK_KEEP_DISK=<n>`: leave out only the experts that would come from the disk, from rank n on. It acts in the sensitive early layers too: on Maya-L with the map, `_DISK=4` raises the KL from 0.017 to 0.040 (code: 0.018 to 0.046; `_DISK=7`: 0.027) and on v1.0.32 did not decode faster (map + `_DISK=4` at the auto split 14.8 tok/s, the map alone at split 27 14.75 - five runs each; Maya-L's runs scatter +-5 %). Left out of this PR. ## With #76 #76's kernel (and #96's, which builds on it) takes `skip_from < 8` to mean "a draft route" and then also leaves out every expert that is only on disk, whatever its rank. With this PR a trunk route can have `skip_from < 8` too, so after both, a kept trunk layer on a split with an SSD tier would drop its disk-only experts at every rank - not what either PR means. An explicit flag for the draft route in `RouteArgs` (or `layer == the draft layer`) keeps both rules apart. Happy to rebase onto #76 and add that, whichever lands first. Textually this PR adds no conflict with #76. ## Checks On this branch (one commit on v1.0.33), RTX 3090 + 3060, built for sm_75/86: - the 5 GLM parity selftests (dsa, ffn, hc, kda, layer) pass; - unset = as before, by `STRATA_GLM_SCORE` on 1,135 held-out tokens: with the cards loaded one after another, Maya-M scores exactly as a stock build (NLL 1.30094, KL 0.018989 to the stock reference, the same 114,052 CPU-lane experts); with the CPU lane off, KL 0.000000 to the stock references on Maya-M and Maya-L; - `TRUNK_KEEP_MAP` as above gives the same scores as the build we measured it on (KL 0.017538 to the full Maya-M, cards loaded one after another). - Test-merged with the open PRs: #92, #98 and #101 clean; #76, #86, #88 and #96 already conflict with main, and this adds no conflict to theirs. --- 🤖 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:24 +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#339
No description provided.