[PR #936] [CLOSED] layer split: overlap the stages' hand-off (STRATA_SPLIT_OVERLAP=1, op… #2925

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/936
Author: @bsvinay
Created: 10/5/2026
Status: ❌ Closed

Base: main ← Head: pr-split-overlap


📝 Commits (10+)

  • 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
  • 0471c5a generate: residency-table uploads wait for their own copy before the non-blocking streams read the table
  • 2d82703 generate: res_put syncs stream 0 (HIP has no cudaStreamLegacy) (#550)
  • 7cdc521 verify: the all-resident graph runs only while every expert is in VRAM; a -1 raises a plan error flag (#871)

📊 Changes

2 files changed (+7 additions, -2 deletions)

View changed files

📝 docs/MULTI_GPU.md (+1 -1)
📝 src/program/generate.cpp (+6 -1)

📄 Description

On 2x RX 7900 XTX the layer split decoded slower than one card (53/45 tok/s vs ~70/68, see #642). The cause is the order inside every verify window: stage 1 finishes, the host syncs its stream, then stages and launches stage 2's graph. Under HIP both the sync and the graph launch are expensive, and they sit on the critical path of every window while both cards are idle.

With STRATA_SPLIT_OVERLAP=1 (off by default; stages on different devices only):

  • each hand-off buffer gets a ready word (mapped pinned memory);
  • the writing stage's graph ends with handoff_publish: the hand-off payload with volatile stores (RDNA keeps plain stores to mapped memory in L2 - the same reason as doorbell_ring_kernel's volatile store), a system fence, and the last block raises the flag;
  • the reading stage's graph starts with wait_flag_ge(flag, 1);
  • Verifier::run captures the next stage's window on its own thread, then stages and launches it on a helper thread (prelaunch) while it serves its own layers, goes straight on to serving the next stage's layers, and syncs the earlier stage only once the chain is done;
  • release_gpu_waits also raises the hand-in flag, and an early return after the prelaunch releases the next stage (#267).

Batch windows, --split-device 0 and the default path are unchanged. Docs: a section in docs/MULTI_GPU.md.

Measured on 2x RX 7900 XTX (gfx1100, ROCm, Linux), Ryzen 9 9900X, 52 GB RAM, Swift 1.5 IQ3_XXS, 128K context, 8-bit KV, split layers 0-25 / 26-47; 512-token greedy answers, median of 8 runs:

serial (default) STRATA_SPLIT_OVERLAP=1 one card
decode, code prompt 53 tok/s 70.1 tok/s ~70
decode, prose prompt 45 tok/s 55.9 tok/s ~68
  • Greedy output byte-identical with the flag at 0 and 1 (same prompt, both runs checked in the engine log: overlapped / serial).
  • Setting it back to 0 returns the old speeds (53/45).
  • Quiz set: 47/51 on the split, same as one card.
  • Prefill unchanged (1,232 / 1,763 / 2,147 tok/s at 4K / 16K / 32K).

Not measured on NVIDIA, where a sync and a graph launch cost less - that is why it is opt-in. Happy to change the default or the switch name as you prefer.


🔄 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/936 **Author:** [@bsvinay](https://github.com/bsvinay) **Created:** 10/5/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr-split-overlap` --- ### 📝 Commits (10+) - [`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 - [`0471c5a`](https://github.com/Niko1221/Strata/commit/0471c5a3d26aa4209ddfc7a7f75f9fca324b2c27) generate: residency-table uploads wait for their own copy before the non-blocking streams read the table - [`2d82703`](https://github.com/Niko1221/Strata/commit/2d82703c7929682d0ae8f8f09cdfcc1fb9a6ffdb) generate: res_put syncs stream 0 (HIP has no cudaStreamLegacy) (#550) - [`7cdc521`](https://github.com/Niko1221/Strata/commit/7cdc521742fa9cb6d3c35cf012ac24db17bba3c2) verify: the all-resident graph runs only while every expert is in VRAM; a -1 raises a plan error flag (#871) ### 📊 Changes **2 files changed** (+7 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/MULTI_GPU.md` (+1 -1) 📝 `src/program/generate.cpp` (+6 -1) </details> ### 📄 Description On 2x RX 7900 XTX the layer split decoded slower than one card (53/45 tok/s vs ~70/68, see #642). The cause is the order inside every verify window: stage 1 finishes, the host syncs its stream, then stages and launches stage 2's graph. Under HIP both the sync and the graph launch are expensive, and they sit on the critical path of every window while both cards are idle. With STRATA_SPLIT_OVERLAP=1 (off by default; stages on different devices only): - each hand-off buffer gets a ready word (mapped pinned memory); - the writing stage's graph ends with `handoff_publish`: the hand-off payload with volatile stores (RDNA keeps plain stores to mapped memory in L2 - the same reason as doorbell_ring_kernel's volatile store), a system fence, and the last block raises the flag; - the reading stage's graph starts with `wait_flag_ge(flag, 1)`; - `Verifier::run` captures the next stage's window on its own thread, then stages and launches it on a helper thread (`prelaunch`) while it serves its own layers, goes straight on to serving the next stage's layers, and syncs the earlier stage only once the chain is done; - `release_gpu_waits` also raises the hand-in flag, and an early return after the prelaunch releases the next stage (#267). Batch windows, --split-device 0 and the default path are unchanged. Docs: a section in docs/MULTI_GPU.md. Measured on 2x RX 7900 XTX (gfx1100, ROCm, Linux), Ryzen 9 9900X, 52 GB RAM, Swift 1.5 IQ3_XXS, 128K context, 8-bit KV, split layers 0-25 / 26-47; 512-token greedy answers, median of 8 runs: | | serial (default) | STRATA_SPLIT_OVERLAP=1 | one card | |----------------------|------------------|------------------------|----------| | decode, code prompt | 53 tok/s | 70.1 tok/s | ~70 | | decode, prose prompt | 45 tok/s | 55.9 tok/s | ~68 | - Greedy output byte-identical with the flag at 0 and 1 (same prompt, both runs checked in the engine log: overlapped / serial). - Setting it back to 0 returns the old speeds (53/45). - Quiz set: 47/51 on the split, same as one card. - Prefill unchanged (1,232 / 1,763 / 2,147 tok/s at 4K / 16K / 32K). Not measured on NVIDIA, where a sync and a graph launch cost less - that is why it is opt-in. Happy to change the default or the switch name as you prefer. --- <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:13 +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#2925
No description provided.