[PR #243] [CLOSED] glm spec: take the NextN head's recurrent-state backup at setup, before the expert pool - no more "the recurrent-state backup did not allocate" at a 200 MB reserve #420

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

📋 Pull Request Information

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

Base: main ← Head: pr/spec-backup


📝 Commits (1)

  • bde81f5 glm spec: the head's recurrent-state backup is taken at setup, before the expert pool - the spec path's first decode step could not allocate it once the reserve was not the only room left

📊 Changes

3 files changed (+57 additions, -11 deletions)

View changed files

📝 include/strata/core/glm_model.hpp (+2 -0)
📝 src/core/glm_fast_path.cu (+52 -8)
📝 src/core/glm_window.cu (+3 -3)

📄 Description

What this changes

The speculative path's head saves its recurrent (KDA) states into a backup buffer before a decode step and restores them after a rejected draft. win_reserve took that backup for a DFlash drafter before the expert pool, but its caller is gated on dflash_on_, so the MTP config (a NextN block, no DFlash) still took the backup lazily in spec_kda_copy on the first decode step - after every part's pool had been sized against the reserve. At a 200 MB reserve that malloc fails on all four cards and every request answers HTTP 400 glm spec: the recurrent-state backup did not allocate; 700 MB had been enough, but the reserve is not all allocatable (the driver's own cost for a pool this size comes out of it).

fast_setup now reserves it for a NextN split's head group on the same footing as win_reserve does for DFlash: the parts [0, h) that kda_all walks, h from part_/n_parts_ because split_next_ is linked only after every part has loaded. The size math moves into spec_kda_bytes() / spec_kda_run(), and win_reserve calls it instead of repeating it. The setup line glm spec: CUDA%d the head's recurrent-state backup (N MB) before the expert pool marks it.

What it leaves alone

The one-GPU MTP path, DFlash's own reserve, and the STRATA_GLM_NO_MTP / STRATA_GLM_NO_SPEC gates are unchanged. The backup is taken only for the head group of a multi-part NextN split, and only when it is needed (g_.nextn > 0, n_parts_ > 1).

Measurements

MTP config, 4 parts, STRATA_GLM_RESERVE_MB=200: the backup prints on CUDA0 (34 MB) and CUDA1 (30 MB) before the pool lines, and the pools come down by exactly that - 4.47 -> 4.43 GB (384 slots) and 4.46 -> 4.43 GB (408 slots). The 100,534-token read then completes: 100,796.6 ms (1.00 ms/token, 997 tok/s), decode 88.4 ms/token, drafts 74.2%. Before this change every request at that reserve answered HTTP 400 with the allocation error.

Checks

  • src/core/glm_fast_path.cu and src/core/glm_window.cu compile clean with the build's own flags (nvcc 13.2, compute_86 + compute_120).
  • python3 tools/check_hip_compat.py passes.
  • Not run in this branch's preparation; the numbers are the checkout's, on the hardware named.

🤖 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/243 **Author:** [@gopinath87607](https://github.com/gopinath87607) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/spec-backup` --- ### 📝 Commits (1) - [`bde81f5`](https://github.com/mw00/project-maya/commit/bde81f5b97d25def1bc3bb3265430e75fb2f3505) glm spec: the head's recurrent-state backup is taken at setup, before the expert pool - the spec path's first decode step could not allocate it once the reserve was not the only room left ### 📊 Changes **3 files changed** (+57 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/glm_model.hpp` (+2 -0) 📝 `src/core/glm_fast_path.cu` (+52 -8) 📝 `src/core/glm_window.cu` (+3 -3) </details> ### 📄 Description ## What this changes The speculative path's head saves its recurrent (KDA) states into a backup buffer before a decode step and restores them after a rejected draft. `win_reserve` took that backup for a DFlash drafter before the expert pool, but its caller is gated on `dflash_on_`, so the MTP config (a NextN block, no DFlash) still took the backup lazily in `spec_kda_copy` on the first decode step - after every part's pool had been sized against the reserve. At a 200 MB reserve that malloc fails on all four cards and every request answers HTTP 400 `glm spec: the recurrent-state backup did not allocate`; 700 MB had been enough, but the reserve is not all allocatable (the driver's own cost for a pool this size comes out of it). `fast_setup` now reserves it for a NextN split's head group on the same footing as `win_reserve` does for DFlash: the parts `[0, h)` that `kda_all` walks, `h` from `part_`/`n_parts_` because `split_next_` is linked only after every part has loaded. The size math moves into `spec_kda_bytes()` / `spec_kda_run()`, and `win_reserve` calls it instead of repeating it. The setup line `glm spec: CUDA%d the head's recurrent-state backup (N MB) before the expert pool` marks it. ## What it leaves alone The one-GPU MTP path, DFlash's own reserve, and the `STRATA_GLM_NO_MTP` / `STRATA_GLM_NO_SPEC` gates are unchanged. The backup is taken only for the head group of a multi-part NextN split, and only when it is needed (`g_.nextn > 0`, `n_parts_ > 1`). ## Measurements MTP config, 4 parts, `STRATA_GLM_RESERVE_MB=200`: the backup prints on CUDA0 (34 MB) and CUDA1 (30 MB) before the pool lines, and the pools come down by exactly that - 4.47 -> 4.43 GB (384 slots) and 4.46 -> 4.43 GB (408 slots). The 100,534-token read then completes: **100,796.6 ms (1.00 ms/token, 997 tok/s)**, decode 88.4 ms/token, drafts 74.2%. Before this change every request at that reserve answered HTTP 400 with the allocation error. ## Checks - `src/core/glm_fast_path.cu` and `src/core/glm_window.cu` compile clean with the build's own flags (nvcc 13.2, compute_86 + compute_120). - `python3 tools/check_hip_compat.py` passes. - Not run in this branch's preparation; the numbers are the checkout's, on the hardware named. 🤖 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:12 +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#420
No description provided.