[PR #1253] [CLOSED] Enable serial multi-GPU batch MTP #3338

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1253
Author: @ilumn
Created: 10/6/2026
Status: ❌ Closed

Base: main ← Head: feat/multi-gpu-batch-mtp


📝 Commits (10+)

  • 8fc9490 Isolate concurrent multimodal positions and batch-MTP draft paths
  • 0de9365 Support serial split batch MTP with last-stage slot drafters
  • 4a0557f Merge upstream main into multimodal slot recovery
  • b87b45c Merge updated slot recovery and upstream main into split batch MTP
  • 96118a1 Add token-gated staggered batch and solo promotion regression
  • 97728fc Merge branch 'fix/pr1242-staggered' of ../Strata-pr1242-staggered into fix/pr1253-staggered
  • 08b39ba Require overlap after each staggered admission
  • c993d77 Merge branch 'fix/pr1242-staggered' of ../Strata-pr1242-staggered into fix/pr1253-staggered
  • 92d60a8 Cover sparse pipeline slot IDs and leading pad rows
  • 1a53f7f Merge branch 'fix/pr1242-staggered' of ../Strata-pr1242-staggered into fix/pr1253-staggered

📊 Changes

16 files changed (+1058 additions, -145 deletions)

View changed files

📝 CMakeLists.txt (+26 -0)
📝 docs/BATCHING.md (+55 -6)
📝 docs/MULTI_GPU.md (+12 -0)
📝 include/strata/core/mtp.hpp (+1 -4)
📝 include/strata/core/session.hpp (+4 -0)
📝 include/strata/kernels/mrope.hpp (+10 -0)
➕ include/strata/program/vision_records.hpp (+49 -0)
📝 src/core/mtp.cpp (+15 -1)
📝 src/core/verify.cpp (+39 -16)
📝 src/program/generate.cpp (+83 -39)
➕ tests/core/vision_records_test.cpp (+36 -0)
➕ tests/cuda/mrope_slot_graph_test.cpp (+90 -0)
➕ tools/batch_http_test.py (+189 -0)
➕ tools/batch_mtp_split_test.py (+145 -0)
📝 tools/batch_test.py (+229 -79)
➕ tools/test_batch_test.py (+75 -0)

📄 Description

This enables per-slot multi-token prediction (MTP) when the target model is split across CUDA GPUs. Previously, --layer-split 24 --batch 4 --batch-mtp disabled batch MTP and used ordinary batching. The enabled path verifies one proposal per slot through the stages serially, with --batch-groups 1, and commits the same accepted prefix on every stage.

A slot drafter needs the target model's final residual and output head, which reside on the last GPU in a layer split. Slot drafters now bind that GPU's weights and head, retain their residual buffers and draft-KV copies there, and use the first stage's PLE history. Each target stage supports eight-row verification windows with bounded graph caching. Allocations, idle waits and cleanup select the GPU that owns the corresponding buffers. Shared draft-vocabulary metadata supports the top-two diagnostic.

This depends on #1242, which isolates concurrent slots' image positions and corrects shared draft-head metadata. That dependency is included in this main-based PR. The serial multi-GPU feature commit is 0de9365f18a2ddcc7e428cc70a639ffcdfcc3b55 (7 files, 210 additions, 25 deletions), based on dependency commit 8fc9490e9cb62e4d3c3ab5f09c1ca8d42f4a8623; validation used main 82f46a8c8f475f001ad76d92f58f4a4f8ffb0253.

Validation on Talos

CUDA 13 / GNU 13.3 Release build, 2× RTX 5090 32 GiB, Swift IQ3_XXS, native Q5_K head, 106299-token draft subset, 8K allocated context, split 24, visible device order 1 then 0, 3 GiB reserve per GPU. Exactness controls: STRATA_IQ_MT_MIN=1 --pcie-frac 0 --adapt-every 1000000 --no-prefill-borrow. Requests generated up to 64 tokens; long prompt 1210 tokens. Independent review covered this serial implementation and its validation evidence.

Check Coverage Result
CUDA build, whitespace, Python syntax Full native build and new harness Pass
CPU regressions 27 checks Pass
Host native regressions 13 on GPU1, 3 on GPU0 Pass
Dual batch 2 / spec 2 Four speculative rows across both stages Exact solo parity
Five-slot rotation Eight-row windows, greedy and seed 1234 / temperature 0.7 / top_k 20 Exact solo parity
Q4 subset head, top-two --mtp-q4 head, STRATA_MTP_TOP2=1 Exact solo parity
Single-GPU regression Four-slot batch MTP Exact solo parity
Plain split/fallback Ordinary batching; groups 2 disable MTP with expected warning Exact solo parity
Staggered lifecycle Long admission, completed next turn, completed/cancelled slot → solo, reuse; greedy/seeded 7/7 each
Synthetic mixed images/text Different 4×6/6×4 grids, malformed admission, cancel/reuse; greedy/seeded 10/10
Real mixed images/text Existing CPU encoder, 11×5/5×11 grids, same lifecycle; greedy/seeded 10/10
Equivalent-mode performance 18 runs, 3 repetitions per mode/profile, identical per-stage cache counts and cross-mode tokens Pass

Speculative runs were checked for grouped-row captures and no disabled-option warning; lifecycle logs prove cache and turn-checkpoint restore paths ran.

Performance and limits

Four fixed prompts, 64 tokens each, same binary/settings, 3 repetitions per batch mode/profile. Rates below are median tokens/s. Normal MTP solo controls ran in each invocation; its rates separate decode from prompt reading. Batch overall includes admissions; the second batch rate starts at the first batch token and still includes overlapping admissions.

Experts per stage Normal MTP solo decode / with prefill Plain serial overall / from first batch token Plain pipeline overall / from first batch token Batch MTP overall / from first batch token
4000 70.9 / 55.8 55.6 / 59.5 61.0 / 66.2 54.7 / 58.7
11000 180.1 / 148.0 150.1 / 164.4 176.7 / 196.8 148.0 / 161.8

Batch MTP was slower than ordinary pipelined batching in both measured profiles. It adds opt-in compatibility for split models; the default is unchanged. These 64-token measurements do not establish long-context or sustained server-load performance.

Explicit fallbacks remain for --batch-groups > 1, same-device split stages, helper caches, remote expert optimization and peer devices. --pipeline-windows remains off with batch slots. Validated scope is two CUDA GPUs and the existing model/runtime above. HIP, more than two GPUs, more than five slots, worst-case context/memory pressure, other model formats and speculative pipeline groups are unrun. The existing idle split BYIELD path is outside this validation; the new harness checks supported staggered admission. Penalty sampling and coupled draft sampling were not validated.

With a compatible two-GPU model config, the included tools reproduce rotating batches and lifecycle checks:

CUDA_VISIBLE_DEVICES=1,0 python tools/batch_test.py --exe build/strata --config strata-model.json --batch 5 --n 5 --max-new 64 --extra "--batch-mtp --batch-groups 1 --layer-split 24 --trim-stage-weights --vision --pcie-frac 0 --adapt-every 1000000 --no-prefill-borrow"
CUDA_VISIBLE_DEVICES=1,0 python tools/batch_mtp_split_test.py --exe build/strata --config strata-model.json --keys "temperature=0.7 top_k=20 seed=1234" --extra "--batch-mtp --batch-groups 1 --layer-split 24 --trim-stage-weights --vision --pcie-frac 0 --adapt-every 1000000 --no-prefill-borrow --prompt-cache 4096"

Mixed-image/performance harnesses, exact local command records and logs are retained separately in the validation bundle.

Longer-run exactness investigation

A separate experimental implementation overlaps speculative slot groups across the GPU stages. Its 32-request workload at concurrency 4 and 512 generated tokens per request produced intermittent exact-token mismatches, including with overlap disabled while retaining the experiment's private verifier/drafter structure. Its benchmark matrix is paused. The cause and whether the published serial implementation is affected remain unresolved; the scoped results above do not establish long-run exactness for that experiment.

The existing QFUSE activation-quantization issue (#1139) was investigated as a possible explanation: batched GDN can consume stale quantized activations when STRATA_QFUSE=1. The QFUSE correction in the concurrent-generation PR (#1209) addresses that path, with runtime validation reported on gfx1151. The Talos CUDA diagnostic configurations leave QFUSE disabled, so this specific mechanism is inactive there. Other underlying causes remain under investigation.


🔄 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/1253 **Author:** [@ilumn](https://github.com/ilumn) **Created:** 10/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/multi-gpu-batch-mtp` --- ### 📝 Commits (10+) - [`8fc9490`](https://github.com/Niko1221/Strata/commit/8fc9490e9cb62e4d3c3ab5f09c1ca8d42f4a8623) Isolate concurrent multimodal positions and batch-MTP draft paths - [`0de9365`](https://github.com/Niko1221/Strata/commit/0de9365f18a2ddcc7e428cc70a639ffcdfcc3b55) Support serial split batch MTP with last-stage slot drafters - [`4a0557f`](https://github.com/Niko1221/Strata/commit/4a0557ff3a96924ebbd50922996534f41d69f5ac) Merge upstream main into multimodal slot recovery - [`b87b45c`](https://github.com/Niko1221/Strata/commit/b87b45c723caa6d1dd945cf172315100a7e34276) Merge updated slot recovery and upstream main into split batch MTP - [`96118a1`](https://github.com/Niko1221/Strata/commit/96118a19c7e626e2384144a6a65a71d07cec75b1) Add token-gated staggered batch and solo promotion regression - [`97728fc`](https://github.com/Niko1221/Strata/commit/97728fcede080d0c80c861edfaac15d5144b330a) Merge branch 'fix/pr1242-staggered' of ../Strata-pr1242-staggered into fix/pr1253-staggered - [`08b39ba`](https://github.com/Niko1221/Strata/commit/08b39ba0b8630616567947f01a96a047a5051952) Require overlap after each staggered admission - [`c993d77`](https://github.com/Niko1221/Strata/commit/c993d772da7c0b0906a203d46d974802d3ee7bc2) Merge branch 'fix/pr1242-staggered' of ../Strata-pr1242-staggered into fix/pr1253-staggered - [`92d60a8`](https://github.com/Niko1221/Strata/commit/92d60a860f754f998bf13648879ebed3b85c3cda) Cover sparse pipeline slot IDs and leading pad rows - [`1a53f7f`](https://github.com/Niko1221/Strata/commit/1a53f7f0a4344bb34f38eebf608a08e8a6c5586d) Merge branch 'fix/pr1242-staggered' of ../Strata-pr1242-staggered into fix/pr1253-staggered ### 📊 Changes **16 files changed** (+1058 additions, -145 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+26 -0) 📝 `docs/BATCHING.md` (+55 -6) 📝 `docs/MULTI_GPU.md` (+12 -0) 📝 `include/strata/core/mtp.hpp` (+1 -4) 📝 `include/strata/core/session.hpp` (+4 -0) 📝 `include/strata/kernels/mrope.hpp` (+10 -0) ➕ `include/strata/program/vision_records.hpp` (+49 -0) 📝 `src/core/mtp.cpp` (+15 -1) 📝 `src/core/verify.cpp` (+39 -16) 📝 `src/program/generate.cpp` (+83 -39) ➕ `tests/core/vision_records_test.cpp` (+36 -0) ➕ `tests/cuda/mrope_slot_graph_test.cpp` (+90 -0) ➕ `tools/batch_http_test.py` (+189 -0) ➕ `tools/batch_mtp_split_test.py` (+145 -0) 📝 `tools/batch_test.py` (+229 -79) ➕ `tools/test_batch_test.py` (+75 -0) </details> ### 📄 Description This enables per-slot multi-token prediction (MTP) when the target model is split across CUDA GPUs. Previously, `--layer-split 24 --batch 4 --batch-mtp` disabled batch MTP and used ordinary batching. The enabled path verifies one proposal per slot through the stages serially, with `--batch-groups 1`, and commits the same accepted prefix on every stage. A slot drafter needs the target model's final residual and output head, which reside on the last GPU in a layer split. Slot drafters now bind that GPU's weights and head, retain their residual buffers and draft-KV copies there, and use the first stage's PLE history. Each target stage supports eight-row verification windows with bounded graph caching. Allocations, idle waits and cleanup select the GPU that owns the corresponding buffers. Shared draft-vocabulary metadata supports the top-two diagnostic. This depends on [#1242](https://github.com/Niko1221/Strata/pull/1242), which isolates concurrent slots' image positions and corrects shared draft-head metadata. That dependency is included in this main-based PR. The serial multi-GPU feature commit is `0de9365f18a2ddcc7e428cc70a639ffcdfcc3b55` (7 files, 210 additions, 25 deletions), based on dependency commit `8fc9490e9cb62e4d3c3ab5f09c1ca8d42f4a8623`; validation used main `82f46a8c8f475f001ad76d92f58f4a4f8ffb0253`. ## Validation on Talos CUDA 13 / GNU 13.3 Release build, 2× RTX 5090 32 GiB, Swift IQ3_XXS, native Q5_K head, 106299-token draft subset, 8K allocated context, split 24, visible device order 1 then 0, 3 GiB reserve per GPU. Exactness controls: `STRATA_IQ_MT_MIN=1 --pcie-frac 0 --adapt-every 1000000 --no-prefill-borrow`. Requests generated up to 64 tokens; long prompt 1210 tokens. Independent review covered this serial implementation and its validation evidence. | Check | Coverage | Result | |---|---|---| | CUDA build, whitespace, Python syntax | Full native build and new harness | Pass | | CPU regressions | 27 checks | Pass | | Host native regressions | 13 on GPU1, 3 on GPU0 | Pass | | Dual batch 2 / spec 2 | Four speculative rows across both stages | Exact solo parity | | Five-slot rotation | Eight-row windows, greedy and seed 1234 / temperature 0.7 / top_k 20 | Exact solo parity | | Q4 subset head, top-two | `--mtp-q4 head`, `STRATA_MTP_TOP2=1` | Exact solo parity | | Single-GPU regression | Four-slot batch MTP | Exact solo parity | | Plain split/fallback | Ordinary batching; groups 2 disable MTP with expected warning | Exact solo parity | | Staggered lifecycle | Long admission, completed next turn, completed/cancelled slot → solo, reuse; greedy/seeded | 7/7 each | | Synthetic mixed images/text | Different 4×6/6×4 grids, malformed admission, cancel/reuse; greedy/seeded | 10/10 | | Real mixed images/text | Existing CPU encoder, 11×5/5×11 grids, same lifecycle; greedy/seeded | 10/10 | | Equivalent-mode performance | 18 runs, 3 repetitions per mode/profile, identical per-stage cache counts and cross-mode tokens | Pass | Speculative runs were checked for grouped-row captures and no disabled-option warning; lifecycle logs prove cache and turn-checkpoint restore paths ran. ## Performance and limits Four fixed prompts, 64 tokens each, same binary/settings, 3 repetitions per batch mode/profile. Rates below are median tokens/s. Normal MTP solo controls ran in each invocation; its rates separate decode from prompt reading. Batch overall includes admissions; the second batch rate starts at the first batch token and still includes overlapping admissions. | Experts per stage | Normal MTP solo decode / with prefill | Plain serial overall / from first batch token | Plain pipeline overall / from first batch token | Batch MTP overall / from first batch token | |---|---|---|---|---| | 4000 | 70.9 / 55.8 | 55.6 / 59.5 | 61.0 / 66.2 | 54.7 / 58.7 | | 11000 | 180.1 / 148.0 | 150.1 / 164.4 | 176.7 / 196.8 | 148.0 / 161.8 | Batch MTP was slower than ordinary pipelined batching in both measured profiles. It adds opt-in compatibility for split models; the default is unchanged. These 64-token measurements do not establish long-context or sustained server-load performance. Explicit fallbacks remain for `--batch-groups > 1`, same-device split stages, helper caches, remote expert optimization and peer devices. `--pipeline-windows` remains off with batch slots. Validated scope is two CUDA GPUs and the existing model/runtime above. HIP, more than two GPUs, more than five slots, worst-case context/memory pressure, other model formats and speculative pipeline groups are unrun. The existing idle split BYIELD path is outside this validation; the new harness checks supported staggered admission. Penalty sampling and coupled draft sampling were not validated. With a compatible two-GPU model config, the included tools reproduce rotating batches and lifecycle checks: ```bash CUDA_VISIBLE_DEVICES=1,0 python tools/batch_test.py --exe build/strata --config strata-model.json --batch 5 --n 5 --max-new 64 --extra "--batch-mtp --batch-groups 1 --layer-split 24 --trim-stage-weights --vision --pcie-frac 0 --adapt-every 1000000 --no-prefill-borrow" CUDA_VISIBLE_DEVICES=1,0 python tools/batch_mtp_split_test.py --exe build/strata --config strata-model.json --keys "temperature=0.7 top_k=20 seed=1234" --extra "--batch-mtp --batch-groups 1 --layer-split 24 --trim-stage-weights --vision --pcie-frac 0 --adapt-every 1000000 --no-prefill-borrow --prompt-cache 4096" ``` Mixed-image/performance harnesses, exact local command records and logs are retained separately in the validation bundle. ## Longer-run exactness investigation A separate experimental implementation overlaps speculative slot groups across the GPU stages. Its 32-request workload at concurrency 4 and 512 generated tokens per request produced intermittent exact-token mismatches, including with overlap disabled while retaining the experiment's private verifier/drafter structure. Its benchmark matrix is paused. The cause and whether the published serial implementation is affected remain unresolved; the scoped results above do not establish long-run exactness for that experiment. The existing [QFUSE activation-quantization issue (#1139)](https://github.com/Niko1221/Strata/issues/1139) was investigated as a possible explanation: batched GDN can consume stale quantized activations when `STRATA_QFUSE=1`. The [QFUSE correction in the concurrent-generation PR (#1209)](https://github.com/Niko1221/Strata/pull/1209) addresses that path, with [runtime validation reported on gfx1151](https://github.com/Niko1221/Strata/issues/1139#issuecomment-6025611893). The Talos CUDA diagnostic configurations leave QFUSE disabled, so this specific mechanism is inactive there. Other underlying causes remain under investigation. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:40:46 +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#3338
No description provided.