[PR #283] [CLOSED] glm prefill: more memory for a long prompt while it reads #445

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/283
Author: @gopinath87607
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: pr/room-draft-lend


📝 Commits (2)

  • 6b40fdd glm prefill: what only the decode needs leaves VRAM while a prompt runs - a split's prestage ring takes the whole loan, and a long prompt takes the DFlash drafter's 0.7 GB (or an MTP block's slots) back as more ring (STRATA_GLM_ROOM_MIN, unset = off)
  • e5285d4 glm prefill: the room's threshold counts the tokens a request READS, not the whole prompt

📊 Changes

6 files changed (+469 additions, -34 deletions)

View changed files

📝 docs/SETTINGS.md (+2 -1)
📝 include/strata/core/glm_dflash.hpp (+10 -0)
📝 include/strata/core/glm_model.hpp (+7 -0)
📝 src/core/glm_dflash.cu (+153 -11)
📝 src/core/glm_fast_path.cu (+29 -11)
📝 src/core/glm_prefill.cu (+268 -11)

📄 Description

Why this PR was recreated. The original (#223) was opened from the gopinath87607/ewaste-maya fork. Deleting that fork deleted its branches, and GitHub closes every pull request whose branch lived in a deleted fork - a closed PR whose source branch is gone cannot be reopened. This is the same work from a new fork (gopinath87607/project-maya), rebased onto current main (v1.1.16 renamed the settings to MAYA_*; that rename is resolved in docs/SETTINGS.md and the code still reads the STRATA_* spelling the alias sets). It replaces the closed #223, which was closed by the fork's deletion, not by a maintainer.

Correctness: the threshold counts the tokens a request reads (2026-10-20)

The same correction as Strata's STRATA_MTP_ROOM_MIN fix (ce882077): an agent turn re-sends a long conversation and reuses almost all of it, and a room that costs a ~0.7 GB round trip each way must not be taken to read a few hundred tokens. In Maya's serving loop prefill() is already handed only the part of the prompt past reuse (generate.cpp), so the value tested was already the read count and run-time behavior is unchanged; the commit makes that the documented contract - tokens_read in the header and the definition, the rationale at the call site, and the setting's row - instead of "a prompt of this many tokens". Commit e5285d4 on top of the rebased feature commit.


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


🔄 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/283 **Author:** [@gopinath87607](https://github.com/gopinath87607) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/room-draft-lend` --- ### 📝 Commits (2) - [`6b40fdd`](https://github.com/mw00/project-maya/commit/6b40fdd4097112ae808ba7bb284b67a69d98f357) glm prefill: what only the decode needs leaves VRAM while a prompt runs - a split's prestage ring takes the whole loan, and a long prompt takes the DFlash drafter's 0.7 GB (or an MTP block's slots) back as more ring (STRATA_GLM_ROOM_MIN, unset = off) - [`e5285d4`](https://github.com/mw00/project-maya/commit/e5285d43ba1d2104638d6a6247cfdf117992568f) glm prefill: the room's threshold counts the tokens a request READS, not the whole prompt ### 📊 Changes **6 files changed** (+469 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `docs/SETTINGS.md` (+2 -1) 📝 `include/strata/core/glm_dflash.hpp` (+10 -0) 📝 `include/strata/core/glm_model.hpp` (+7 -0) 📝 `src/core/glm_dflash.cu` (+153 -11) 📝 `src/core/glm_fast_path.cu` (+29 -11) 📝 `src/core/glm_prefill.cu` (+268 -11) </details> ### 📄 Description > **Why this PR was recreated.** The original (#223) was opened from the `gopinath87607/ewaste-maya` fork. Deleting that fork deleted its branches, and GitHub closes every pull request whose branch lived in a deleted fork - a closed PR whose source branch is gone cannot be reopened. This is the same work from a new fork (`gopinath87607/project-maya`), rebased onto current `main` (v1.1.16 renamed the settings to `MAYA_*`; that rename is resolved in `docs/SETTINGS.md` and the code still reads the `STRATA_*` spelling the alias sets). It replaces the closed #223, which was closed by the fork's deletion, not by a maintainer. ### Correctness: the threshold counts the tokens a request reads (2026-10-20) The same correction as Strata's `STRATA_MTP_ROOM_MIN` fix (`ce882077`): an agent turn re-sends a long conversation and reuses almost all of it, and a room that costs a ~0.7 GB round trip each way must not be taken to read a few hundred tokens. In Maya's serving loop `prefill()` is already handed only the part of the prompt past `reuse` (generate.cpp), so the value tested was already the read count and run-time behavior is unchanged; the commit makes that the documented contract - `tokens_read` in the header and the definition, the rationale at the call site, and the setting's row - instead of "a prompt of this many tokens". Commit `e5285d4` on top of the rebased feature commit. --- 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) --- <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:30 +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#445
No description provided.