Repository navigation
Qwen TP batch driver: build-ahead protocol (gated, off until the native executor submits steps) - #1830
Merged
Conversation
The driver can build a plain decode step before it reads the step before it, so the GPU and the collectives run while the host reads, publishes and answers (window 1 measured ~1.9 ms of GPU idle at each token boundary). - Every folded step's selection sum also carries two decision words (each rank's barrier flag) for the step two later. With no barrier and the unread step decoding the same lanes, both ranks build that step on the unread step's selection rows (executor submitDecode/readDecode, new, default unsupported). - Any event that needs a plan (owner stop or the answer to an ending token, join, idle lane, cancel or deadline, ended lane, output count, more than four held tokens) is a barrier: both ranks read every submitted step and the next plan is made and exchanged with nothing in flight, as today. - Held tokens are a queue (one published per answer); a decision that reads a stop marks the lane leaving and keeps the answer for the plan. - An EOS read after the next step was built discards that one forward; the generation schedule accepts one declared discarded forward after an EOS (a length finish still none). - Gate: QwenTensorParallelBatchSettings.buildsAhead adds qwen-tp-batch-build-ahead-v1 to the load agreement. Off: the native executor does not submit decode steps yet, so the product is unchanged. Tests: six two-rank fake-executor cases (steady decode at widths 1/2/4, EOS, owner stops at once and late, late credits, joins + prompts + cancellation, ranks that disagree failing closed), the gate, the schedule's EOS rule. With the build-ahead path disabled 3 fail; with it all pass, and every existing driver case is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This comment has been minimized.
This comment has been minimized.
…, tests) Review of #1830: - The runtime passes QwenTensorParallelBatchSettings.buildsAhead (the load agreement's value) into the driver, so the gate and the behaviour are one value. - On a failure, a submitted unread step is drained before retireAll. - Decisions see the peer's reported cancellations (no publish, barrier). - The schedule accepts exactly one discarded forward after an EOS. - After a barrier the next step carries its successor's plan again, so only one step runs read-then-build instead of two. - Tests: the build-ahead path is asserted in the EOS, owner-stop and late-credit cases; disagreement in both directions fails both ranks at the first folded step; a corrupted decision word fails both; the held bound; an assisted row beside plain rows; a failure while a step is pending retires every lane. Harness bounds tightened to the driver's. With the build-ahead path disabled, 9 tests fail; with it, all 30 pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
added a commit
that referenced
this pull request
Nov 5, 2026
Review of #1830 (must-fix 1), executor half: QwenTensorParallelBatchSettings .buildsAhead now reaches both the driver and the native executor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #1830-#1834, N1: in the continuation branch a failing read of the previous step left pending pointing at it, so the cleanup read it a second time and never drained the step already built ahead (probe: submit 4, read 3, read 3). pending now becomes the newer step before the read. Tests: aReadFailureWhileTheNextStepIsBuiltDrainsTheNewerStepOnce (red before: step 6 read twice, step 7 never; green after); the pending-failure test now checks every submitted step is read exactly once and the failed one never (N2); a built-ahead EOS leaves exactly one discarded forward (N4). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
added a commit
that referenced
this pull request
Nov 5, 2026
…s no device frontier Review of #1830-#1834, N5 and the device-read gap: - aNativeLaneRetiresAfterABuiltAheadEOS: a native lane whose EOS is read after its next step was built retires as a clean EOS with exactly one discarded forward; red without the schedule's EOS rule. - CBv2StageKVHost.submittedDeviceFrontierReads counts the frontier checks a submitted frame reads from the device; the token-identity suite asserts none on a paged host (GPU) and that the counter is live on a contiguous one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
added a commit
that referenced
this pull request
Nov 5, 2026
QwenStageTokenSampler.takePendingStepLogprobs came in from #1824 too: one copy kept, its doc naming both users (Gemma's one-token loop, Qwen's build-ahead). #1820's stride, #1822/#1824's CBv2OwnedRequestState.submit and #1830 are kept as on dev. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
added a commit
that referenced
this pull request
Nov 5, 2026
Qwen TP native executor: submit and read decode steps in two phases (PR6a, stacked on #1830)
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The driver protocol for Qwen tensor-parallel build-ahead (PR6 part b; design in
overnight/tp-perf/REPORT.md"PR6 design"). The batch driver can build a plain decode step before it reads the step before it, so the GPU and the collectives keep running while the host reads tokens, publishes and services the owner. Window 1 measured ~1.9 ms of GPU idle at each token boundary of a ~23 ms step. The expected gain is 8–10 %, to be measured once the native executor opts in.Off in the product. The native executor does not submit decode steps yet (
buildsAheadfalse, the protocol default), so nothing changes until part a (native two-phasesubmitDecode/readDecode) and part c (opt-in) land with their GPU suites.Protocol (both ranks)
Decision words. Every folded plain decode step's selection sum also carries two decision words (each rank's barrier flag, 0/1) for the step two later. When neither rank asks for a barrier and the unread step decoded the same lanes the decision covered, both ranks build that step on the unread step's selection rows. Then they read the unread step.
Barrier = today's path. A rank asks for a barrier whenever anything needs a plan:
At a barrier both ranks read every submitted step, and the next plan is made and exchanged with nothing in flight, through today's
makePlan/validate/leave/join. No plan ever carries in-flight counts.Lockstep. Every input to a decision and to a build is agreed state (read sums, read tokens, plans), so both ranks submit the same collectives in the same order. A rank's own decision word is checked unchanged in transit.
Held tokens. Held tokens are a queue (
heldLogprobs): one published per "go on" answer, in order, never past a stop. A client stop drops up to 4 held tokens:validate'sdropsOnebecomesdropsHeld, still exactly 1 without build-ahead.EOS after a built step. An EOS read after the next step was built discards that one forward on both ranks; its token is never selected.
QwenLayerStageGenerationSchedule.finishnow accepts one declared discarded forward after an EOS (a client stop already could; a length finish still can't). No step is built past a request's output count.Version gate.
QwenTensorParallelBatchSettings.buildsAheadaddsqwen-tp-batch-build-ahead-v1to the load agreement, so ranks on different protocols refuse each other before loading weights. A pair that disagrees anyway fails closed on both ranks at the first folded step (the sum shapes differ); it never runs out of step. The driver refuses build-ahead on an executor that can't submit steps or doesn't fold control.Tests (model-free, CPU; run locally: 71 tests in the driver, settings, schedule-adjacent and other batch-driver suites, all pass)
New in
QwenTensorParallelBatchDriverTests(two ranks, fake executor):steadyDecodeBuildsAheadAndTakesTheReadThenBuildTokens, widths 1/2/4: ≥ 10 steps built before the previous one was read. Both ranks submit and read in the same order. Tokens, finishes and forwards equal the read-then-build oracle (none past length).anEOSReadAfterTheNextStepWasBuiltDiscardsThatForwardOnly: EOS beside length rows; ≤ 1 forward past an EOS, none past a length end.aHostStopUnderBuildAheadPublishesOnlyWhatTheOwnerSaw: answers at once and one poll late; nothing published past what the owner saw; clean client stop on both ranks.lateCreditsUnderBuildAheadPublishInOrder.joinsPromptsAndCancellationInterleaveWithBuildAhead.ranksThatDisagreeOnBuildAheadFailClosed.buildAheadNeedsAnExecutorThatSubmitsAndFolds.readThenBuildNeverBuildsAhead.theScheduleAcceptsAnEOSWithTheForwardBuiltPastIt.Also:
QwenTensorParallelBatchSettingsTests(the gate field appears only when on). All 21 existing driver cases pass unchanged.Red → green: with the build-ahead path disabled, 3 tests fail with 6 issues (steady build-ahead count, joins build-ahead count, disagreeing ranks not failing). With it, all pass.
Token identity against the read-then-build oracle is checked in every new case, through the fake executor's deterministic histories. On real hardware it comes with part a's GPU suite (build-ahead equals read-then-build bitwise for greedy and sampled rows), queued in the REPORT's GPU slot queue.
Docs:
docs/architecture/inference.md(Qwen TP folded control → "Build-ahead"). No changelog fragment: no user-visible change while the native executor keeps it off.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review fixes (
2c22a0ecd0, 21:19Z)settings.buildsAheadinto the driver (and, in Qwen TP native executor: submit and read decode steps in two phases (PR6a, stacked on #1830) #1832, into the executor), so the gate and the behaviour are one value. A submitted, unread step is drained beforeretireAll.Second review fixes (
0f0818add8, 22:02Z)pendingis already the newer step, so the cleanup drains it exactly once and never re-reads the failed step.aReadFailureWhileTheNextStepIsBuiltDrainsTheNewerStepOnceis red before the fix (step 6 read twice, step 7 never) and green after.