Conversation
Route scheduler-tagged prompt-tail padding through the rollback-capable speculative decode state layout while preserving the uniform K+1 graph shape.\n\nAssisted-by: OpenAI Codex
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.
Purpose
Fix recurrent-state corruption in hybrid Mamba models when speculative decoding pads the last prompt token to a uniform
K + 1query length.This is most visible in prefill/decode-disaggregated serving:
N - 1.Nto produceh(N).Kplaceholder positions so every row has query lengthK + 1and can use the same FULL CUDA graph.h(N + K placeholders)instead ofh(N).The requests do not need to share a prefix. They only need to enter the same scheduler step. Both may have MTP enabled: one request is already in steady-state speculative decode, while the newly resumed request still has one real prompt token left.
The trigger is:
K > 0;K + 1padding.Disaggregated serving makes this common because the NIXL Mamba handoff deliberately transfers
h(N - 1)and leaves tokenNfor the decode node. The same state can also arise after a local prefix-cache hit, preemption/replay, or another short prompt extension, so the fix is not NIXL-specific.Fix
Pass the scheduler's draft-count tag into Mamba metadata construction. When a row is:
Kplaceholders, androute it through Mamba's existing speculative-decode state layout even though the real token is still part of the prompt.
That layout is already transactional: it keeps
h(N)in the running state slot and writes later speculative states to scratch slots. Normal acceptance/rollback therefore discards the placeholder states and retains exactlyh(N). Genuine multi-token prefills and first prompt chunks remain on the prefill path.This preserves the original performance optimization: the scheduler still emits a uniform
K + 1row, so the FULL CUDA-graph batch shape is unchanged. The change only selects the state-management path that can safely roll back speculative positions.Reproduction
Deploy a hybrid Mamba model with prefill/decode disaggregation and NIXL KV/state transfer. Use separate prefill and decode workers, and enable MTP with five speculative tokens on both roles so their cache layouts remain compatible. Our reproducing deployment used two TP4 prefill workers and two TP4 decode workers, but the essential condition is that a decode worker handles more than one request concurrently.
Run SWE-bench Verified against the P/D router with enough concurrency for a newly transferred request to join a scheduler step that already contains a speculative decode request. The transferred request arrives with recurrent state through prompt token
N - 1; the decode worker must process tokenN. Stock vLLM pads that one-token prompt tail with five placeholders to match the existing six-position speculative row.On an affected vLLM 0.28 deployment, the padded row is sent through the Mamba prefill state path. The next decoding iteration then reads state after the placeholders instead of state after token
N. In the full 500-instance, three-repeat SWE run, this appears as invalid byte-piece output, Unicode replacement characters, leaked literal tool-call XML, missing structured tool calls, and a large resolved-accuracy drop with MTP5. A matched MTP-off run using the same checkpoint, serving topology, sampling settings, and benchmark provides the control.Apply this PR and repeat the same MTP5 workload without changing the checkpoint or serving parameters. The padded batch shape remains unchanged, but the prompt-tail row uses transactional speculative state handling; the corrupted-output phenotype disappears and SWE accuracy returns to the matched MTP-off level.
Why this is not duplicate work
No open PR found in the required duplicate-work search routes scheduler-tagged, padded prompt-tail rows through Mamba's transactional speculative state path.
Kscheduler placeholders, in the shared Mamba metadata path.alignmode. It does not address placeholder positions being persisted through the prefill state path.Validation commands and results
The rebased source-only branch passes the following checks:
A focused metadata regression in the deployment image passed all three cases: a stateful padded prompt tail becomes a speculative-decode row; an ordinary six-token prefill remains a prefill; and a stateless first prompt chunk remains a prefill.
An exact-image CUDA state probe compared three lanes from identical initial recurrent state. The padded speculative-decode lane retained the same accepted state and next-token result as the single-token decode lane. The unpatched padded-prefill lane persisted the placeholder-advanced convolution and SSM states and diverged on the next real token.
The bounded P/D MTP5 reproducer changed from 7/8 corrupted responses before the fix to 0/8 after it while retaining the uniform
K + 1batch shape. The full SWE-bench Verified qualification is reported below.AI assistance
OpenAI Codex assisted with root-cause analysis, implementation, validation harnesses, experiment analysis, and PR preparation. I reviewed and understand every changed line and am responsible for the contribution and the results reported here.
Test Result
mean/resolvedover all 1,500 SWE trajectories: