[PR #1599] [CLOSED] split: batch the draft layer's prompt K/V on a layer split, +3 to 8% prompt speed (opt-in) #3554

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1599
Author: @noon-at-cgn
Created: 10/8/2026
Status: ❌ Closed

Base: main ← Head: pr/split-mtp-batch


📝 Commits (2)

  • 763faae split: batched draft-layer prompt K/V on the last stage (STRATA_SPLIT_MTP_BATCH=1, opt-in)
  • 3d57d0c docs: replace the evidence placeholder in the split MTP-batch paragraph with the measured result

📊 Changes

9 files changed (+269 additions, -20 deletions)

View changed files

📝 CMakeLists.txt (+4 -0)
📝 docs/MULTI_GPU.md (+22 -0)
📝 include/strata/prefill/prefill.hpp (+2 -1)
➕ include/strata/program/draft_kv_plan.hpp (+44 -0)
📝 src/prefill/prefill.cpp (+14 -8)
➕ src/program/draft_kv_plan_test.cpp (+62 -0)
📝 src/program/generate.cpp (+26 -2)
📝 sycl/src/prefill/prefill.cpp (+14 -9)
➕ tools/split_mtp_batch_parity.py (+81 -0)

📄 Description

Title

Issue: Related: none found (searched open PRs 2026-10-08; closed #453 added E-9 for a ring K/V on one GPU).

Summary

Why it matters: on a layer split, every prompt chunk ends with the draft layer's own pass, which blocks the pipeline (0.9-1.3 s per request in the host's "after each chunk" time). One GPU already avoids that with the batched E-9 pass (Prefill::draft_kv), but generate.cpp only calls it when !multi_gpu. With STRATA_SPLIT_MTP_BATCH=1 the last stage runs E-9 too: that time drops to 0.1-0.25 s, and long prompts read faster with the same greedy output.

2x RTX 3080, layer split 23, pooled medians, 2 restarts per arm env off env on
prompt read 25k tokens 1996 tok/s 2129 (+6.7%)
51k 2448 2553 (+4.3%)
104k 2846 2940 (+3.3%)
greedy output, 6 prompts (5 x 256 tokens + one 25.5k prompt) - identical, 6/6 in all five comparisons, A/A included
drafts accepted 826 of 1210 (68.3%) 826 of 1210

Default off; the default path is unchanged.

What changed

  • src/program/generate.cpp: on_chunk asks draft_kv_plan::plan() which path to try; on a split with the variable on it calls draft_kv on the drafter's stage. One log line per process says what the variable did.
  • include/strata/program/draft_kv_plan.hpp (new): the choice as a pure function. src/program/draft_kv_plan_test.cpp + CMakeLists.txt: CPU test (18 checks).
  • src/prefill/prefill.cpp, include/strata/prefill/prefill.hpp, sycl/src/prefill/prefill.cpp: draft_kv makes the stage's device current and takes an optional why that names the reason when it declines.
  • tools/split_mtp_batch_parity.py (new), docs/MULTI_GPU.md: one paragraph.

Extra Notes

Measured on engine 0.1.40.3 (d5ea713) plus this change; the branch itself is cut from main fb58e0d.
Machine: 2x RTX 3080 20 GB (220 W), Xeon E5-2696 v4, UD-Q4_K_XL, --batch-mtp, 2 slots, --prefill auto:16384. Same binary in both arms, only the env differs; full restarts in the order off/on/off/on. All 8 on/off prompt-read ratios are above 1 (1.03 to 1.08); the two off restarts differ by at most 2% at 25k and 0.3% elsewhere. Parity ran with --adapt-every 0 --suffix-draft 0 (with the adaptive tier on, greedy output is not repeatable across restarts).
Open question, stated plainly: decode is not shown to be unchanged. The on medians are about 3% lower in both pairs (pooled solo 82.6 -> 80.2 tok/s, c2 93.2 -> 90.8), but the restart-to-restart control moves up to 4.7% and no mechanism is known (the patch touches only the prompt path). With two restarts per arm it can be neither confirmed nor excluded.
The drafter's K/V come from Q8_1 x Q8_0 MMQ instead of its own mmvq, so they are not bit-identical; no acceptance difference was visible at this n. Needs a --native pack, otherwise it logs why and keeps the old pass. Checked: draft_kv_plan_test, CUDA build. Not built: HIP, SYCL (only the new parameter). Not tested: AMD, three or more cards, without --batch-mtp, the decline path.
Context: this change is part of the setup measured in the community benchmark #1640.


🔄 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/1599 **Author:** [@noon-at-cgn](https://github.com/noon-at-cgn) **Created:** 10/8/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/split-mtp-batch` --- ### 📝 Commits (2) - [`763faae`](https://github.com/Niko1221/Strata/commit/763faae32d5c169d47e130c7862826892f7dba1e) split: batched draft-layer prompt K/V on the last stage (STRATA_SPLIT_MTP_BATCH=1, opt-in) - [`3d57d0c`](https://github.com/Niko1221/Strata/commit/3d57d0c0ce215e0e3339446d528d5db9e027a08c) docs: replace the evidence placeholder in the split MTP-batch paragraph with the measured result ### 📊 Changes **9 files changed** (+269 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+4 -0) 📝 `docs/MULTI_GPU.md` (+22 -0) 📝 `include/strata/prefill/prefill.hpp` (+2 -1) ➕ `include/strata/program/draft_kv_plan.hpp` (+44 -0) 📝 `src/prefill/prefill.cpp` (+14 -8) ➕ `src/program/draft_kv_plan_test.cpp` (+62 -0) 📝 `src/program/generate.cpp` (+26 -2) 📝 `sycl/src/prefill/prefill.cpp` (+14 -9) ➕ `tools/split_mtp_batch_parity.py` (+81 -0) </details> ### 📄 Description ## Title Issue: Related: none found (searched open PRs 2026-10-08; closed #453 added E-9 for a ring K/V on one GPU). ## Summary **Why it matters:** on a layer split, every prompt chunk ends with the draft layer's own pass, which blocks the pipeline (0.9-1.3 s per request in the host's "after each chunk" time). One GPU already avoids that with the batched E-9 pass (`Prefill::draft_kv`), but `generate.cpp` only calls it when `!multi_gpu`. With `STRATA_SPLIT_MTP_BATCH=1` the last stage runs E-9 too: that time drops to 0.1-0.25 s, and long prompts read faster with the same greedy output. | 2x RTX 3080, layer split 23, pooled medians, 2 restarts per arm | env off | env on | |---|---|---| | prompt read 25k tokens | 1996 tok/s | 2129 (+6.7%) | | 51k | 2448 | 2553 (+4.3%) | | 104k | 2846 | 2940 (+3.3%) | | greedy output, 6 prompts (5 x 256 tokens + one 25.5k prompt) | - | identical, 6/6 in all five comparisons, A/A included | | drafts accepted | 826 of 1210 (68.3%) | 826 of 1210 | Default off; the default path is unchanged. ## What changed - `src/program/generate.cpp`: `on_chunk` asks `draft_kv_plan::plan()` which path to try; on a split with the variable on it calls `draft_kv` on the drafter's stage. One log line per process says what the variable did. - `include/strata/program/draft_kv_plan.hpp` (new): the choice as a pure function. `src/program/draft_kv_plan_test.cpp` + `CMakeLists.txt`: CPU test (18 checks). - `src/prefill/prefill.cpp`, `include/strata/prefill/prefill.hpp`, `sycl/src/prefill/prefill.cpp`: `draft_kv` makes the stage's device current and takes an optional `why` that names the reason when it declines. - `tools/split_mtp_batch_parity.py` (new), `docs/MULTI_GPU.md`: one paragraph. ## Extra Notes Measured on engine 0.1.40.3 (d5ea713) plus this change; the branch itself is cut from main fb58e0d. Machine: 2x RTX 3080 20 GB (220 W), Xeon E5-2696 v4, UD-Q4_K_XL, `--batch-mtp`, 2 slots, `--prefill auto:16384`. Same binary in both arms, only the env differs; full restarts in the order off/on/off/on. All 8 on/off prompt-read ratios are above 1 (1.03 to 1.08); the two off restarts differ by at most 2% at 25k and 0.3% elsewhere. Parity ran with `--adapt-every 0 --suffix-draft 0` (with the adaptive tier on, greedy output is not repeatable across restarts). **Open question, stated plainly:** decode is not shown to be unchanged. The on medians are about 3% lower in both pairs (pooled solo 82.6 -> 80.2 tok/s, c2 93.2 -> 90.8), but the restart-to-restart control moves up to 4.7% and no mechanism is known (the patch touches only the prompt path). With two restarts per arm it can be neither confirmed nor excluded. The drafter's K/V come from Q8_1 x Q8_0 MMQ instead of its own mmvq, so they are not bit-identical; no acceptance difference was visible at this n. Needs a `--native` pack, otherwise it logs why and keeps the old pass. Checked: `draft_kv_plan_test`, CUDA build. Not built: HIP, SYCL (only the new parameter). Not tested: AMD, three or more cards, without `--batch-mtp`, the decline path. Context: this change is part of the setup measured in the community benchmark #1640. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:42:18 +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#3554
No description provided.