[PR #1042] [CLOSED] prefill: bytes_needed sizes the MoE buffers for the layout init picks (with or without an expert source) #2988

Closed
opened 2026-11-04 02:04:42 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1042
Author: @sergqwer
Created: 10/6/2026
Status: ❌ Closed

Base: main ← Head: pr/prefill-bytes-needed


📝 Commits (10+)

  • f4e96d5 tests: gdn_rec_head also compares the PP (variant 4) and two-column (variant 5) recurrence kernels, bitwise
  • 16bc95a prefill: STRATA_HCD_EXACT=1 - the HC down projection by a WMMA kernel with hipBLASLt solution 1176/1177 k order (StaggerU included), bitwise
  • 502fcef #606: the fused SwiGLU q8_1 quantizers keep the block's scale and sum finite too
  • 64d0136 cache: preserve checkpoints when split allocation fails
  • a0d0056 prefill: fused-expert exact wins (table16 via direct selector, float4 moe_combine, LDS alias + occupancy)
  • 5f5452b serve: park_current's try covers the checkpoint split too (#752): a host OOM skips parking
  • 8b19a38 Layer split: --vram-reserve-later-mib, a separate reserve for the later cards
  • ea83d0d Resident RAM mode with a layer split
  • d2d981f setup: the low-RAM mode's resident variant on several GPUs (#642)
  • cd62e5e serve: a split's stage-0 GPU profile line keeps its text (#848); later stages say which stage

📊 Changes

3 files changed (+27 additions, -21 deletions)

View changed files

📝 include/strata/prefill/prefill.hpp (+9 -5)
📝 src/prefill/prefill.cpp (+11 -9)
📝 src/program/generate.cpp (+7 -7)

📄 Description

Replaces #547. GitHub closed it on 2026-10-05, when my fork was made private by mistake: that took the fork out of the network for good, so it can no longer open pull requests. This is the same branch and commit (b3a15cf), opened from a new fork; the discussion and the measurements are in #547.


Prefill::bytes_needed() sizes the region the prompt path borrows from the expert cache, and it must count exactly what carve() allocates. It does not, in two places (src/prefill/prefill.cpp).

  1. xn and grs. bytes_needed counts a T x D float buffer for xn. carve allocates it only under STRATA_GR_UNFUSED=1; by default the fused read reads R. bytes_needed also leaves out grs (T x HC floats), which carve always takes. Net, 40,944 bytes a token too many:

    • 0.31 GiB at the default 8192-token chunk;
    • 1.25 GiB at a 32K chunk (--prefill auto:32768).

    Those expert-cache slots are lent to every prompt, never used, and refilled after it. A 12-16 GB card feels it most: either more experts are streamed during the prompt, or the auto chunk steps down earlier than it needs to.

  2. The MoE layout. bytes_needed sizes the MoE scratch with fused_layout(T, true), but carve uses fused_layout(T, m.src != nullptr). For a pack that can take the fused layout, a caller with no ExpertSource gets a region sized for the smaller fused buffers, and init then asks for MMQ-sized ones. bytes_needed now takes a src flag (default true), and generate.cpp passes srcp != nullptr at its four call sites.

Measured on an RTX 5090, IQ2_XS (ISTA), --expert-cache 14900, v0.1.37 against this PR:

prompt slots the prompt path borrows first-token logits prompt time (one run each)
2K (1 chunk) 1,303 -> 1,239 (1.75 -> 1.67 GiB) byte-identical 871 / 884 ms
32K (4 x 8192) 3,340 -> 3,108 (4.49 -> 4.18 GiB) byte-identical 6,460 / 6,241 ms

The same experts are computed with the same kernels; only the number of slots lent for the prompt changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio


🔄 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/Niko1221/Strata/pull/1042 **Author:** [@sergqwer](https://github.com/sergqwer) **Created:** 10/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/prefill-bytes-needed` --- ### 📝 Commits (10+) - [`f4e96d5`](https://github.com/Niko1221/Strata/commit/f4e96d55b6f13622bae6b3ded2f81ca16cbd78f6) tests: gdn_rec_head also compares the PP (variant 4) and two-column (variant 5) recurrence kernels, bitwise - [`16bc95a`](https://github.com/Niko1221/Strata/commit/16bc95ab3e5293a6dd557ad0ec7e2a5eef23640a) prefill: STRATA_HCD_EXACT=1 - the HC down projection by a WMMA kernel with hipBLASLt solution 1176/1177 k order (StaggerU included), bitwise - [`502fcef`](https://github.com/Niko1221/Strata/commit/502fcef6ff29325427ecfb5409b242ac7bea18e1) #606: the fused SwiGLU q8_1 quantizers keep the block's scale and sum finite too - [`64d0136`](https://github.com/Niko1221/Strata/commit/64d01362bee3aa109fb340d9b4144a62d9192522) cache: preserve checkpoints when split allocation fails - [`a0d0056`](https://github.com/Niko1221/Strata/commit/a0d00560fdb3bd728001cac756e223b12e3a09e9) prefill: fused-expert exact wins (table16 via direct selector, float4 moe_combine, LDS alias + occupancy) - [`5f5452b`](https://github.com/Niko1221/Strata/commit/5f5452bec6fabe7c76b44af2397b29daac95feb4) serve: park_current's try covers the checkpoint split too (#752): a host OOM skips parking - [`8b19a38`](https://github.com/Niko1221/Strata/commit/8b19a38a57a80ee9c2bd03d677d8b55fc961d34b) Layer split: --vram-reserve-later-mib, a separate reserve for the later cards - [`ea83d0d`](https://github.com/Niko1221/Strata/commit/ea83d0dc5ef3fd481c53ee6bd99dd8016e10ce78) Resident RAM mode with a layer split - [`d2d981f`](https://github.com/Niko1221/Strata/commit/d2d981f5b2841cfcefcc88872730785b9d23bd78) setup: the low-RAM mode's resident variant on several GPUs (#642) - [`cd62e5e`](https://github.com/Niko1221/Strata/commit/cd62e5e07f5efa6be42a8ccfbbc82b78f6abfe93) serve: a split's stage-0 GPU profile line keeps its text (#848); later stages say which stage ### 📊 Changes **3 files changed** (+27 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/prefill/prefill.hpp` (+9 -5) 📝 `src/prefill/prefill.cpp` (+11 -9) 📝 `src/program/generate.cpp` (+7 -7) </details> ### 📄 Description Replaces #547. GitHub closed it on 2026-10-05, when my fork was made private by mistake: that took the fork out of the network for good, so it can no longer open pull requests. This is the same branch and commit (`b3a15cf`), opened from a new fork; the discussion and the measurements are in #547. --- `Prefill::bytes_needed()` sizes the region the prompt path borrows from the expert cache, and it must count exactly what `carve()` allocates. It does not, in two places (`src/prefill/prefill.cpp`). 1. **`xn` and `grs`.** `bytes_needed` counts a T x D float buffer for `xn`. `carve` allocates it only under `STRATA_GR_UNFUSED=1`; by default the fused read reads `R`. `bytes_needed` also leaves out `grs` (T x HC floats), which `carve` always takes. Net, 40,944 bytes a token too many: - 0.31 GiB at the default 8192-token chunk; - 1.25 GiB at a 32K chunk (`--prefill auto:32768`). Those expert-cache slots are lent to every prompt, never used, and refilled after it. A 12-16 GB card feels it most: either more experts are streamed during the prompt, or the auto chunk steps down earlier than it needs to. 2. **The MoE layout.** `bytes_needed` sizes the MoE scratch with `fused_layout(T, true)`, but `carve` uses `fused_layout(T, m.src != nullptr)`. For a pack that can take the fused layout, a caller with no `ExpertSource` gets a region sized for the smaller fused buffers, and `init` then asks for MMQ-sized ones. `bytes_needed` now takes a `src` flag (default `true`), and `generate.cpp` passes `srcp != nullptr` at its four call sites. **Measured** on an RTX 5090, IQ2_XS (ISTA), `--expert-cache 14900`, v0.1.37 against this PR: | prompt | slots the prompt path borrows | first-token logits | prompt time (one run each) | | --- | --- | --- | --- | | 2K (1 chunk) | 1,303 -> 1,239 (1.75 -> 1.67 GiB) | byte-identical | 871 / 884 ms | | 32K (4 x 8192) | 3,340 -> 3,108 (4.49 -> 4.18 GiB) | byte-identical | 6,460 / 6,241 ms | The same experts are computed with the same kernels; only the number of slots lent for the prompt changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:04:42 +07:00
Sign in to join this conversation.
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
Niko1221/Strata#2988
No description provided.