[PR #223] glm prefill: what only the decode needs leaves VRAM while a prompt runs, and the prestage ring takes it (STRATA_GLM_ROOM_MIN, unset = off) #406

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

Original Pull Request: https://github.com/mw00/project-maya/pull/223

State: closed
Merged: No


Two pieces of VRAM belong to the decode and are never read while a prompt runs. With this flag set they leave for the length of the prompt and come back before the next token:

  • The DFlash drafter (~0.7 GB of weights and block buffers): copied once into pinned host memory, DMA'd back after the last chunk. Its K/V ring, pinned staging and position vectors stay (the prompt's captured window must survive), and decode_dflash refuses to run while it is lent, so nothing can draft against half a drafter.
  • An MTP config's NextN block: its expert slots were inside the pool's lendable tail all along, so nothing is freed - the prompt's carve, which lends from the front, simply takes the draft block's slots before any trunk layer's decode cache.

The freed bytes become prestage ring. On a split with STRATA_GLM_PRESTAGE unset, the ring stops being capped at Strata's 160 experts and only the pool's lend bounds it: in the measured run CUDA2/CUDA3 (the parts that sat at the cap) went to 439 and 303 experts, where the two 8 GB parts were already lend-bound at 127 and 90.

Flag: STRATA_GLM_ROOM_MIN - unset (the default) is the engine as it is today: the ring keeps its cap, nothing is unloaded, every layer's tail stays k_extra. Set to N, prompts of N tokens or more take the room; 0 = every prompt. STRATA_GLM_PRESTAGE still caps the ring when it is set.

Measured (4 parts: 2x RTX 3060 12 GB + 2x RTX 5060 8 GB, --layer-split 10,21,33, 260k ctx, --prefill 16384, STRATA_GLM_ROOM_MIN=8192): the byte-identical 100,534-token read in 90,891 ms - 1,106 tok/s, 13 chunks of 7,744 - against the same rig's standing 89.5 s / 1,123 tok/s. A prompt chunk here is compute-bound, so what this buys is the ring and the phase booking, not seconds.

docs/SETTINGS.md carries both rows. Builds clean; python3 tools/check_hip_compat.py passes.

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/mw00/project-maya/pull/223 **State:** closed **Merged:** No --- Two pieces of VRAM belong to the decode and are never read while a prompt runs. With this flag set they leave for the length of the prompt and come back before the next token: - **The DFlash drafter** (~0.7 GB of weights and block buffers): copied once into pinned host memory, DMA'd back after the last chunk. Its K/V ring, pinned staging and position vectors stay (the prompt's captured window must survive), and `decode_dflash` refuses to run while it is lent, so nothing can draft against half a drafter. - **An MTP config's NextN block**: its expert slots were inside the pool's lendable tail all along, so nothing is freed - the prompt's carve, which lends from the front, simply takes the draft block's slots before any trunk layer's decode cache. The freed bytes become **prestage ring**. On a split with `STRATA_GLM_PRESTAGE` unset, the ring stops being capped at Strata's 160 experts and only the pool's lend bounds it: in the measured run CUDA2/CUDA3 (the parts that sat at the cap) went to 439 and 303 experts, where the two 8 GB parts were already lend-bound at 127 and 90. **Flag:** `STRATA_GLM_ROOM_MIN` - unset (the default) is the engine as it is today: the ring keeps its cap, nothing is unloaded, every layer's tail stays `k_extra`. Set to N, prompts of N tokens or more take the room; `0` = every prompt. `STRATA_GLM_PRESTAGE` still caps the ring when it is set. **Measured** (4 parts: 2x RTX 3060 12 GB + 2x RTX 5060 8 GB, `--layer-split 10,21,33`, 260k ctx, `--prefill 16384`, `STRATA_GLM_ROOM_MIN=8192`): the byte-identical 100,534-token read in 90,891 ms - **1,106 tok/s**, 13 chunks of 7,744 - against the same rig's standing 89.5 s / 1,123 tok/s. A prompt chunk here is compute-bound, so what this buys is the ring and the phase booking, not seconds. `docs/SETTINGS.md` carries both rows. Builds clean; `python3 tools/check_hip_compat.py` passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
bsakaguchi 2026-10-29 21:25:04 +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#406
No description provided.