Repository navigation
perf(cbv2-mtp): single-forward Qwen draft rounds (1.13x vs MTP-off); env-gated draft-head shortlist - #108
Merged
Conversation
…d shortlist Draft-step trim on top of capture-verify (c020624): 1. SINGLE DRAFT FORWARD (shipped, default): Qwen35InlineMTPAssistant.draftStep no longer runs the MTP head twice per round (proposal + staging re-forward). The proposed draft pair (assistant hidden, draft token) is DEFERRED in request state and enters assistant KV as part of the NEXT round's one [1, 1+p] forward, only after the target confirmed it (finalizeRound confirmed==2). Rejection simply drops the pair — no KV trim on any path, and the blocking mid-graph eval() between the two forwards is gone. Per round this halves draft weight traffic (~0.72 GB -> ~0.36 GB; the second full 286 MB 4-bit lm_head read was computed and discarded). Content is bit-compatible with the legacy staging forward (same fused inputs; only batch geometry differs, per the documented NUMERICS POLICY). Legacy path pinned via DARKBLOOM_QWEN_MTP_DOUBLE_FORWARD=1 as the A/B oracle. 2. DRAFT-HEAD SHORTLIST (implemented, measured, DEFAULT OFF): CBv2MTPRequestStatefulDrafter.draftShortlistSize opts verify rounds into surfacing each position's target top-K ids + probability mass (EngineLoopV2.mtpDraftShortlist; mass rides the acceptance packet as ppm, coverage-gated >= 0.90 at finalize into the carry); the drafter scores K gathered quantized lm_head rows (quantizedMM over weight[ids]/ scales[ids]/biases[ids]) instead of streaming the full 248,320-row head. Measured net-negative on M4 Max because the shortlist source is one position behind the draft: K=256 acceptance 0.79->0.58 (95.5 vs 116.5 tok/s), K=2048 0.68 (110.3), K=16384 0.77 (115.2) — coverage recovers but verify-side top-K + gather outweigh the ~1.3 ms full head read. Env-gated via DARKBLOOM_QWEN_MTP_SHORTLIST=<K> for future k>=2 chains. Paired same-session ladder (release, B=1 greedy, 256 tok, median of 5): MTP-off 103.0/105.0 | double-forward control 111.75 (accept 0.79) | single-forward 116.45 (accept 0.78) = 1.11-1.13x vs off, +4.2% vs control | temp-0.7 target-prefix 110.25 (multi-token deltas, accept 0.65-0.86). Tests: new Qwen35MTPDraftTrimTests (6) — single vs double-forward oracle parity across accept/reject chains, rejection/discard pending-pair semantics, float + quantized gathered-row shortlist parity (real assistant via production load path). CBv2QwenMTPIntegrationTests +3 — shortlist carry plumbing (coverage-gated ids contain the committed carry token), opt-in gating, ppm coverage math. Suites: 111 tests / 15 suites green.
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.
Problem
Capture-verify MTP (#106) reached 1.08x vs MTP-off, but each round still ran the MTP draft head twice (staging double-forward) — re-reading the 286 MB quantized lm_head and blocking the engine thread with a mid-graph eval — ~0.72 GB of draft traffic per round against ~1.79 committed tokens.
Change
[1,1+p]forward, only after target confirmation. No KV trim on any path; removes the second lm_head read and one blocking eval per round. Legacy double-forward stays as an env-pinned oracle (DARKBLOOM_QWEN_MTP_DOUBLE_FORWARD=1).DARKBLOOM_QWEN_MTP_SHORTLIST=<K>): scoring the draft against the target's top-K rows regresses at practical K because the top-K source is one position behind the draft (acceptance 0.79→0.58 at K=256 → net 0.91x); at K=16384 coverage recovers but argPartition+gather outweigh the ~1.3 ms full-head read. Kept for k≥2 chains where the math changes. Negative result documented, guarded by tests.Measured (M4 Max, release, prod artifact, B=1 greedy 256 tok, paired sessions, drift bracket ~2%)
1.11–1.13x vs MTP-off (+4.2% over parent).
Behavior
flowchart LR subgraph Before A1[round] --> B1["draft: 2x MTP-head forwards<br/>2x 286MB lm_head + mid-graph eval"] --> C1["1.08x vs off"] end subgraph After A2[round] --> B2["draft pair deferred in request state<br/>one [1,1+p] forward post-confirmation"] --> C2["1.11–1.13x vs off"] endCode
flowchart LR subgraph Before D1[Qwen35MTP.draftStep] --> E1[staging forward + confirm forward] end subgraph After D2[Qwen35MTP.draftStep] --> E2[pending-pair carry in request state<br/>append on next round forward] D2 -.env opt-in.-> F2[shortlist head K rows<br/>default off — acceptance guard] endTests
6 new
Qwen35MTPDraftTrimTests: single-vs-double-forward oracle parity across accept/reject chains, rollback/discard pending semantics, float+quantized shortlist parity via the production load path; +3 integration tests (carry plumbing, opt-in, coverage math). Release suites green.