[PR #389] [CLOSED] GLM expert tiers: the count memory, a prompt's weight in it, and the pool's tail spread across the layers, opt-in (MAYA_GLM_COUNT_HALF, MAYA_GLM_PROMPT_COUNTS, MAYA_GLM_LEND_SPREAD) #507

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/389
Author: @somnergy
Created: 10/22/2026
Status: ❌ Closed

Base: main ← Head: pr/glm-tier-policy


📝 Commits (3)

  • 210f71d GLM expert tiers: the aged counts' halving period and a prompt's weight in them, opt-in (MAYA_GLM_COUNT_HALF, MAYA_GLM_PROMPT_COUNTS)
  • 674584c GLM expert tiers: the pool's tail slot by slot across the layers, opt-in (MAYA_GLM_LEND_SPREAD)
  • 790a908 tools/glm_multi_replay.py: a scripted multi-conversation workload for A/B runs of tier and scheduler settings

📊 Changes

10 files changed (+929 additions, -29 deletions)

View changed files

📝 CMakeLists.txt (+3 -2)
📝 docs/SETTINGS.md (+3 -0)
📝 include/strata/core/glm_model.hpp (+2 -0)
➕ include/strata/core/tier_policy.hpp (+115 -0)
📝 src/core/glm_fast_path.cu (+41 -9)
📝 src/core/glm_fast_state.hpp (+9 -3)
📝 src/core/glm_prefill.cu (+11 -15)
➕ tests/core/tier_policy_test.cpp (+120 -0)
➕ tools/glm_multi_replay.py (+456 -0)
➕ tools/test_glm_multi_replay.py (+169 -0)

📄 Description

Summary

Where part of the experts live in RAM, the decode's VRAM tier evicts, refills and swaps by aged route counts. Three opt-in settings (each unset keeps today's rule), plus a benchmark to decide whether they are worth keeping:

  • MAYA_GLM_COUNT_HALF=<events>: the counts halve every 32768 count events, a few seconds of a batched decode; this sets the period (e.g. 432000, ~30 s).
  • MAYA_GLM_PROMPT_COUNTS=<w> (0-1): a prompt chunk adds T x 8 events a layer, so one read halves every count several times; this weights a prompt's routing in the counts.
  • MAYA_GLM_LEND_SPREAD=1: a read borrows the front of the pool's tail region, which, laid out layer by layer, is the whole tail of the first MoE layers; spread, a read takes a slot or two of every layer.
  • tools/glm_multi_replay.py: a reproducible multi-conversation workload for A/B runs (below).

The rules are pure functions in strata/core/tier_policy.hpp, CPU-tested.

Why

Measured under several concurrent Claude Code sessions (agentic coding: long multi-turn conversations, subagents, tool calls, auto-mode safety checks) through the Anthropic Messages API with --parallel 8, with Maya-L (~85% of experts in VRAM):

  • Waiting for RAM-tier experts was 78-82% of the extra time a decode step took against every expert in VRAM, so each point of VRAM hit matters.
  • Prompt reads come every ~10 s; on the live route log the first GPU's layers 3-7 decayed from ~97.4% to ~94.7% VRAM hit within 15-18 minutes while later layers held steady.
  • After a restart, with every client's conversation read cold (116-148K tokens each), the VRAM hit took ~10 minutes to climb from 87% to 96%.

Measured

Hardware: 2x NVIDIA RTX PRO 5000 Blackwell 72 GB, each on PCIe 5.0 x8 from its own CPU root port (no fast P2P); Intel Core Ultra 9 285K (8 P + 16 E cores, no AVX-512), the engine on all 24 cores; 96 GB DDR5; driver 615.71.09, CUDA 13.4. Model: Maya-L (IQ3_S / IQ4_XS experts), ~85% of the experts in VRAM, the rest pinned in RAM, CPU lane on; 8 conversations at most.

Two live A/B pairs, back to back, 35-45 minutes each after a 12-minute warm-up. t1 = off; t2 = LEND_SPREAD=1, COUNT_HALF=432000, PROMPT_COUNTS=0.1:

pair 1: t1 pair 1: t2 pair 2: t1 pair 2: t2
CPU-lane split of a two-miss route (first GPU, picked at start) 1 CPU + 1 PCIe 1 + 1 1 + 1 2 CPU
running (mean) 8.0 7.9 7.9 7.1
VRAM hit (engine's window) 97.2% 97.5% 96.6% 97.8%
VRAM hit per request (decode, median) 96.8% 97.2% 96.7% 97.7%
RAM-tier experts over PCIe a token 1.16 1.09 1.55 0.33
decode per request, 64-128K context 17.2 tok/s 17.6 14.4 (8 requests) 20.2
decode per request, 128-160K context 16.9 tok/s 15.9 15.5 too few

The VRAM hit rose in both pairs (+0.3 and +1.1 points). Decode did not show a clear gain: pair 1 (same CPU-lane split) moved -6% to +2% by context; pair 2's larger numbers came with a different CPU-lane split picked at start (which alone cuts PCIe fetches: a t1 start with that split fetched 0.36 a token) and lighter contexts. A replay of 26 minutes of live routes put the longer count memory as the best eviction-side rule (+0.2 points); the replay does not model the early-layer decay LEND_SPREAD aims at, and no route log was taken with t2.

The benchmark that should decide

tools/glm_multi_replay.py run replays a fixed workload against a running server, fixed by --seed: 8 conversations sharing 30K / 8K / 4K-token system prompts; turns that append mostly short new text (95% under 8K tokens, a few up to 64K) with 2-20 s think times; 40 short checks an hour on one 30K system prompt; two cold bursts where half the clients start over; compaction past --max-context. The history is scripted (the model's answers are not fed back) and requests are greedy with the end tokens banned, so every run sends the same prompts and writes the same tokens. It records each request's read and decode times and VRAM hit (/metrics?requests=all), the tiers every 10 s, and, with --route-log, the VRAM hit of layer bands over the run. compare prints mean +- sd per configuration and marks differences beyond twice their standard error.

Protocol: experts partly in RAM; the same config but the settings; the CPU-lane split pinned (MAYA_GLM_CPU_PLAN); a fresh engine and empty slot folder per run; configurations alternated, 3 runs each, 30 minutes per run. The settings stay only if VRAM hit and decode per request improve beyond the run-to-run spread. Not run yet.

Recommendation

For now: with experts partly in RAM and several conversations, the three settings together raised the VRAM hit by 0.3-1.1 points without a decode gain shown; leave them off by default until the benchmark above shows a real one. With every expert in VRAM there are no misses to save; streamed from RAM and one GPU were not measured.

Exactness

Not bitwise against the settings off: they change which experts sit in VRAM at a given moment, and with it which ones the CPU lane computes (another rounding) and the order a prompt chunk sums expert outputs in - the same kind of difference as between any two runs, since the tiers depend on timing. With the CPU lane off, decode arithmetic does not depend on where an expert sits.

How it was verified

  • tests/core/tier_policy_test.cpp (CPU): the parse and ranges; the defaults match the old halving loops; the weighted prompt counts; both tail layouts tile the region exactly, and a spread loan is even across the layers.
  • tools/test_glm_multi_replay.py (no GPU, part of the CI's tools tests): the workload's determinism, the texts and requests, the summary's bins, the route-log bands, the comparison, and a short run against a fake server.
  • On v1.1.23 (this branch): builds (nvcc 13.4, sm_75 and sm_120); tier_policy_test passes on the box above; tools/check_hip_compat.py is clean.
  • The live pairs: these settings on v1.1.21, ~2 h with t2, 0 engine errors. Not run on a GPU on v1.1.22+, where upstream changed the lending's victim choice next to LEND_SPREAD's code (by reading, the two are independent).

🔄 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/389 **Author:** [@somnergy](https://github.com/somnergy) **Created:** 10/22/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/glm-tier-policy` --- ### 📝 Commits (3) - [`210f71d`](https://github.com/mw00/project-maya/commit/210f71d0d81ab24c0d63c1a483947380258f172d) GLM expert tiers: the aged counts' halving period and a prompt's weight in them, opt-in (MAYA_GLM_COUNT_HALF, MAYA_GLM_PROMPT_COUNTS) - [`674584c`](https://github.com/mw00/project-maya/commit/674584c72c17f5797f96d78186aaf0a008bc4ede) GLM expert tiers: the pool's tail slot by slot across the layers, opt-in (MAYA_GLM_LEND_SPREAD) - [`790a908`](https://github.com/mw00/project-maya/commit/790a9085f52d976328d1f8ccbf344a4286f71951) tools/glm_multi_replay.py: a scripted multi-conversation workload for A/B runs of tier and scheduler settings ### 📊 Changes **10 files changed** (+929 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+3 -2) 📝 `docs/SETTINGS.md` (+3 -0) 📝 `include/strata/core/glm_model.hpp` (+2 -0) ➕ `include/strata/core/tier_policy.hpp` (+115 -0) 📝 `src/core/glm_fast_path.cu` (+41 -9) 📝 `src/core/glm_fast_state.hpp` (+9 -3) 📝 `src/core/glm_prefill.cu` (+11 -15) ➕ `tests/core/tier_policy_test.cpp` (+120 -0) ➕ `tools/glm_multi_replay.py` (+456 -0) ➕ `tools/test_glm_multi_replay.py` (+169 -0) </details> ### 📄 Description ## Summary Where part of the experts live in RAM, the decode's VRAM tier evicts, refills and swaps by aged route counts. Three opt-in settings (each unset keeps today's rule), plus a benchmark to decide whether they are worth keeping: - **`MAYA_GLM_COUNT_HALF=<events>`**: the counts halve every 32768 count events, a few seconds of a batched decode; this sets the period (e.g. `432000`, ~30 s). - **`MAYA_GLM_PROMPT_COUNTS=<w>`** (0-1): a prompt chunk adds T x 8 events a layer, so one read halves every count several times; this weights a prompt's routing in the counts. - **`MAYA_GLM_LEND_SPREAD=1`**: a read borrows the front of the pool's tail region, which, laid out layer by layer, is the whole tail of the first MoE layers; spread, a read takes a slot or two of every layer. - **`tools/glm_multi_replay.py`**: a reproducible multi-conversation workload for A/B runs (below). The rules are pure functions in `strata/core/tier_policy.hpp`, CPU-tested. ## Why Measured under several concurrent Claude Code sessions (agentic coding: long multi-turn conversations, subagents, tool calls, auto-mode safety checks) through the Anthropic Messages API with `--parallel 8`, with Maya-L (~85% of experts in VRAM): - Waiting for RAM-tier experts was 78-82% of the extra time a decode step took against every expert in VRAM, so each point of VRAM hit matters. - Prompt reads come every ~10 s; on the live route log the first GPU's layers 3-7 decayed from ~97.4% to ~94.7% VRAM hit within 15-18 minutes while later layers held steady. - After a restart, with every client's conversation read cold (116-148K tokens each), the VRAM hit took ~10 minutes to climb from 87% to 96%. ## Measured Hardware: 2x NVIDIA RTX PRO 5000 Blackwell 72 GB, each on PCIe 5.0 x8 from its own CPU root port (no fast P2P); Intel Core Ultra 9 285K (8 P + 16 E cores, no AVX-512), the engine on all 24 cores; 96 GB DDR5; driver 615.71.09, CUDA 13.4. Model: Maya-L (IQ3_S / IQ4_XS experts), ~85% of the experts in VRAM, the rest pinned in RAM, CPU lane on; 8 conversations at most. Two live A/B pairs, back to back, 35-45 minutes each after a 12-minute warm-up. t1 = off; t2 = `LEND_SPREAD=1`, `COUNT_HALF=432000`, `PROMPT_COUNTS=0.1`: | | pair 1: t1 | pair 1: t2 | pair 2: t1 | pair 2: t2 | |---|---|---|---|---| | CPU-lane split of a two-miss route (first GPU, picked at start) | 1 CPU + 1 PCIe | 1 + 1 | 1 + 1 | **2 CPU** | | running (mean) | 8.0 | 7.9 | 7.9 | 7.1 | | VRAM hit (engine's window) | 97.2% | **97.5%** | 96.6% | **97.8%** | | VRAM hit per request (decode, median) | 96.8% | **97.2%** | 96.7% | **97.7%** | | RAM-tier experts over PCIe a token | 1.16 | 1.09 | 1.55 | 0.33 | | decode per request, 64-128K context | 17.2 tok/s | 17.6 | 14.4 (8 requests) | 20.2 | | decode per request, 128-160K context | 16.9 tok/s | 15.9 | 15.5 | too few | The VRAM hit rose in both pairs (+0.3 and +1.1 points). Decode did not show a clear gain: pair 1 (same CPU-lane split) moved -6% to +2% by context; pair 2's larger numbers came with a different CPU-lane split picked at start (which alone cuts PCIe fetches: a t1 start with that split fetched 0.36 a token) and lighter contexts. A replay of 26 minutes of live routes put the longer count memory as the best eviction-side rule (+0.2 points); the replay does not model the early-layer decay `LEND_SPREAD` aims at, and no route log was taken with t2. ## The benchmark that should decide `tools/glm_multi_replay.py run` replays a fixed workload against a running server, fixed by `--seed`: 8 conversations sharing 30K / 8K / 4K-token system prompts; turns that append mostly short new text (95% under 8K tokens, a few up to 64K) with 2-20 s think times; 40 short checks an hour on one 30K system prompt; two cold bursts where half the clients start over; compaction past `--max-context`. The history is scripted (the model's answers are not fed back) and requests are greedy with the end tokens banned, so every run sends the same prompts and writes the same tokens. It records each request's read and decode times and VRAM hit (`/metrics?requests=all`), the tiers every 10 s, and, with `--route-log`, the VRAM hit of layer bands over the run. `compare` prints mean +- sd per configuration and marks differences beyond twice their standard error. Protocol: experts partly in RAM; the same config but the settings; the CPU-lane split pinned (`MAYA_GLM_CPU_PLAN`); a fresh engine and empty slot folder per run; configurations alternated, 3 runs each, 30 minutes per run. **The settings stay only if VRAM hit and decode per request improve beyond the run-to-run spread.** Not run yet. ## Recommendation For now: with experts partly in RAM and several conversations, the three settings together raised the VRAM hit by 0.3-1.1 points without a decode gain shown; leave them off by default until the benchmark above shows a real one. With every expert in VRAM there are no misses to save; streamed from RAM and one GPU were not measured. ## Exactness Not bitwise against the settings off: they change which experts sit in VRAM at a given moment, and with it which ones the CPU lane computes (another rounding) and the order a prompt chunk sums expert outputs in - the same kind of difference as between any two runs, since the tiers depend on timing. With the CPU lane off, decode arithmetic does not depend on where an expert sits. ## How it was verified - `tests/core/tier_policy_test.cpp` (CPU): the parse and ranges; the defaults match the old halving loops; the weighted prompt counts; both tail layouts tile the region exactly, and a spread loan is even across the layers. - `tools/test_glm_multi_replay.py` (no GPU, part of the CI's tools tests): the workload's determinism, the texts and requests, the summary's bins, the route-log bands, the comparison, and a short run against a fake server. - On v1.1.23 (this branch): builds (nvcc 13.4, sm_75 and sm_120); `tier_policy_test` passes on the box above; `tools/check_hip_compat.py` is clean. - The live pairs: these settings on v1.1.21, ~2 h with t2, 0 engine errors. Not run on a GPU on v1.1.22+, where upstream changed the lending's victim choice next to `LEND_SPREAD`'s code (by reading, the two are independent). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:26:11 +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#507
No description provided.