[PR #3821] [Engine] Prefill pipe: STRATA_PREFILL_PIPE_FLOOR, the smallest pipelined prompt chunk (default 512, as before) #4794

Open
opened 2026-11-07 15:39:05 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3821
Author: @ruibeikaa
Created: 10/23/2026
Status: 🔄 Open

Base: main ← Head: prefill-pipe-floor


📝 Commits (1)

  • 53054ff prefill: STRATA_PREFILL_PIPE_FLOOR sets the smallest pipelined chunk (default 512, as before)

📊 Changes

1 file changed (+12 additions, -2 deletions)

View changed files

📝 src/prefill/prefill.cpp (+12 -2)

📄 Description

Problem and result

Everything below was measured on four GP100 dies (two PH402 SKU 200 boards, 32 GB HBM2 per die, 128 GB in all) with every expert resident in VRAM: no CPU share, no PCIe share, no adaptive tier. A rig that keeps experts in RAM or streams them over PCIe was not measured. HIP, SYCL and Metal were not built.

--prefill-pipe <b/a> (#1441, in main as 125025a7) tries every chunk count from the fewest the buffers allow up to one chunk per 512 tokens, each chunk evened out on the 256-token grid and at least 512 tokens. On a rig with a small b/a - four GP100 dies with every expert in VRAM measure about 70 tokens - the cheapest split of a short prompt has chunks below 512 tokens, which that floor rules out: a 1.15K-token prompt is read in 512-token chunks through four stages.

STRATA_PREFILL_PIPE_FLOOR=<tokens> sets that floor (rounded up to the 256-token grid, clamped to 256..4096). Unset, it is 512 and the rule picks the chunks it picks today. On four GP100 dies with b/a 70 and the floor at 256, a fresh 1.15K-token read went 4,310 -> 3,861 ms (-10.4%) and a 1.1K-token append to a 26K-token conversation 4,946 -> 4,461 ms (-9.8%); the other prompt reads kept their chunks and their times, and decode is unchanged.

Bitwise identity is not kept where the chunks change, as with any other --prefill-pipe value: the prompt pass sums in another order. Of the 15 requests below, the two whose chunks changed have different engine state hashes, and one of their replies - the 16 tokens after the 1.1K-token append - differs from the unchanged engine's.

Follow-up to #1441: the same rule with one more knob, no default change. This branch is main plus one commit and needs none of my other PRs. The main e88ee39d run below was on a branch that also carried #3455, #3760, #3819, #3751 and #3820, all on in the arm before this one.

Approach

  • prefill.cpp: pipe_floor() next to pipe_value(), read once. Both places in pipeline_chunk where 512 was written - the largest chunk count tried, (n + 511) / 512, and the smallest chunk, max(512, ...) - take it. The cost model, the 3% rule and --prefill-pipe 1 are untouched.
  • With the floor at 512 the two expressions are the ones they replace, so the chunks are the same for every prompt length, buffer chunk, stage count and b/a.
  • Host code only. SYCL has its own prefill.cpp (untouched); HIP and Metal compile this one.

Validation

Rig: four GP100 dies (compute capability 6.0, application clocks 1050 MHz graphics / 715 MHz memory, 140 W cap), Windows 11, driver 581.80 (TCC), CUDA 12.9, VS 2022. Build -DSTRATA_EXPERIMENTAL_SM60=ON -DCMAKE_CUDA_ARCHITECTURES=60, ggml at the pinned 3cf03257f, unpatched. Model: Swift 1.5 IQ3_S (abliterated GSQ-RCO GGUF, dense matrices in Q8_0).

Passed:

  • main e88ee39d (engine 0.1.45.3) plus my GP100 stack, one exe for every arm, one engine start per arm, greedy; a ladder in which each arm adds one switch to the arm before. Arm S5 = #3455, #3760, #3819, #3751 and #3820 on; arm S6 = S5 + STRATA_PREFILL_PIPE_FLOOR=256.

    • Engine arguments, the same in every arm: --serve --expert-cache auto --prefill auto --spec 4 --spec-min-p 0.85 --mtp <drafter> --max-context 1048576 --kv int8 --layer-split 12,24,36 --mtp-window 8192 --pipeline-windows 3 --conversation-cache-mib 32768 --conversation-cache-slots 8 --rope-scaling yarn --rope-scale 4. Environment, the same in every arm: STRATA_PREFILL_PIPE=70 (b/a as measured on this rig) STRATA_Q8_SM60=1 STRATA_STAGE_TRIM=1 STRATA_MMQ_RESIDENT_SORT_NE=1 STRATA_DF_BRANCH=1 STRATA_FUSE_DECODE=1 STRATA_FUSE_WAIT=2 STRATA_SIDE_MIXER=2 STRATA_GR_UP75=1 STRATA_B6_MMVQ_ROWS=1 STRATA_ADAPT_LAG=2 STRATA_ADAPT_NOWAIT=1 STRATA_DECODE_TIMING=1. Each start's switches were checked in the engine process's environment.
    • Requests: five short prompts (77-82 tokens in, 400-512 out), a 9.8K-token document + 300 out, a fresh 26K-token read + 400 out and an 88K-token append to it (115K context) + 400 out - the eight benchmark prompts - then prompt reads of 240 / 1.15K / 7.7K / 33K tokens and a 26K-token conversation with a 1.1K-token append (16 out each). A parity pass with STRATA_STATE_HASH=1 and a 250K-token read added (15 requests), and a timing pass without debug switches (14 requests).
    • Chunks (the engine's own lines): with the floor at 256 the 1.15K-token read and the 1.1K-token append ran in 256-token chunks (512 before). Every other read kept its chunks: 512 for 7.7K and 9.8K, 768 for 26K, 1024 for 33K, 1536 for the 88K append, 4096 for 250K, none for 240 tokens.
    • Prompt reads, S5 -> S6, timing pass / parity pass: 1.15K fresh 4,310 -> 3,861 / 4,329 -> 3,884 ms; 1.1K append 4,946 -> 4,461 / 5,012 -> 4,502 ms. The reads whose chunks did not change moved by -0.6..+0.0% in the timing pass.
    • Decode, eight prompts token-weighted: 56.39 -> 56.40 tok/s (timing pass).
    • Parity: 12 of the 15 requests equal to S5 in every reply hash and every STRATA_STATE_HASH item. The 1.15K read: the same reply; every state item except the PLE history differs. The 1.1K append: reply and state differ. The 250K read that came after them in the same engine: the same reply and main-model state; only the drafter's K/V hash (mtp=) differs (not investigated further).
  • Older tree (0.1.41-based, my GP100 branch of that time, not this revision): b/a 70, floor 512 against 256, two engine starts each in mirrored order (512, 256, 256, 512), prompt read ms:

    Read Floor 512 Floor 256 Change
    1.16K fresh 2,658 / 2,658 2,138 / 2,136 -19.6%
    2.5K fresh 4,001 / 4,020 3,605 / 3,606 -10.1%
    4.5K fresh 6,016 / 6,046 5,804 / 6,367 +0.9% (one run faster, one slower)
    8.9K fresh (512 chunks in both) 10,525 / 10,540 10,549 / 11,165 +3.1% (the same chunks; the second run slower)
    317-token append 1,559 / 1,549 1,428 / 1,430 -8.0%
    663-token append 2,461 / 2,452 1,830 / 1,832 -25.5%
    1.19K append 3,011 / 3,006 2,433 / 2,432 -19.2%
    2.5K append 4,363 / 4,359 3,928 / 3,882 -10.5%

    In a separate hash check of the same eight reads (fresh engine starts), the two floor-256 runs gave the same replies, and one of the eight - the 1.19K append, whose chunks changed - differed from an arm at b/a 290 and floor 512.

  • This branch, rebased onto main 5c8dd322: sm_60 with STRATA_EXPERIMENTAL_SM60=ON (strata) and sm_86 without it (strata), both built without errors.

Failed:

  • Bitwise identity with the unchanged engine on the requests whose chunks changed (expected, see above): one reply of 15 differs (the 1.1K-token append), and the state hashes of the two re-chunked requests differ.

Not run:

  • HIP, SYCL and Metal builds (no such machine here).
  • A GPU run of this branch on main 5c8dd322: the numbers above are from the revisions named there; the rebased branch was only built.
  • Floors other than 256 on main; rigs with a larger b/a (there the rule rarely wants chunks below 512, so the floor should not matter - not measured).

Limits

  • A floor below 512 helps only where b/a is small, i.e. where a chunk's fixed cost per stage is low against its per-token cost.
  • Changing the floor changes a short prompt's chunks and therefore its output bits, like changing --prefill-pipe.
  • The knob is not in docs/MULTI_GPU.md; that section's "at least 512" stays true by default.

CI note: the red metal-link check is not caused by this PR. The job fails while compiling upstream's metal/src/mtl_rt.mm (lines 69 and 92: MTLGPUFamilyMetal4, MTLCompileOptions.mathMode, MTLMathModeFast / MTLMathModeSafe), which the macos-14 runner's SDK does not provide. The workflow runs on any pull request that touches src/ or include/; this PR changes no file under metal/.


🔄 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/3821 **Author:** [@ruibeikaa](https://github.com/ruibeikaa) **Created:** 10/23/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `prefill-pipe-floor` --- ### 📝 Commits (1) - [`53054ff`](https://github.com/Niko1221/Strata/commit/53054ffe1786b28988da1f4cfbbbc694a5d7f4a0) prefill: STRATA_PREFILL_PIPE_FLOOR sets the smallest pipelined chunk (default 512, as before) ### 📊 Changes **1 file changed** (+12 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/prefill/prefill.cpp` (+12 -2) </details> ### 📄 Description ## Problem and result **Everything below was measured on four GP100 dies (two PH402 SKU 200 boards, 32 GB HBM2 per die, 128 GB in all) with every expert resident in VRAM: no CPU share, no PCIe share, no adaptive tier.** A rig that keeps experts in RAM or streams them over PCIe was not measured. HIP, SYCL and Metal were not built. `--prefill-pipe <b/a>` (#1441, in main as 125025a7) tries every chunk count from the fewest the buffers allow up to one chunk per 512 tokens, each chunk evened out on the 256-token grid and at least 512 tokens. On a rig with a small b/a - four GP100 dies with every expert in VRAM measure about 70 tokens - the cheapest split of a short prompt has chunks below 512 tokens, which that floor rules out: a 1.15K-token prompt is read in 512-token chunks through four stages. `STRATA_PREFILL_PIPE_FLOOR=<tokens>` sets that floor (rounded up to the 256-token grid, clamped to 256..4096). Unset, it is 512 and the rule picks the chunks it picks today. On four GP100 dies with b/a 70 and the floor at 256, a fresh 1.15K-token read went 4,310 -> 3,861 ms (-10.4%) and a 1.1K-token append to a 26K-token conversation 4,946 -> 4,461 ms (-9.8%); the other prompt reads kept their chunks and their times, and decode is unchanged. Bitwise identity is not kept where the chunks change, as with any other `--prefill-pipe` value: the prompt pass sums in another order. Of the 15 requests below, the two whose chunks changed have different engine state hashes, and one of their replies - the 16 tokens after the 1.1K-token append - differs from the unchanged engine's. ## Related discussion Follow-up to #1441: the same rule with one more knob, no default change. This branch is main plus one commit and needs none of my other PRs. The main e88ee39d run below was on a branch that also carried #3455, #3760, #3819, #3751 and #3820, all on in the arm before this one. ## Approach - `prefill.cpp`: `pipe_floor()` next to `pipe_value()`, read once. Both places in `pipeline_chunk` where 512 was written - the largest chunk count tried, `(n + 511) / 512`, and the smallest chunk, `max(512, ...)` - take it. The cost model, the 3% rule and `--prefill-pipe 1` are untouched. - With the floor at 512 the two expressions are the ones they replace, so the chunks are the same for every prompt length, buffer chunk, stage count and b/a. - Host code only. SYCL has its own `prefill.cpp` (untouched); HIP and Metal compile this one. ## Validation Rig: four GP100 dies (compute capability 6.0, application clocks 1050 MHz graphics / 715 MHz memory, 140 W cap), Windows 11, driver 581.80 (TCC), CUDA 12.9, VS 2022. Build `-DSTRATA_EXPERIMENTAL_SM60=ON -DCMAKE_CUDA_ARCHITECTURES=60`, ggml at the pinned 3cf03257f, unpatched. Model: Swift 1.5 IQ3_S (abliterated GSQ-RCO GGUF, dense matrices in Q8_0). **Passed:** - main e88ee39d (engine 0.1.45.3) plus my GP100 stack, one exe for every arm, one engine start per arm, greedy; a ladder in which each arm adds one switch to the arm before. Arm S5 = #3455, #3760, #3819, #3751 and #3820 on; arm S6 = S5 + `STRATA_PREFILL_PIPE_FLOOR=256`. - Engine arguments, the same in every arm: `--serve --expert-cache auto --prefill auto --spec 4 --spec-min-p 0.85 --mtp <drafter> --max-context 1048576 --kv int8 --layer-split 12,24,36 --mtp-window 8192 --pipeline-windows 3 --conversation-cache-mib 32768 --conversation-cache-slots 8 --rope-scaling yarn --rope-scale 4`. Environment, the same in every arm: `STRATA_PREFILL_PIPE=70` (b/a as measured on this rig) `STRATA_Q8_SM60=1 STRATA_STAGE_TRIM=1 STRATA_MMQ_RESIDENT_SORT_NE=1 STRATA_DF_BRANCH=1 STRATA_FUSE_DECODE=1 STRATA_FUSE_WAIT=2 STRATA_SIDE_MIXER=2 STRATA_GR_UP75=1 STRATA_B6_MMVQ_ROWS=1 STRATA_ADAPT_LAG=2 STRATA_ADAPT_NOWAIT=1 STRATA_DECODE_TIMING=1`. Each start's switches were checked in the engine process's environment. - Requests: five short prompts (77-82 tokens in, 400-512 out), a 9.8K-token document + 300 out, a fresh 26K-token read + 400 out and an 88K-token append to it (115K context) + 400 out - the eight benchmark prompts - then prompt reads of 240 / 1.15K / 7.7K / 33K tokens and a 26K-token conversation with a 1.1K-token append (16 out each). A parity pass with `STRATA_STATE_HASH=1` and a 250K-token read added (15 requests), and a timing pass without debug switches (14 requests). - Chunks (the engine's own lines): with the floor at 256 the 1.15K-token read and the 1.1K-token append ran in 256-token chunks (512 before). Every other read kept its chunks: 512 for 7.7K and 9.8K, 768 for 26K, 1024 for 33K, 1536 for the 88K append, 4096 for 250K, none for 240 tokens. - Prompt reads, S5 -> S6, timing pass / parity pass: 1.15K fresh 4,310 -> 3,861 / 4,329 -> 3,884 ms; 1.1K append 4,946 -> 4,461 / 5,012 -> 4,502 ms. The reads whose chunks did not change moved by -0.6..+0.0% in the timing pass. - Decode, eight prompts token-weighted: 56.39 -> 56.40 tok/s (timing pass). - Parity: 12 of the 15 requests equal to S5 in every reply hash and every `STRATA_STATE_HASH` item. The 1.15K read: the same reply; every state item except the PLE history differs. The 1.1K append: reply and state differ. The 250K read that came after them in the same engine: the same reply and main-model state; only the drafter's K/V hash (`mtp=`) differs (not investigated further). - Older tree (0.1.41-based, my GP100 branch of that time, not this revision): b/a 70, floor 512 against 256, two engine starts each in mirrored order (512, 256, 256, 512), prompt read ms: | Read | Floor 512 | Floor 256 | Change | |---|---:|---:|---:| | 1.16K fresh | 2,658 / 2,658 | 2,138 / 2,136 | -19.6% | | 2.5K fresh | 4,001 / 4,020 | 3,605 / 3,606 | -10.1% | | 4.5K fresh | 6,016 / 6,046 | 5,804 / 6,367 | +0.9% (one run faster, one slower) | | 8.9K fresh (512 chunks in both) | 10,525 / 10,540 | 10,549 / 11,165 | +3.1% (the same chunks; the second run slower) | | 317-token append | 1,559 / 1,549 | 1,428 / 1,430 | -8.0% | | 663-token append | 2,461 / 2,452 | 1,830 / 1,832 | -25.5% | | 1.19K append | 3,011 / 3,006 | 2,433 / 2,432 | -19.2% | | 2.5K append | 4,363 / 4,359 | 3,928 / 3,882 | -10.5% | In a separate hash check of the same eight reads (fresh engine starts), the two floor-256 runs gave the same replies, and one of the eight - the 1.19K append, whose chunks changed - differed from an arm at b/a 290 and floor 512. - This branch, rebased onto main 5c8dd322: sm_60 with `STRATA_EXPERIMENTAL_SM60=ON` (`strata`) and sm_86 without it (`strata`), both built without errors. **Failed:** - Bitwise identity with the unchanged engine on the requests whose chunks changed (expected, see above): one reply of 15 differs (the 1.1K-token append), and the state hashes of the two re-chunked requests differ. **Not run:** - HIP, SYCL and Metal builds (no such machine here). - A GPU run of this branch on main 5c8dd322: the numbers above are from the revisions named there; the rebased branch was only built. - Floors other than 256 on main; rigs with a larger b/a (there the rule rarely wants chunks below 512, so the floor should not matter - not measured). ## Limits - A floor below 512 helps only where b/a is small, i.e. where a chunk's fixed cost per stage is low against its per-token cost. - Changing the floor changes a short prompt's chunks and therefore its output bits, like changing `--prefill-pipe`. - The knob is not in docs/MULTI_GPU.md; that section's "at least 512" stays true by default. **CI note:** the red `metal-link` check is not caused by this PR. The job fails while compiling upstream's `metal/src/mtl_rt.mm` (lines 69 and 92: `MTLGPUFamilyMetal4`, `MTLCompileOptions.mathMode`, `MTLMathModeFast` / `MTLMathModeSafe`), which the `macos-14` runner's SDK does not provide. The workflow runs on any pull request that touches `src/` or `include/`; this PR changes no file under `metal/`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#4794
No description provided.