Conversation
…MLA builder Under parallel drafting (DSpark, DFlash) the sparse MLA builder derives its decode threshold through _init_reorder_batch_threshold, which counts 1 + 2 * num_speculative_tokens (11 for k=5). The sliding-window builder added num_speculative_tokens to its own threshold instead (6 for k=5). A request with 7..11 query tokens - a short prompt, or the uncached tail of a prefix-cache hit - was therefore a decode for the C128A metadata (no prefill top-k indices built) and a prefill for the SWA metadata, and the sparse attention asserted on the missing indices, killing the engine. The SWA builder now takes its threshold from the same helper. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Peuqui <peuqui@github.com>
Peuqui
force-pushed
the
sparse-swa-spec-threshold
branch
from
September 12, 2026 06:38
8411611 to
7fae17c
Compare
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
DeepSeek-V4-Flash with DSpark (
num_speculative_tokens=5) kills the engineon a chat prompt of 7 to 11 tokens after the template, and on any
prefix-cache hit that leaves 7 to 11 uncached tokens (typically the second
turn of a tool call):
followed five minutes later by
RPC call to sample_tokens timed outandEngineDeadError. Prompts of 4 to 6 tokens and of 12 tokens and more work.Three metadata builders decide the decode/prefill split for one forward,
with two different thresholds:
FlashMLASparseMetadataBuilder(C128A) calls_init_reorder_batch_threshold(1, supports_spec_as_decode=True), whichunder parallel drafting counts
1 + 2 * num_speculative_tokens(
backend.py), i.e. 11 for k=5. DSpark setsparallel_drafting = True(
config/speculative.py).DeepseekSparseSWAMetadataBuildercomputedreorder_batch_threshold + num_speculative_tokens, i.e. 6, with a commentsaying it must match the other builders.
A request with a query length in (6, 11] is a decode for the C128A builder
(
treat_short_extends_as_decodes), so it builds noc128a_prefill_topk_indices; for the SWA builder it is a prefill, so thesparse attention takes
_forward_prefilland asserts on the missingindices. The window is exactly the gap between the two thresholds.
The SWA builder now takes its threshold from the same helper. Without
speculation nothing changes (both were 1); with MTP-style drafting
(
parallel_drafting=False) nothing changes either (both were 1 + k). Theindexer builder (
indexer.py) still addsnum_speculative_tokens; it isnot part of this assert path and is left as is — happy to align it in the
same PR if wanted.
Test Plan
pre-commit run --files vllm/v1/attention/backends/mla/sparse_swa.pyandthe
mypy-3.10hook (--hook-stage manual).TP1 × PP5, DSpark k=5, chat prompts with exactly 4..16 tokens after the
template (each prompt in a fresh request,
max_tokens=8), before andafter the change. Before: two boots, descending from 16 and ascending
from 4, each stopped at the first crash. After: one boot, all lengths,
then a two-round tool call (call, then the tool result as a
toolmessage, with prefix caching).
Test Result
(8 asserted three times in earlier runs). After: all thirteen lengths
4..16 answer, no assertion in the worker log. Tool call with the tool
result returned as a
toolmessage (prefix-cache hit leaving 8 uncachedtokens, the case that asserted before): the call is parsed
(
get_weather,{"city": "Hamburg", "unit": "celsius"}) and the secondturn answers in 5.3 s with the returned values, no assertion.
Not a duplicate
Checked on 2026-09-12 against
1CatAI/1Cat-vLLM:gh pr list --state open --searchfor "sparse_swa", "decode threshold speculative","parallel_drafting" and
gh issue list --search "topk_indices"return noPR touching this;
gh pr diff --name-onlyover every open PR shows nonetouching
sparse_swa.pyordeepseek_v4/amd/rocm.py. Related butdifferent: #208 (indexer decode workspace OOM and a shape assert in
combine_topk_swa_indicesunder 32-sequence load), #205 (prefix-cache hitrate 0 with DSpark, an upstream SWA mask bug), #597 (DSML tool-call token
selection and decode speed on 8× V100).
AI assistance (Claude) was used to measure the window and trace the two
thresholds; I reviewed every line and ran the tests above.
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.