[PR #1441] [CLOSED] Prompt chunks sized for a layer split's pipeline (--prefill-pipe, opt-in; b/a from --calibrate) #3458

Closed
opened 2026-11-07 14:41:37 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1441
Author: @ruibeikaa
Created: 10/7/2026
Status: ❌ Closed

Base: main ← Head: prefill-pipeline-chunk


📝 Commits (6)

  • 4d8740d prefill: chunks sized for a layer split's pipeline (STRATA_PREFILL_PIPE=1, opt-in)
  • a7d3a8a prefill: STRATA_PREFILL_PIPE measures b/a on the rig and picks the chunk count by the pipeline's time
  • 09deb54 prefill: --prefill-pipe takes b/a from setup's --calibrate instead of learning it while serving
  • 875f40b prefill: plan a segment's --prefill-pipe chunk once and read every part of it in that chunk
  • ddd4a5b prefill: --prefill-pipe 1 follows STRATA_PREFILL_EQUAL's rule (even out only when the last chunk streams every expert)
  • a608198 Merge main (v0.1.42) into prefill-pipeline-chunk

📊 Changes

11 files changed (+593 additions, -43 deletions)

View changed files

📝 docs/DETAILS.md (+4 -2)
📝 docs/MULTI_GPU.md (+70 -0)
📝 include/strata/core/conversation_cache.hpp (+10 -0)
📝 include/strata/prefill/prefill.hpp (+37 -1)
📝 serve/server.py (+13 -2)
📝 serve/test_server.py (+32 -1)
📝 setup.py (+2 -1)
📝 src/prefill/prefill.cpp (+133 -12)
📝 src/program/generate.cpp (+140 -14)
📝 tools/calibrate.py (+79 -5)
📝 tools/test_calibrate.py (+73 -5)

📄 Description

Summary

--prefill auto takes the largest chunk the buffers allow (up to 8192). That is right for one card - a chunk costs a
fixed pass over its layers' experts plus a part per token, so few large chunks are cheapest - and not for a layer
split, which reads a prompt as a pipeline: with few large or uneven chunks the later stages wait. A 10.7K-token prompt
read as a 7680 and a 3011 chunk over four stages kept the first stage busy for 24 of the 36 s.

--prefill-pipe R picks the chunk count with the least pipeline time, sum_i (b + a C_i) + (S - 1) max_i (b + a C_i)
for chunks C_i over S stages, within the cap --prefill auto sets, and only when it beats today's split by 3%. R is
b/a in tokens, a property of the PC that differs by an order of magnitude between rigs (about 700 on four GP100 dies,
about 5000 on two RTX 3090 Ti), so setup's --calibrate measures it once, like the PCIe share and the draft floor.
--prefill-pipe 1 only evens out today's chunk count and needs no b/a. The default is 0 (today's split). A prompt's
chunks depend on its length and R only.

Calibration (tools/calibrate.py, layer splits only)

It measures the read speed of a 2K- and an 8K-token prompt (the install's docs, the same text for every value) with
the chunks off, evened out, and b/a 768, 1536, 3072 and 6144. The best is kept only when it reads faster than off in
each of three paired rounds and by more than 3% in the median.

Rig Kept Read tok/s
four GP100 dies (4 stages) b/a 768 off 219–220 → 355–356 in every round (+62%)
two RTX 3090 Ti (2 stages) off nothing beat off; b/a 768 read 20% slower

Measurements by prompt length

Four GP100 dies (PH402 SKU 200), prompt tok/s:

Prompt tokens --prefill auto --prefill 2048 --prefill auto + --prefill-pipe 1024 (chunk)
2,013 180.9 181.4 228.0 (1024)
3,865 207.6 276.5 312.4 (1024)
10,041 261.1 433.0 432.6 (2048)
28,998 475.7 554.1 559.7 (3328)

Two RTX 3090 Ti (two stages), prompt tok/s:

Prompt tokens --prefill auto + b/a 5836 / 6432 (chunk) for comparison: b/a 1024
2,035 694-815 698-816 (today's) 560-562
3,887 1,127-1,207 1,115-1,227 (today's) 880-885
10,063 1,437-1,553 1,654-1,681 (2 x 5120) 1,109-1,113
29,019 2,532-2,603 2,566-2,620 (today's) 2,064-2,089

PH402: --layer-split 12,24,36, Flash-Next IQ3_XXS, 64K, two interleaved rounds (each within 0.2%); b/a 1024 gives the
same chunks as the 700-890 measured on this rig. RTX 3090 Ti: CUDA 12.9 build for sm_86, Swift 1.5 IQ3_XXS, 1M context,
13,371 of 24,576 experts in VRAM, two starts per arm each reading the four prompts twice, the cold first pass after a
card was freed left out; b/a 5836 and 6432 (timed on the rig).

History

  1. The first commit fixed b/a at 1024. MistyMoonR measured 22–36% slower on two RTX 4090 (STRATA_PF_FUSED=1); two
    RTX 3090 Ti read 19–24% slower.
  2. The second commit learned b/a from the chunk times of served prompts. That fixed the speed on those cards, but a
    prompt's chunks, and so its output bits, then depended on how busy the PC was (the same 30K-token prompt was read in
    2560 or 2048 chunks in two starts, with different replies). It also knew nothing for the first prompts after a
    start, and on a noisy rig it never settled.
  3. The third commit (2762964) makes b/a a calibrated setting, as above. The runtime fit is gone.

What changed

  • src/prefill/prefill.cpp, include/strata/prefill/prefill.hpp: Prefill::pipeline_chunk, set_pipe /
    set_pipe_request, and their use in run_impl. Only the first stage chooses - a later stage is handed one chunk at a
    time - so nothing outside the prompt path changes. One log line says what it chose:
    strata prefill: 10058 tokens in 1280-token chunks over 4 stages (--prefill-pipe 706: b/a).
  • src/program/generate.cpp: --prefill-pipe, and the pipe= request key.
  • serve/server.py: strata_tune passes prefill_pipe.
  • tools/calibrate.py, setup.py: the calibration step and its message.
  • docs/MULTI_GPU.md, docs/DETAILS.md: the section and the calibrate list.
  • Tests: tools/test_calibrate.py (20 tests) and serve/test_server.py (tune keys).

🔄 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/1441 **Author:** [@ruibeikaa](https://github.com/ruibeikaa) **Created:** 10/7/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `prefill-pipeline-chunk` --- ### 📝 Commits (6) - [`4d8740d`](https://github.com/Niko1221/Strata/commit/4d8740df99d6c5c1f1955b37dc081ee93b1e0247) prefill: chunks sized for a layer split's pipeline (STRATA_PREFILL_PIPE=1, opt-in) - [`a7d3a8a`](https://github.com/Niko1221/Strata/commit/a7d3a8a1c195c1704ba6affa9229585614758c25) prefill: STRATA_PREFILL_PIPE measures b/a on the rig and picks the chunk count by the pipeline's time - [`09deb54`](https://github.com/Niko1221/Strata/commit/09deb54d6dd593dc1604e67340d10c290cd16da1) prefill: --prefill-pipe takes b/a from setup's --calibrate instead of learning it while serving - [`875f40b`](https://github.com/Niko1221/Strata/commit/875f40b0749b343240902eac3c24e2b2fe23e00e) prefill: plan a segment's --prefill-pipe chunk once and read every part of it in that chunk - [`ddd4a5b`](https://github.com/Niko1221/Strata/commit/ddd4a5bb335fc3d1dc02a7da85858869669b6aa7) prefill: --prefill-pipe 1 follows STRATA_PREFILL_EQUAL's rule (even out only when the last chunk streams every expert) - [`a608198`](https://github.com/Niko1221/Strata/commit/a608198475e3459e1b12c47c22d29f6f1e990976) Merge main (v0.1.42) into prefill-pipeline-chunk ### 📊 Changes **11 files changed** (+593 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+4 -2) 📝 `docs/MULTI_GPU.md` (+70 -0) 📝 `include/strata/core/conversation_cache.hpp` (+10 -0) 📝 `include/strata/prefill/prefill.hpp` (+37 -1) 📝 `serve/server.py` (+13 -2) 📝 `serve/test_server.py` (+32 -1) 📝 `setup.py` (+2 -1) 📝 `src/prefill/prefill.cpp` (+133 -12) 📝 `src/program/generate.cpp` (+140 -14) 📝 `tools/calibrate.py` (+79 -5) 📝 `tools/test_calibrate.py` (+73 -5) </details> ### 📄 Description ## Summary `--prefill auto` takes the largest chunk the buffers allow (up to 8192). That is right for one card - a chunk costs a fixed pass over its layers' experts plus a part per token, so few large chunks are cheapest - and not for a layer split, which reads a prompt as a pipeline: with few large or uneven chunks the later stages wait. A 10.7K-token prompt read as a 7680 and a 3011 chunk over four stages kept the first stage busy for 24 of the 36 s. `--prefill-pipe R` picks the chunk count with the least pipeline time, sum_i (b + a C_i) + (S - 1) max_i (b + a C_i) for chunks C_i over S stages, within the cap `--prefill auto` sets, and only when it beats today's split by 3%. R is b/a in tokens, a property of the PC that differs by an order of magnitude between rigs (about 700 on four GP100 dies, about 5000 on two RTX 3090 Ti), so setup's `--calibrate` measures it once, like the PCIe share and the draft floor. `--prefill-pipe 1` only evens out today's chunk count and needs no b/a. The default is 0 (today's split). A prompt's chunks depend on its length and R only. ## Calibration (`tools/calibrate.py`, layer splits only) It measures the read speed of a 2K- and an 8K-token prompt (the install's docs, the same text for every value) with the chunks off, evened out, and b/a 768, 1536, 3072 and 6144. The best is kept only when it reads faster than off in each of three paired rounds and by more than 3% in the median. | Rig | Kept | Read tok/s | |---|---|---| | four GP100 dies (4 stages) | b/a 768 | off 219–220 → 355–356 in every round (+62%) | | two RTX 3090 Ti (2 stages) | off | nothing beat off; b/a 768 read 20% slower | ## Measurements by prompt length Four GP100 dies (PH402 SKU 200), prompt tok/s: | Prompt tokens | `--prefill auto` | `--prefill 2048` | `--prefill auto` + `--prefill-pipe 1024` (chunk) | | ---: | ---: | ---: | ---: | | 2,013 | 180.9 | 181.4 | **228.0** (1024) | | 3,865 | 207.6 | 276.5 | **312.4** (1024) | | 10,041 | 261.1 | 433.0 | **432.6** (2048) | | 28,998 | 475.7 | 554.1 | **559.7** (3328) | Two RTX 3090 Ti (two stages), prompt tok/s: | Prompt tokens | `--prefill auto` | + b/a 5836 / 6432 (chunk) | for comparison: b/a 1024 | | ---: | ---: | ---: | ---: | | 2,035 | 694-815 | 698-816 (today's) | 560-562 | | 3,887 | 1,127-1,207 | 1,115-1,227 (today's) | 880-885 | | 10,063 | 1,437-1,553 | **1,654-1,681** (2 x 5120) | 1,109-1,113 | | 29,019 | 2,532-2,603 | 2,566-2,620 (today's) | 2,064-2,089 | PH402: `--layer-split 12,24,36`, Flash-Next IQ3_XXS, 64K, two interleaved rounds (each within 0.2%); b/a 1024 gives the same chunks as the 700-890 measured on this rig. RTX 3090 Ti: CUDA 12.9 build for sm_86, Swift 1.5 IQ3_XXS, 1M context, 13,371 of 24,576 experts in VRAM, two starts per arm each reading the four prompts twice, the cold first pass after a card was freed left out; b/a 5836 and 6432 (timed on the rig). ## History 1. The first commit fixed b/a at 1024. MistyMoonR measured 22–36% slower on two RTX 4090 (`STRATA_PF_FUSED=1`); two RTX 3090 Ti read 19–24% slower. 2. The second commit learned b/a from the chunk times of served prompts. That fixed the speed on those cards, but a prompt's chunks, and so its output bits, then depended on how busy the PC was (the same 30K-token prompt was read in 2560 or 2048 chunks in two starts, with different replies). It also knew nothing for the first prompts after a start, and on a noisy rig it never settled. 3. The third commit (2762964) makes b/a a calibrated setting, as above. The runtime fit is gone. ## What changed - `src/prefill/prefill.cpp`, `include/strata/prefill/prefill.hpp`: `Prefill::pipeline_chunk`, `set_pipe` / `set_pipe_request`, and their use in `run_impl`. Only the first stage chooses - a later stage is handed one chunk at a time - so nothing outside the prompt path changes. One log line says what it chose: `strata prefill: 10058 tokens in 1280-token chunks over 4 stages (--prefill-pipe 706: b/a)`. - `src/program/generate.cpp`: `--prefill-pipe`, and the `pipe=` request key. - `serve/server.py`: `strata_tune` passes `prefill_pipe`. - `tools/calibrate.py`, `setup.py`: the calibration step and its message. - `docs/MULTI_GPU.md`, `docs/DETAILS.md`: the section and the calibrate list. - Tests: `tools/test_calibrate.py` (20 tests) and `serve/test_server.py` (tune keys). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:41:37 +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#3458
No description provided.