[PR #4010] [CLOSED] [Engine] Pipelined batch groups adapt the VRAM tier (opt-in STRATA_PIPE_ADAPT_EVERY): six-stream decode after a start 309 -> 410 tok/s #4874

Closed
opened 2026-11-07 16:31:01 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4010
Author: @SuperDistance
Created: 10/24/2026
Status: ❌ Closed

Base: main ← Head: pr/pipelined-adapt


📝 Commits (1)

  • b0af5d6 batch-groups: opt-in adaptive-tier rounds in the pipelined loop (STRATA_PIPE_ADAPT_EVERY)

📊 Changes

4 files changed (+148 additions, -5 deletions)

View changed files

📝 docs/BATCHING.md (+27 -1)
📝 include/strata/program/batch_groups.hpp (+30 -0)
📝 src/program/batch_groups_test.cpp (+38 -1)
📝 src/program/generate.cpp (+53 -3)

📄 Description

Problem and result

With --batch-groups above 1 on a layer split, the pipelined batch loop never starts a round of the adaptive VRAM tier. The serial batch windows start one every --adapt-every windows (#1637); pump counts the routing but starts none, as docs/BATCHING.md says ("The pipelined --batch-groups path does not adapt"). So while the slots are busy the tier only moves when they go back to the solo path, and a freshly started engine keeps its start-up profile for minutes.

On 2x RTX 5090 a fresh engine's six-stream decode climbs from 246 to 355 tokens/s over eight bursts while the tier gains 96 experts every burst or two. With the new opt-in STRATA_PIPE_ADAPT_EVERY=128 it runs at about 415 tokens/s from the second burst: 309 -> 410 tokens/s (mean of eight bursts, two fresh engines each). Unset, nothing changes: under the exactness settings the answers are byte-identical to the release.

#1637 (the tier in serial batch windows; this is the pipelined half). Found while comparing 0.2.1.3 and 0.2.4.1 on this machine: single engines differed by -6.5% and +3.3%, interleaved warm engines by 0.1% (311.9 against 311.6 tokens/s), and the single-engine differences followed each engine's swap count.

Approach

  • After N group windows pump starts no new group on the first stage, lets the groups in flight finish, then runs one round exactly as batch_step does between serial windows: adapt(), then apply_pending(true). Nothing in flight reads a cache slot while experts are swapped, and the new experts have landed before the next launch. Then it goes on.
  • Not while a prompt is read beside the slots (in_prompt_read: its loan of cache slots), not with --adapt-async 1 (its own ticks), not while a round's copies are in flight, not with the tier off.
  • The rule is two pure functions in include/strata/program/batch_groups.hpp (pipe_adapt_every(), pipe_adapt_due()), checked by 12 new cases in batch_groups_test.
  • With the switch set, the engine says so once among the start-up lines, and the strata batch (pipelined ...) line adds the rounds, the experts swapped in and the time spent.
  • Unset (or 0, or not a number): one counter increment and one false check per group window. No new log line, and the summary line prints as before.
  • docs/BATCHING.md documents the switch and the measurements.

Validation

Passed:

  • Build of main 7dd5cf18 + this commit (b0af5d61), Windows 11, MSVC 2022, CUDA 13.0, sm_120: cmake --build <dir> --target batch_groups_test strata, then batch_groups_test.exe -> batch_groups_test: all passed, including the 12 new pipe adapt: cases.
  • HIP build for gfx1100 on Windows (tools/hip/build_windows.bat): compiles. Not run (no AMD GPU).
  • 2x RTX 5090 (Windows 11, 450 W limit), Swift-Qwen3.8-Flash-Next IQ3_S, --layer-split 25 --trim-stage-weights --batch 6 --batch-groups 2 --resident-experts --kv-resident 32768 --adapt-every 16 --pool-workers 15, served through serve/server.py. Each arm got a freshly loaded engine with no warm-up, then tools/serve_load.py --clients 6 --rounds 8 --max-tokens 1024. The measure is the engine's own strata batch (pipelined ...) rows/s for each burst (one row is one token of one slot). Order: stock, 128, 32, unset, 32, 128.
build / STRATA_PIPE_ADAPT_EVERY bursts 1-8, tokens/s mean experts swapped before burst 8
v0.2.4.1 release 246, 257, 291, 292, 335, 338, 356, 355 309 287
this change, unset 249, 242, 297, 296, 333, 336, 372, 362 311 288
this change, 128 363, 415, 414, 420, 420, 411, 415, 420 410 6,181
this change, 128 359, 407, 416, 422, 419, 417, 404, 411 407 6,294
this change, 32 375, 405, 408, 405, 409, 390, 405, 409 402 5,957
this change, 32 384, 414, 404, 402, 401, 412, 406, 401 403 5,678

With 128: 14 to 16 rounds per burst, 576 to 1,440 experts swapped in, 130 to 322 ms of a 14 to 16 s burst in the rounds (the pipeline drains not counted). 32 runs 61 to 63 rounds per burst, and its four times as many drains end a little lower. No errors and no stall lines in any engine log.

  • Default path: under the exactness settings of docs/BATCHING.md (STRATA_IQ_MT_MIN=1, --pcie-frac 0, --adapt-every 1000000, --no-prefill-borrow), six streams x two bursts x 512 greedy tokens with the same prompts: release, then this change unset, then the release again. serve_load.py --compare against the first run: ALL IDENTICAL both times.

Failed: none observed. Without the exactness settings the unset build's answers differed from the release's in all 48 requests (from the 20th to the 1,191st character), as BATCHING.md says outputs do run to run.

Not run:

  • The measurements were taken on afd1a8c8. It has the same rule inline in generate.cpp and printed the start-up line later. This head moves the rule into batch_groups.hpp, moves the line to the start-up lines, and is rebased onto 7dd5cf18; it was rebuilt and unit-tested, not re-measured.
  • Long soaks, and parallel load with prompts read beside the slots (STRATA_PIPED_CONCURRENT): the rounds pause then by design, but that was not exercised.
  • More than two stages, other GPUs, Linux, SYCL (no oneAPI here), HIP at run time.

Limits

  • One machine, model and configuration. The gain is largest right after a start or a change of traffic. An engine whose slots often go back to the solo path adapts there too, so a long-running server may gain less.
  • Each round empties the pipeline once. 128 was the better of the two values tried, not a tuned optimum.
  • The default stays off. A default change would need numbers from other machines.

🔄 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/4010 **Author:** [@SuperDistance](https://github.com/SuperDistance) **Created:** 10/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/pipelined-adapt` --- ### 📝 Commits (1) - [`b0af5d6`](https://github.com/Niko1221/Strata/commit/b0af5d618259967796ae83a95cb485a13fbd385c) batch-groups: opt-in adaptive-tier rounds in the pipelined loop (STRATA_PIPE_ADAPT_EVERY) ### 📊 Changes **4 files changed** (+148 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/BATCHING.md` (+27 -1) 📝 `include/strata/program/batch_groups.hpp` (+30 -0) 📝 `src/program/batch_groups_test.cpp` (+38 -1) 📝 `src/program/generate.cpp` (+53 -3) </details> ### 📄 Description ## Problem and result With `--batch-groups` above 1 on a layer split, the pipelined batch loop never starts a round of the adaptive VRAM tier. The serial batch windows start one every `--adapt-every` windows (#1637); `pump` counts the routing but starts none, as docs/BATCHING.md says ("The pipelined `--batch-groups` path does not adapt"). So while the slots are busy the tier only moves when they go back to the solo path, and a freshly started engine keeps its start-up profile for minutes. On 2x RTX 5090 a fresh engine's six-stream decode climbs from 246 to 355 tokens/s over eight bursts while the tier gains 96 experts every burst or two. With the new opt-in `STRATA_PIPE_ADAPT_EVERY=128` it runs at about 415 tokens/s from the second burst: **309 -> 410 tokens/s** (mean of eight bursts, two fresh engines each). Unset, nothing changes: under the exactness settings the answers are byte-identical to the release. ## Related discussion #1637 (the tier in serial batch windows; this is the pipelined half). Found while comparing 0.2.1.3 and 0.2.4.1 on this machine: single engines differed by -6.5% and +3.3%, interleaved warm engines by 0.1% (311.9 against 311.6 tokens/s), and the single-engine differences followed each engine's swap count. ## Approach - After N group windows `pump` starts no new group on the first stage, lets the groups in flight finish, then runs one round exactly as `batch_step` does between serial windows: `adapt()`, then `apply_pending(true)`. Nothing in flight reads a cache slot while experts are swapped, and the new experts have landed before the next launch. Then it goes on. - Not while a prompt is read beside the slots (`in_prompt_read`: its loan of cache slots), not with `--adapt-async 1` (its own ticks), not while a round's copies are in flight, not with the tier off. - The rule is two pure functions in `include/strata/program/batch_groups.hpp` (`pipe_adapt_every()`, `pipe_adapt_due()`), checked by 12 new cases in `batch_groups_test`. - With the switch set, the engine says so once among the start-up lines, and the `strata batch (pipelined ...)` line adds the rounds, the experts swapped in and the time spent. - Unset (or 0, or not a number): one counter increment and one false check per group window. No new log line, and the summary line prints as before. - docs/BATCHING.md documents the switch and the measurements. ## Validation **Passed:** - Build of main 7dd5cf18 + this commit (b0af5d61), Windows 11, MSVC 2022, CUDA 13.0, sm_120: `cmake --build <dir> --target batch_groups_test strata`, then `batch_groups_test.exe` -> `batch_groups_test: all passed`, including the 12 new `pipe adapt:` cases. - HIP build for gfx1100 on Windows (`tools/hip/build_windows.bat`): compiles. Not run (no AMD GPU). - 2x RTX 5090 (Windows 11, 450 W limit), Swift-Qwen3.8-Flash-Next IQ3_S, `--layer-split 25 --trim-stage-weights --batch 6 --batch-groups 2 --resident-experts --kv-resident 32768 --adapt-every 16 --pool-workers 15`, served through `serve/server.py`. Each arm got a freshly loaded engine with no warm-up, then `tools/serve_load.py --clients 6 --rounds 8 --max-tokens 1024`. The measure is the engine's own `strata batch (pipelined ...)` rows/s for each burst (one row is one token of one slot). Order: stock, 128, 32, unset, 32, 128. | build / `STRATA_PIPE_ADAPT_EVERY` | bursts 1-8, tokens/s | mean | experts swapped before burst 8 | | --- | --- | ---: | ---: | | v0.2.4.1 release | 246, 257, 291, 292, 335, 338, 356, 355 | 309 | 287 | | this change, unset | 249, 242, 297, 296, 333, 336, 372, 362 | 311 | 288 | | this change, 128 | 363, 415, 414, 420, 420, 411, 415, 420 | 410 | 6,181 | | this change, 128 | 359, 407, 416, 422, 419, 417, 404, 411 | 407 | 6,294 | | this change, 32 | 375, 405, 408, 405, 409, 390, 405, 409 | 402 | 5,957 | | this change, 32 | 384, 414, 404, 402, 401, 412, 406, 401 | 403 | 5,678 | With 128: 14 to 16 rounds per burst, 576 to 1,440 experts swapped in, 130 to 322 ms of a 14 to 16 s burst in the rounds (the pipeline drains not counted). 32 runs 61 to 63 rounds per burst, and its four times as many drains end a little lower. No errors and no stall lines in any engine log. - Default path: under the exactness settings of docs/BATCHING.md (`STRATA_IQ_MT_MIN=1`, `--pcie-frac 0`, `--adapt-every 1000000`, `--no-prefill-borrow`), six streams x two bursts x 512 greedy tokens with the same prompts: release, then this change unset, then the release again. `serve_load.py --compare` against the first run: **ALL IDENTICAL** both times. **Failed:** none observed. Without the exactness settings the unset build's answers differed from the release's in all 48 requests (from the 20th to the 1,191st character), as BATCHING.md says outputs do run to run. **Not run:** - The measurements were taken on afd1a8c8. It has the same rule inline in `generate.cpp` and printed the start-up line later. This head moves the rule into `batch_groups.hpp`, moves the line to the start-up lines, and is rebased onto 7dd5cf18; it was rebuilt and unit-tested, not re-measured. - Long soaks, and parallel load with prompts read beside the slots (`STRATA_PIPED_CONCURRENT`): the rounds pause then by design, but that was not exercised. - More than two stages, other GPUs, Linux, SYCL (no oneAPI here), HIP at run time. ## Limits - One machine, model and configuration. The gain is largest right after a start or a change of traffic. An engine whose slots often go back to the solo path adapts there too, so a long-running server may gain less. - Each round empties the pipeline once. 128 was the better of the two values tried, not a tuned optimum. - The default stays off. A default change would need numbers from other machines. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:31:01 +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#4874
No description provided.