Repository navigation
fix(turbomind): harden MTP/speculative serving [stacked on #5006] - #5144
Draft
richardclli wants to merge 4 commits into
Draft
richardclli wants to merge 4 commits into
richardclli wants to merge 4 commits into
Conversation
- Fixed-chain speculator base with EAGLE3 and Qwen3.5 MTP draft models, target-native speculation, and method-keyed draft weight registry - Block speculative verification: paged CuTe verification attention, SM90 GDR verify and commit kernels with persistent pipelining - Unified parameterized batch-op pipeline; executor forward split into target pass and speculative round; host batch ops moved engine-side - Scheduler: unified required admission, simplified rollback, submitted rows carry producer-set effects instead of a kind tag - Op-level pytest suites: verification attention, draft carry, speculative sampling, speculative sequence, target hidden projection, copy
ROOT CAUSE: MoeGateKernel_v8 / MoeGateNoAuxTCKernel_V2 (noaux_tc gate). When a
token yields fewer than top_k selectable experts (NaN/-inf router logits collapse
max_i), some of the top_k selection steps clear no slot, leaving holes in
smem.shared_exp_id. The routing write then read such an uninitialized slot as an
expert id and indexed masks[expert_id*token_num_padded+ti2] out of range -> CUDA
illegal memory access (cuda-gdb: 'Warp Out-of-range Address', expert_id=-1132287279).
Timing-dependent (which rows degenerate), so masked by CUDA_LAUNCH_BLOCKING and
memory sanitizers.
Fix (both gate kernels):
- initialize shared_exp_id/shared_scales to a -1/0 sentinel before the fill,
so unfilled (degenerate) slots are deterministically skipped.
- keep the idx<top_k guard and only write masks/scales/accum when
0 <= expert_id < expert_num.
Validated on full Qwen3.6-35B-A3B NVFP4, TP2: AR canary 10/10; MTP N=2 canary
10/10; 120 concurrent spec requests (k=6 x 20 rounds) zero crashes (was ~2).
A DFlash2/7 round near session_len wrote past the allocated KV columns, underflowing a BatchCopy size (copy.cc TM_LOG_FATAL) and aborting the engine. Reserve 2*(max_proposals+1) rows below session_len at add time: too-large prompts now return a clean kTooLong 400 and generation is truncated to the limit. Verified: 262015+128 -> 200 (trunc 113), 262130/262144 -> 400, canary 10/10, needle recall True @261K.
This branch has not been 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.
Summary
Stacked on #5006 (TurboMind
speculative decoding). This PR adds three correctness fixes that multi-token
speculation exposes: a latent base-upstream MoE-gate out-of-bounds, a
cross-stream logits race, and the speculative KV margin at admission.
Once #5006 is merged, the diff of this PR shrinks to exactly the three fix
commits. SM75 validation additionally ran on
#5019 (GDN
half_t+ methodalias), but the code here does not depend on it.
Motivation
Multi-token speculation exposes three latent serving bugs. None is introduced by
the MTP framework; they are correctness gaps that the speculative path reproduces
reliably on SM75 (RTX 2080 Ti), and the first also affects any MoE deployment with
degenerate router logits.
Modification
expert id, so a valid token that selects fewer than
top_kexperts no longerindexes
masks[]out of range. Applies to both thev8andnoaux_tcgatekernels.
the sampler runs on another stream and the first step could hang on stale data.
2 * (max_proposals + 1)rows belowsession_lenso aspeculative round cannot write past the allocated KV columns; oversized prompts
return a clean
kTooLongand generation is truncated to the limit.Dependency note
half_tand method alias; needed to run, not to buildThe MoE-gate fix is format-independent; #5142 is only how the 35B-A3B NVFP4
grouped-expert lane was exercised. FP8/half checkpoints can reproduce the fixes
if #5142 is unavailable.
Validation
top_kfinitelogits;
tests/turbomind/moe_gate21/21.200 (truncated 8); 262144 and 262200 -> 400, no
BatchCopyabort.35B-A3B MTP-4 10/10; MTP needle 4K/32K/128K.
BC-breaking
None. Behavior changes only in degenerate/oversized cases, where it replaces a
crash with a clean skip, truncation, or
kTooLong.Notes
The MoE-gate fix addresses a latent base-upstream bug that exists independently
of the MTP framework; it is grouped here because multi-token speculation is the
reliable repro. It can be split into a standalone main-targeted PR on request.
SM75 is the validation platform, not the scope of the fixes.