[PR #4966] [Engine] Opt-in solo/batch MTP switching with physical single-GPU controls #5269

Open
opened 2026-11-07 16:33:57 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4966
Author: @cennac
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/mtp-single-batch-transition-20261102


📝 Commits (3)

  • b8603b4 增加双阶段流水的可选惩罚历史传递与边界测试
  • 4398ff2 增加MTP单卡验证与双卡请求切换实验开关
  • 2deb363 记录MTP实机验证与输出一致性限制

📊 Changes

9 files changed (+625 additions, -3 deletions)

View changed files

📝 CMakeLists.txt (+9 -0)
➕ docs/MTP_SWITCHING.md (+133 -0)
📝 docs/MULTI_GPU.md (+16 -1)
➕ include/strata/program/pipeline_batch.hpp (+33 -0)
📝 src/program/generate.cpp (+62 -2)
➕ src/program/pipeline_batch_test.cpp (+56 -0)
➕ src/program/pipeline_penalties_test.cpp (+66 -0)
➕ tools/bench_mtp_switch.py (+158 -0)
➕ tools/test_bench_mtp_switch.py (+92 -0)

📄 Description

Problem and result

With --batch 4 --batch-groups 2, a lone request on the dual-GPU service lost its solo pipeline windows and fell back to the serial path. This change adds a bounded opt-in so the supported two-stage topology can keep solo pipeline windows when no batch request is admitted, while preserving the existing batch-MTP path for concurrent requests. The default remains unchanged. The tested integration does not reproduce the complete optimized RDNA3 backend; that limitation is documented below.

This work follows the existing mechanisms in #3095 and #4121, and uses the pending per-window penalty-history work in #4909. No default behavior is changed.

Approach

Enable the solo/batch exception only for two layer stages, four internal slots, two groups, two pipeline windows, piped MTP and --spec >= 3. Admissions and prompt reads that could conflict with active batch slots stay on the serial verifier. Allocation and topology checks disable the exception when the required layout is unavailable. Physical single-GPU controls are measurement controls for the existing implementation.

Validation

Passed: HIP/gfx1100 build and host tests for pipeline batches, penalties and groups; Windows CUDA-header compilation; HTTP/SSE protocol fixtures; 34 HIP request completions with the 1-to-2-to-1 transition observed; original service/config/power/fan settings restored and verified.
Failed: Paired rendered-text equality was only 3/14; the cause is unresolved, so this is not presented as lossless acceleration.
Not run: SYCL runtime, NVIDIA execution, sampled decoding, other models/quantizations, four simultaneous clients, and a complete port of the custom RDNA3 backend optimizations.

Limits

The measured rates are HTTP end-to-end observations, not a quality or token/logit parity proof. The custom RDNA3 source has backend paths that are outside this integration and remains the performance reference. Output parity and the remaining backend checks are unresolved; the measured requests do not establish merge readiness.

With --batch 4 --batch-groups 2, a lone request loses solo pipeline windows even when the dual-GPU service has no other active client. Model-card penalties can separately force the serial path. This dependent integration adds an explicit, bounded opt-in for solo pipeline / batch-MTP coexistence, plus a physical single-GPU control and request-sequence measurement tool.

Scope: this is a request-path switching integration, not the complete optimized RDNA3 backend port. It does not reproduce the custom build's best performance. The deployed optimized build remains in use; this PR is not its replacement.

Output equality is unresolved. Only 3/14 corresponding rendered-text hashes match between the dual arms. The opt-out control itself also varies before the final solo phase. HTTP completion and speed measurements do not establish lossless acceleration.

Behavior and scope

STRATA_HYBRID_WINDOWS=1 keeps solo pipeline windows for exactly two layer stages, four slots, two explicitly selected groups, --pipeline-windows 2, batch MTP, --spec >= 3, and STRATA_PIPED_MTP=2, with async adaptation off. Allocation/validation that reduces that topology disables the exception again. The setting is off by default.

After diagnostic overrides, BGEN admissions and prompt reads beside active slots cannot enter the solo pipeline, including admission before the first batch slot is active. Existing pipeline drain and slot-copy paths handle committed state. The batch MTP drafter stays on the last card. Physical single-GPU MTP is an existing implementation and is unchanged; this contribution supplies separate controls for both physical cards rather than calling a dual-GPU solo request “single GPU”.

  • #3095 supplies the related solo-pipeline/batch coexistence mechanism, including first-card drafter placement. This experiment limits the topology, retains last-card placement and adds the per-request admission guard.
  • #4121 describes pipelined-group MTP. The current base already contains that mechanism; this PR reuses it rather than claiming another MTP algorithm.
  • This branch includes pending #4909 (b8603b46) for exact per-window penalty histories. That patch remains independently reviewable. Once it lands, its dependent commit can be dropped from this diff.

Validation

Tested engine code: 4398ff2e8ee44768104587585a5ce6a7e77e99d3, upstream base c62d5e3a15b40ea51c96aae9e8d36928965f53ab. Later documentation changes do not change the tested engine files. Binary/source hashes, commands, sanitized configs, individual requests, cold runs and structural engine excerpts are in the immutable evidence archive.

Passed:

  • Complete HIP/gfx1100 engine build, all kernel/static targets rebuilt from source, ROCm10 and GCC 15.2. Fixed llama.cpp 3cf03257f219afbe7334045ff7c6a06ac68c627d and rocWMMA source dependencies; no old engine objects reused.
  • pipeline_batch_test, pipeline_penalties_test, batch_groups_test on Linux/GCC and Windows/MSVC. The admission test covers GEN → first admission with no active slot → active batch → GEN, diagnostic override precedence, unsupported topologies and opt-out behavior.
  • CUDA-header host compilation of the changed generate.cpp on Windows/MSVC, CUDA 12.1 headers. This alone is not a complete CUDA build.
  • python tools/test_bench_mtp_switch.py: three HTTP/SSE protocol fixtures, including partial-stream failure and missing token usage; no GPU measurements are attributed to these fixtures.
  • HIP request-level smoke test: 34 HTTP requests completed; both dual arms observed the staggered 1→2→1 stream sequence. The original service was restored; original config hash, power caps and fan modes were unchanged. No thermal/memory guard was triggered.
  • Complete CUDA 13.1 / sm_75 engine build in a fresh build directory. No NVIDIA GPU execution. Initial configuration and launch-permission failures are retained separately; the corrected final build passed.

Failed / unresolved:

  • Paired rendered-text equality: 3/14 matches. All three final solo-after comparisons match; earlier solo, batch and staggered comparisons do not. The cause is not isolated. Per-request hashes and the control's internal variability are retained. No token/logit parity or quality-equivalence claim is made.

Not run:

  • SYCL build/runtime, NVIDIA GPU execution, default-output parity against a separately built unpatched main, sampled decoding, other model/quantization/context workloads, four simultaneous clients.

Observed rates, not a lossless speedup claim

Same binary and public 130,020-token prompt, 512 output tokens (128 for the short staggered request), context capacity 131,072, greedy API settings, seed 42, reasoning disabled, retained warm cache. Values are medians of HTTP end-to-end completion-token rates; first cold runs remain in the archive and are excluded here.

Layout Warm solo after switching, 3 runs Two requests, aggregate, 3 pairs
Dual GPU, hybrid/history opt-ins off, piped MTP on 56.34 t/s 134.05 t/s
Same dual GPU, hybrid/history opt-ins on 93.01 t/s 136.18 t/s

Separate existing single-GPU MTP controls: GPU 0 69.54 t/s, GPU 1 60.08 t/s, medians of two warm runs each, with their cold requests retained. These require a 4 GiB conversation cache instead of the dual service's 16 GiB and a 12 GiB host-registration cap. Power limits were retained at 303 W and 231 W; this is not a stock blower/platinum comparison. Automatic expert-cache sizing can also change with the pipeline's extra verifier/snapshot reserve. Different generated text can change MTP acceptance, so these observations do not isolate a quality-preserving speed gain.

Use docs/MTP_SWITCHING.md and tools/bench_mtp_switch.py for the controls and sequence. Parity investigation and the remaining backend checks are still required before merge. Historical custom-tree 116/161 t/s records belong to that separate build, not this submitted integration.

Same-day optimized-production control and missing backend paths

The appended raw control evidence runs both saved measurement scripts on the unchanged optimized production service. Both original and appended evidence are retained.

Stack and workload Warm solo Two requests, aggregate
Optimized production, original benchmark 114.58 t/s 153.63 t/s
Optimized production, this PR's switching benchmark 134.11 t/s 164.35 t/s
This mainline integration, earlier opt-in run with the same switching benchmark 93.01 t/s 136.18 t/s

The switching rows use the medians of three solo-after requests and three synchronized pairs, HTTP end-to-end, actual 130,020-token input and 512 output tokens. Production solo-after samples were 114.48/134.11/134.27; dual pairs were 164.31/168.33/164.35. The original script uses a three-run solo mean and continuous dual throughput over 33.33 seconds, with two distinct prompts rather than the switching script's shared prompt. These scripts must not be treated as identical workloads.

The two stacks have different engine/server revisions; production retained GPU vision while the isolated candidate dual arms disabled it. This was a same-day sequential control, not a randomized kernel ablation. Output differences can also change MTP acceptance. Both scripts completed; the original marker checks passed; production configuration, power caps and fan modes were unchanged. Hotspot peaks were 77/82 C and minimum available RAM was 16.42 GiB. These checks do not resolve the candidate's output-equality failure above.

Source inspection found that the submitted tree does not include the custom rdna_gr.cu compilation unit or its RDNA GR/Q8/A8/inject/fused control paths. It also does not implement the custom STRATA_RDNA_MMVQ_WAVE and STRATA_WAIT_FUSE controls. Those variables remain in the candidate configuration but cannot restore absent implementations. The per-path explanation of the speed gap remains unconfirmed static analysis until controlled ports/ablations; no per-kernel contribution percentage is claimed.

The complete custom source is already public with its existing history and attribution. It is the performance/reproduction reference, not the code submitted by this PR. Porting its backend changes requires separately reviewable patches and same-workload correctness/performance checks. This PR stays focused on switching; output parity and the remaining backend checks are still unresolved.


🔄 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/4966 **Author:** [@cennac](https://github.com/cennac) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/mtp-single-batch-transition-20261102` --- ### 📝 Commits (3) - [`b8603b4`](https://github.com/Niko1221/Strata/commit/b8603b46d758ff5fc452656e4ec9f63c0c4a1b0c) 增加双阶段流水的可选惩罚历史传递与边界测试 - [`4398ff2`](https://github.com/Niko1221/Strata/commit/4398ff2e8ee44768104587585a5ce6a7e77e99d3) 增加MTP单卡验证与双卡请求切换实验开关 - [`2deb363`](https://github.com/Niko1221/Strata/commit/2deb363b83e33a6a0c6e5f25dd262a6180f5df45) 记录MTP实机验证与输出一致性限制 ### 📊 Changes **9 files changed** (+625 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+9 -0) ➕ `docs/MTP_SWITCHING.md` (+133 -0) 📝 `docs/MULTI_GPU.md` (+16 -1) ➕ `include/strata/program/pipeline_batch.hpp` (+33 -0) 📝 `src/program/generate.cpp` (+62 -2) ➕ `src/program/pipeline_batch_test.cpp` (+56 -0) ➕ `src/program/pipeline_penalties_test.cpp` (+66 -0) ➕ `tools/bench_mtp_switch.py` (+158 -0) ➕ `tools/test_bench_mtp_switch.py` (+92 -0) </details> ### 📄 Description ## Problem and result With `--batch 4 --batch-groups 2`, a lone request on the dual-GPU service lost its solo pipeline windows and fell back to the serial path. This change adds a bounded opt-in so the supported two-stage topology can keep solo pipeline windows when no batch request is admitted, while preserving the existing batch-MTP path for concurrent requests. The default remains unchanged. The tested integration does not reproduce the complete optimized RDNA3 backend; that limitation is documented below. ## Related discussion This work follows the existing mechanisms in [#3095](https://github.com/Niko1221/Strata/pull/3095) and [#4121](https://github.com/Niko1221/Strata/pull/4121), and uses the pending per-window penalty-history work in [#4909](https://github.com/Niko1221/Strata/pull/4909). No default behavior is changed. ## Approach Enable the solo/batch exception only for two layer stages, four internal slots, two groups, two pipeline windows, piped MTP and `--spec >= 3`. Admissions and prompt reads that could conflict with active batch slots stay on the serial verifier. Allocation and topology checks disable the exception when the required layout is unavailable. Physical single-GPU controls are measurement controls for the existing implementation. ## Validation Passed: HIP/gfx1100 build and host tests for pipeline batches, penalties and groups; Windows CUDA-header compilation; HTTP/SSE protocol fixtures; 34 HIP request completions with the 1-to-2-to-1 transition observed; original service/config/power/fan settings restored and verified. Failed: Paired rendered-text equality was only 3/14; the cause is unresolved, so this is not presented as lossless acceleration. Not run: SYCL runtime, NVIDIA execution, sampled decoding, other models/quantizations, four simultaneous clients, and a complete port of the custom RDNA3 backend optimizations. ## Limits The measured rates are HTTP end-to-end observations, not a quality or token/logit parity proof. The custom RDNA3 source has backend paths that are outside this integration and remains the performance reference. Output parity and the remaining backend checks are unresolved; the measured requests do not establish merge readiness. With `--batch 4 --batch-groups 2`, a lone request loses solo pipeline windows even when the dual-GPU service has no other active client. Model-card penalties can separately force the serial path. This dependent integration adds an explicit, bounded opt-in for solo pipeline / batch-MTP coexistence, plus a physical single-GPU control and request-sequence measurement tool. **Scope: this is a request-path switching integration, not the complete optimized RDNA3 backend port. It does not reproduce the custom build's best performance. The deployed optimized build remains in use; this PR is not its replacement.** **Output equality is unresolved. Only 3/14 corresponding rendered-text hashes match between the dual arms. The opt-out control itself also varies before the final solo phase. HTTP completion and speed measurements do not establish lossless acceleration.** ### Behavior and scope `STRATA_HYBRID_WINDOWS=1` keeps solo pipeline windows for exactly two layer stages, four slots, two explicitly selected groups, `--pipeline-windows 2`, batch MTP, `--spec >= 3`, and `STRATA_PIPED_MTP=2`, with async adaptation off. Allocation/validation that reduces that topology disables the exception again. The setting is off by default. After diagnostic overrides, BGEN admissions and prompt reads beside active slots cannot enter the solo pipeline, including admission before the first batch slot is active. Existing pipeline drain and slot-copy paths handle committed state. The batch MTP drafter stays on the last card. Physical single-GPU MTP is an existing implementation and is unchanged; this contribution supplies separate controls for both physical cards rather than calling a dual-GPU solo request “single GPU”. ### Related work and dependency - #3095 supplies the related solo-pipeline/batch coexistence mechanism, including first-card drafter placement. This experiment limits the topology, retains last-card placement and adds the per-request admission guard. - #4121 describes pipelined-group MTP. The current base already contains that mechanism; this PR reuses it rather than claiming another MTP algorithm. - This branch includes pending #4909 (`b8603b46`) for exact per-window penalty histories. That patch remains independently reviewable. Once it lands, its dependent commit can be dropped from this diff. ### Validation Tested engine code: `4398ff2e8ee44768104587585a5ce6a7e77e99d3`, upstream base `c62d5e3a15b40ea51c96aae9e8d36928965f53ab`. Later documentation changes do not change the tested engine files. Binary/source hashes, commands, sanitized configs, individual requests, cold runs and structural engine excerpts are in the [immutable evidence archive](https://github.com/cennac/Strata/tree/078146edb81c809722884e8e21dcc98e41fba4ed/bench/results/2026-11-02-community-dual-rx7900xtx-mtp-switch). Passed: - Complete HIP/gfx1100 engine build, all kernel/static targets rebuilt from source, ROCm10 and GCC 15.2. Fixed llama.cpp `3cf03257f219afbe7334045ff7c6a06ac68c627d` and rocWMMA source dependencies; no old engine objects reused. - `pipeline_batch_test`, `pipeline_penalties_test`, `batch_groups_test` on Linux/GCC and Windows/MSVC. The admission test covers GEN → first admission with no active slot → active batch → GEN, diagnostic override precedence, unsupported topologies and opt-out behavior. - CUDA-header host compilation of the changed `generate.cpp` on Windows/MSVC, CUDA 12.1 headers. This alone is not a complete CUDA build. - `python tools/test_bench_mtp_switch.py`: three HTTP/SSE protocol fixtures, including partial-stream failure and missing token usage; no GPU measurements are attributed to these fixtures. - HIP request-level smoke test: 34 HTTP requests completed; both dual arms observed the staggered 1→2→1 stream sequence. The original service was restored; original config hash, power caps and fan modes were unchanged. No thermal/memory guard was triggered. - Complete CUDA 13.1 / sm_75 engine build in a fresh build directory. No NVIDIA GPU execution. Initial configuration and launch-permission failures are retained separately; the corrected final build passed. Failed / unresolved: - Paired rendered-text equality: 3/14 matches. All three final solo-after comparisons match; earlier solo, batch and staggered comparisons do not. The cause is not isolated. Per-request hashes and the control's internal variability are retained. No token/logit parity or quality-equivalence claim is made. Not run: - SYCL build/runtime, NVIDIA GPU execution, default-output parity against a separately built unpatched main, sampled decoding, other model/quantization/context workloads, four simultaneous clients. ### Observed rates, not a lossless speedup claim Same binary and public 130,020-token prompt, 512 output tokens (128 for the short staggered request), context capacity 131,072, greedy API settings, seed 42, reasoning disabled, retained warm cache. Values are medians of HTTP end-to-end completion-token rates; first cold runs remain in the archive and are excluded here. | Layout | Warm solo after switching, 3 runs | Two requests, aggregate, 3 pairs | | --- | ---: | ---: | | Dual GPU, hybrid/history opt-ins off, piped MTP on | 56.34 t/s | 134.05 t/s | | Same dual GPU, hybrid/history opt-ins on | 93.01 t/s | 136.18 t/s | Separate existing single-GPU MTP controls: GPU 0 **69.54 t/s**, GPU 1 **60.08 t/s**, medians of two warm runs each, with their cold requests retained. These require a 4 GiB conversation cache instead of the dual service's 16 GiB and a 12 GiB host-registration cap. Power limits were retained at 303 W and 231 W; this is not a stock blower/platinum comparison. Automatic expert-cache sizing can also change with the pipeline's extra verifier/snapshot reserve. Different generated text can change MTP acceptance, so these observations do not isolate a quality-preserving speed gain. Use `docs/MTP_SWITCHING.md` and `tools/bench_mtp_switch.py` for the controls and sequence. Parity investigation and the remaining backend checks are still required before merge. Historical custom-tree 116/161 t/s records belong to that separate build, not this submitted integration. ### Same-day optimized-production control and missing backend paths The [appended raw control evidence](https://github.com/cennac/Strata/tree/8c8c82405d74d95716f7815cd5d20b564fcf8c0e/bench/results/2026-11-02-community-dual-rx7900xtx-production-control) runs both saved measurement scripts on the unchanged optimized production service. Both original and appended evidence are retained. | Stack and workload | Warm solo | Two requests, aggregate | | --- | ---: | ---: | | Optimized production, original benchmark | 114.58 t/s | 153.63 t/s | | Optimized production, this PR's switching benchmark | 134.11 t/s | 164.35 t/s | | This mainline integration, earlier opt-in run with the same switching benchmark | 93.01 t/s | 136.18 t/s | The switching rows use the medians of three solo-after requests and three synchronized pairs, HTTP end-to-end, actual 130,020-token input and 512 output tokens. Production solo-after samples were 114.48/134.11/134.27; dual pairs were 164.31/168.33/164.35. The original script uses a three-run solo mean and continuous dual throughput over 33.33 seconds, with two distinct prompts rather than the switching script's shared prompt. These scripts must not be treated as identical workloads. The two stacks have different engine/server revisions; production retained GPU vision while the isolated candidate dual arms disabled it. This was a same-day sequential control, not a randomized kernel ablation. Output differences can also change MTP acceptance. Both scripts completed; the original marker checks passed; production configuration, power caps and fan modes were unchanged. Hotspot peaks were 77/82 C and minimum available RAM was 16.42 GiB. These checks do not resolve the candidate's output-equality failure above. Source inspection found that the submitted tree does not include the custom `rdna_gr.cu` compilation unit or its RDNA GR/Q8/A8/inject/fused control paths. It also does not implement the custom `STRATA_RDNA_MMVQ_WAVE` and `STRATA_WAIT_FUSE` controls. Those variables remain in the candidate configuration but cannot restore absent implementations. The per-path explanation of the speed gap remains **unconfirmed static analysis** until controlled ports/ablations; no per-kernel contribution percentage is claimed. The [complete custom source](https://github.com/cennac/Strata/tree/3eb5752b18c30e633e144511d919b95bd64e1959) is already public with its existing history and attribution. It is the performance/reproduction reference, not the code submitted by this PR. Porting its backend changes requires separately reviewable patches and same-workload correctness/performance checks. This PR stays focused on switching; output parity and the remaining backend checks are still unresolved. --- <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#5269
No description provided.