mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1636] [CLOSED] batch-mtp: work with a layer split, +15% two-stream decode, one group under --batch-groups auto #3573
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3573
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1636
Author: @noon-at-cgn
Created: 10/9/2026
Status: ❌ Closed
Base:
main← Head:pr/batch-mtp-141📝 Commits (5)
e1e47afbatch-mtp: work with a layer split (slot drafters on the last stage's GPU, grouped slot rows through every stage)e46e904batch-mtp: log the accepted proposals in the batch summaryc7b77d8batch-groups: the 0.1.41 auto default gives way to --batch-mtp (one group, said once)ffc4000batch-mtp: not with helper expert caches on a layer split (not run); docs say how it meets --batch-groups2c08077docs: batch MTP on a layer split - measured on 2x RTX 3080 20 GB (0.1.41 build and the earlier 0.1.40.3 runs), with what was not measured📊 Changes
8 files changed (+430 additions, -57 deletions)
View changed files
📝
CMakeLists.txt(+8 -0)📝
docs/BATCHING.md(+57 -8)➕
include/strata/core/batch_rows.hpp(+30 -0)➕
include/strata/program/batch_groups.hpp(+62 -0)📝
src/core/verify.cpp(+6 -22)➕
src/program/batch_groups_test.cpp(+93 -0)📝
src/program/generate.cpp(+96 -27)➕
tests/core/batch_rows_test.cpp(+78 -0)📄 Description
Title
Issue: Related: #1253 (ilumn, "Enable serial multi-GPU batch MTP": the same design, open, based on
82f46a8, includes #1242). #1413 (--batch-groups G>1+--batch-mtpis silently inert). #1242.Summary
Why it matters: on a layer split
--batch-mtpis refused ("it is for one GPU (no layer split or helper) for now"), so two people using a two-GPU machine get one token per window each, while the flag gives +31% to +39% on one GPU (docs/BATCHING.md). This change lets--batch-mtprun on a layer split: each slot's drafter lives on the last stage's GPU (where the solo drafter and the head are), and a window carries two rows per slot (its token and its proposal) through every stage. On 0.1.41 it also needs one more fix: a layer split with--batch2 or more now pipelines the slots in groups by default (--batch-groups auto), pipelined groups run no slot drafts (#1413), and the--batch-mtpgate ran before that default was resolved, so--batch-mtpstayed on while the groups became 2 and the drafts never ran. With--batch-mtpand no--batch-groups,autonow resolves to one group and the log says why.--batch-groups N(N above 1) or--batch-groups autogiven on the command line is honoured and turns--batch-mtpoff, as upstream does.23,parallel 2,--spec 4, 2x RTX 3080 20 GB (220 W cap), Xeon E5-2696 v4, UD-Q4_K_XLfb58e0d, binary strata-w10):--batch-mtp, one group (3 restarts, 60 measurements)--batch-mtp, one serial group (2 restarts, 40)--batch-mtp,--batch-groupsunset = the 0.1.41 default, two pipelined groups of one slot (1 restart, 20)--batch-mtp--batch-mtp(2 runs per arm)Where upstream's default is better: a new prompt of about 48k tokens arriving while one stream decodes was read at 2508 tok/s with the pipelined groups and 1217 tok/s in serial windows, and the decoding stream finished sooner (25.0 against 18.0 tok/s over its whole run).
--batch-mtpdoes not change that. So--batch-mtppays where concurrent decodes dominate; with long reads arriving beside decodes the 0.1.41 pipelined default can be the better choice. The first two 0.1.41 arms ran the asynchronous adaptive tier in batch windows, which is #1637 (the stack's next change; upstream main refuses it with batch slots); the pipelined path never adapts in windows (its tier runs in the solo path only), and that arm is our build started with the flags 0.1.41 resolves to, not an upstream binary.What changed
src/program/generate.cpp:--batch-mtpis accepted with a layer split whose stages are on separate GPUs (still refused when two stages share a GPU, with--batch-groupsabove 1, and, new, with helper-GPU expert caches or--remote-expert-opton a split, which have not been run). The slot drafters load from the last stage's slot sessions under that stage's device guard and bind to its weights and head; their residual buffers, the row copy (asynchronous, on the drafter's own stream) and the draft-K/V copies at admission and slot restore run on the drafter's device. Every stage's verifier gets the eight-row window size and the batch graph limit. The slot drafters' logits are not charged to CUDA0's cache sizing. The log says where the drafters are and what each costs (--batch-mtp: 2 slot drafters on CUDA1 (50 MiB of private K/V state and buffers each ...)); thestrata batch:summary says how many proposals were accepted.src/core/verify.cpp,include/strata/core/batch_rows.hpp(new): the row-layout rules ofstage_batchmove into a pure function; grouped slot rows are allowed on a stage that hands rows on, and the hand-off bound iskVerifyMaxTrows (it was the slot count, which a slot's two rows exceed). CPU testtests/core/batch_rows_test.cpp.include/strata/program/batch_groups.hpp(new, pure) andsrc/program/batch_groups_test.cpp(CPU): how many groups--batchruns with (the 0.1.41 default,auto, an explicit number) and the one case where the default gives way (--batch-mtp).generate.cppcalls it before the--batch-mtpgate, so the gate sees the resolved number. Log line:--batch-groups auto: 1 group of 2 slots - --batch-mtp does not run in pipelined groups; --batch-groups 2 would pipeline them and turn it off.docs/BATCHING.md: the layer-split paragraph, the--batch-groups autorow, the limits list, the measurements above.Extra Notes
#1253 (ilumn / Alex, open, conflicts with main, based on
82f46a8, includes #1242): the same design, so please read both. The same: slot drafters on the last stage's GPU bound to that stage's weights and head, serial windows (--batch-groups 1), eight-row windows through every stage with a bounded batch graph cache,--batch-mtpstill refused when two stages share a GPU. What differs:OnDeviceguards in the destructors ofVerifierandMtpDrafterand inMtpDrafter::idle, and takes the last stage's bind bytes (the drafters' logits and residual rows,late_bind) out of that stage's expert-cache room. This change has neither (it relies on--vram-reserve-mib); I did not copy them, since they are theirs.--pipeline-windows, helper caches,--remote-expert-optand peer devices in the gate. Here--pipeline-windowsis already off with batch slots,--peer-devicecannot be combined with a layer split, and helper caches on a split are refused.batch_rows.hpp); in #1253 they stay inline instage_batch.tools/batch_mtp_split_test.py: staggered admission, solo promotion, seeded and greedy, mixed images) and measurements on 2x RTX 5090 with an IQ3_XXS model; this change has no GPU harness of its own, only the measurements above and a text-equality check (below).--batch-groups 1. Rebased on 0.1.41 its gate (o.batch_groups > 1, evaluated beforeautois resolved) would see 1 and keep batch MTP on while the groups become 2. The gate fix here is what makes--batch-mtpwork on 0.1.41 without that flag.They cannot both be applied as they are: they conflict in
generate.cpp(gate and drafter sites),verify.cpp(stage_batch) anddocs/BATCHING.md. If #1253 goes first, what stays here is the gate fix and its test,batch_rows.hppand its test, the accepted-proposals log line and the asynchronous row copy, and I will rebase onto it. If this goes first, #1253 still brings its harness, the destructor guards and thelate_bindaccounting. The gate fix needs neither. #1253's own table shows batch MTP slower than pipelined batching on 2x RTX 5090 (54.7 against 61.0 tok/s at 4000 experts per stage, 148.0 against 176.7 at 11000), and blange48's report on it found no gain on a 4-stage split (120/125/149/173/200 against 123/125/148/174/202 serial and 121/154/218/258/378 pipelined at 1/2/3/4/8 clients). Our two-stage result is for two stages and two slots. Related, not changed here: #1504 (long prompt reads on a layer split beside a decoding slot) concerns the read speed that the pipelined default wins in the table above.Text equality: with the same expert cache on both arms (the slot drafters take VRAM, 4213 slots on CUDA1 in both after adjusting the reserve),
--pcie-frac 0 --adapt-every 0 --suffix-draft 0, the greedy text with--batch-mtpequalled the text without it for 5 short prompts in all 6 comparisons (one restart per arm; the 25k-token prompt was not repeatable between two identical streams of the same arm). With different caches (4246 against 4213 slots) even the solo path differs on 5 of 6 prompts, so an unadjusted on/off comparison is confounded. This is text equality, not a bit-exactness proof, and says nothing about sampled output.Not tested: HIP, SYCL, three or more stages (#1253's report found no gain at four), more than two slots, sampled decoding, images with
--batch-mtpon a split (no per-slot image positions here: that is #1242), GPU parity of the split path beyond the text check above,--batch-mtpwith helper caches (refused), any upstream-main binary (all 0.1.41 numbers are from our build). The new gate and log lines were read in the start log of the production engine on strata-w10 (this change plus the rest of our stack): the base config and--batch-groups 2(which printed--batch-mtp is off: it does not combine with --batch-groups (pipelined slot groups) yet); there was no CPU-only start of the engine.Tests (CPU,
CUDA_VISIBLE_DEVICES=-1):batch_rows_testandbatch_groups_test(14 checks) pass;cteston the whole tree: 52 pass, 56 fail with no GPU (the same set on this branch and #1637). On GPU 0 with about 1 GiB free:verify_parity,verify_batch_parity,rope_parity,qsa_parity,kv_stream_parity,kv_hybrid_paritypass;gdn_rec_paritystops withcudaMalloc: out of memory(another process holds that GPU's memory).python -m unittest discover -s serve: 593 tests OK (11 skipped).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.