Skip to content

[WIP][Spec Decode] DSpark confidence-scheduled verification#47808

Draft
LucasWilkinson wants to merge 19 commits into
vllm-project:mainfrom
neuralmagic:codex/dspark-capacity-realloc
Draft

[WIP][Spec Decode] DSpark confidence-scheduled verification#47808
LucasWilkinson wants to merge 19 commits into
vllm-project:mainfrom
neuralmagic:codex/dspark-capacity-realloc

Conversation

@LucasWilkinson

@LucasWilkinson LucasWilkinson commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

This PR implements confidence-scheduled speculative verification for
DSpark. The confidence head predicts each
draft token's acceptance probability; the host scheduler prunes verification
work that is not expected to pay for its target-model cost.

confidence_based_verification controls the feature: none and off disable
it, auto uses compact verification when the attention backend supports the
required full CUDA graphs and otherwise falls back to masking, and mask
forces the masked path.

  • Masking leaves pruned rows as padding. Supported MoE kernels skip those rows
    through VLLM_MOE_SKIP_PADDING.
  • Compact verification rebuilds the variable-length verifier batch and replays
    full CUDA graphs for the target verification and draft query steps.

This builds on #47469 (SM100 DSA varlen decode). #47513 is the padded/full-CUDA-
graph comparison point. It replaces #47694, which was opened from the wrong
fork.

Scheduling and execution

The paper's prefix scheduler runs on the host. Each draft token receives its
cumulative prefix-survival probability. Tokens are considered globally in
score order, and the scheduler chooses the admission count that maximizes
expected accepted tokens times the profiled step rate. dspark_budget_frac
caps admission, while dspark_confidence_threshold provides direct threshold
mode.

Automatic profiling measures overlapping end-to-end step times and fits an
additive request-sized cost and verification-token cost. Their sum is converted
to the step rate used by the scheduler. The request term captures the parallel
DSpark proposal and other work whose shape does not shrink with verifier
pruning; the verification term captures the prunable token work. In a TP4
varlen profile, request-sized cost was 1.408 ms at 32 requests, 4.021 ms at 128,
and 7.398 ms at 256. The fit RMSE was 0.180 ms. Explicit
(verification_tokens, steps_per_second) breakpoints remain supported.

ConfidenceManager owns scheduling and the mode-specific batch transform. The
shared model runner is limited to request initialization, graph dispatch, batch
trimming, and confidence staging hooks.

Confidence logits and sampler outcomes use a fixed two-slot pinned-host ring.
The previous proposal's copy is consumed at a deterministic later dispatch, so
all TP ranks make the same shape decision without per-step payload allocation.
Compact verification uploads one packed metadata buffer and rebuilds positions,
sequence lengths, logit mappings, and verifier token IDs in one Triton kernel.

Online calibration

dspark_online_sts applies per-position Sequential Temperature Scaling from
the rejection sampler's observed accept/reject outcomes. Temperatures are fit
with an order-preserving ECE grid search over binned logits. Data-starved
positions blend toward the pooled fit, and calibration remains the identity
before observations arrive.

Performance

deepseek-ai/DeepSeek-V4-Flash-DSpark, TP4 B300, k=7, probabilistic drafts,
speed_bench, 256 prompts, up to 512 generated tokens, temperature 1.0,
natural EOS termination, and auto-profiled SPS. Cells are output tok/s /
acceptance length:

c No capacity Mask Varlen Mask + STS Varlen + STS
16 3,141 / 3.87 3,112 / 3.90 3,042 / 3.73 3,114 / 3.92 2,983 / 3.72
32 4,691 / 3.91 4,647 / 3.94 4,509 / 3.58 4,572 / 3.92 4,304 / 3.58
64 6,993 / 3.90 7,009 / 3.87 6,726 / 3.56 6,968 / 3.95 6,571 / 3.54
128 9,591 / 3.95 9,921 / 3.93 9,826 / 3.48 10,044 / 3.94 9,722 / 3.49
256 12,695 / 3.92 12,517 / 3.90 13,019 / 3.34 12,497 / 3.84 13,226 / 3.33

All 25 cells completed 256/256 requests. The result is workload-dependent. At
c=128, mask + STS improves throughput by 4.7% over baseline. At c=256, varlen
improves throughput by 2.6% and varlen + STS by 4.2%. The table is reported
without smoothing or a fitted trend line.

Correctness and validation

  • .venv/bin/python -m pytest tests/test_config.py tests/v1/spec_decode/test_dspark_confidence.py tests/v1/worker/test_gpu_block_table.py -q:
    183 passed.
  • .venv/bin/python -m pytest tests/v1/attention/test_dspark_noncausal_sparse_mla.py -q:
    20 passed, 8 skipped.
  • .venv/bin/python -m pytest tests/v1/spec_decode/test_dflash_lookahead.py -q:
    3 passed.
  • GSM8K 5-shot, all 1,319 questions, TP4 compact verification with budget 0.5:
    0.9454 accuracy (required 0.9200), invalid rate 0.000.
  • Pre-commit (Ruff, format, mypy 3.12, and config schema) passed on all changed
    files; the PR pre-commit and DCO checks are green.
  • The performance matrix above completed without retries, CUDA errors, or
    tracebacks.

Duplicate-work check

Searched open PRs by the linked PR number and DSpark confidence/capacity
keywords. The only functional overlap is #47513, which implements padded
verification rather than this host confidence scheduler and compact batch path.

AI assistance

Built with AI assistance (OpenAI Codex and Claude). The human submitter must
review and be able to defend every changed line before undrafting.

@mergify mergify Bot added qwen Related to Qwen models nvidia speculative-decoding labels Jul 7, 2026
@mergify mergify Bot added the v1 label Jul 7, 2026
@LucasWilkinson LucasWilkinson force-pushed the codex/dspark-capacity-realloc branch 3 times, most recently from e4457cf to 9b3a024 Compare July 8, 2026 03:15
@mergify

mergify Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @LucasWilkinson.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Jul 8, 2026
@LucasWilkinson LucasWilkinson force-pushed the codex/dspark-capacity-realloc branch from 9b3a024 to f4ee8d9 Compare July 8, 2026 18:24
@mergify mergify Bot added performance Performance-related issues and removed needs-rebase labels Jul 8, 2026
@LucasWilkinson LucasWilkinson force-pushed the codex/dspark-capacity-realloc branch 17 times, most recently from a36535e to df8a2f8 Compare July 12, 2026 19:48
@LucasWilkinson LucasWilkinson force-pushed the codex/dspark-capacity-realloc branch from c1a2f3c to 5d3d111 Compare July 13, 2026 14:57
@mergify

mergify Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @LucasWilkinson.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Jul 14, 2026
@sheep94lion

Copy link
Copy Markdown

Hi, I am learning about DSpark and glad to see a working implementation! I wanted to check one design point against the DSpark paper before I rely on this. As I read the paper, the confidence-based prefix scheduler splits the decision in two: the total verify budget for a step is set from the confidence data two steps earlier, but the per-request verify length is then allocated from the current step's confidence.

Instead, we approximate the upcoming verification capacity using the confidence head outputs from two steps prior. Mechanically, the candidate tokens in the current step are still strictly sorted by their actual, up-to-date cumulative confidence scores;

In this PR it looks to me like both quantities come from the same two-steps-earlier snapshot rather than being split. Is that an intentional simplification for now, or is matching the paper's fresher per-request allocation something you're planning?

Possibly I'm misreading the flow — happy to be corrected.

Implement host-side confidence scheduling for DSpark with automatically selected compact or masked verification, request-conditioned SPS profiling, and online temperature calibration.

Centralize scheduling and batch transformation in ConfidenceManager, use a fixed two-slot pinned-host copy ring, fuse compact batch rewrites, and keep shared model-runner and warmup hooks minimal.

Validated with focused CUDA tests, a GPU-sync-checked serving probe, GSM8K, and a 25-cell natural-EOS throughput matrix.

Co-authored-by: OpenAI Codex <codex@openai.com>

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Minimize shared-path changes, simplify confidence staging, and retain bounded varlen CUDA-graph dispatch.

Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Fit additive draft-request and verifier-token timing curves during automatic SPS profiling while retaining the existing scheduler lookup path.

Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Name the fitted request-count term for all request-shaped work, including fixed masked-verifier overhead, without changing scheduling behavior.

Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Measure draft and verifier costs directly for SPS scheduling. Keep the host-derived verification budget delayed while assigning that budget from current GPU prefix scores, matching the paper without expanding the shared model-runner path.

Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Apply the delayed token budget to the latest asynchronously staged confidence snapshot on the host. This preserves the paper's fresh per-request ordering while removing the generic per-step GPU sort and its buffers.

Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Use the paper's SPS objective argmax directly instead of requiring an additional five-percent predicted gain before pruning.

Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Choose one stale SPS budget on TP rank zero, then assign that budget from current confidences on the GPU. Keep compact verification metadata device-resident while retaining only the aggregate host shape needed for CUDA graph selection.

Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
@LucasWilkinson LucasWilkinson force-pushed the codex/dspark-capacity-realloc branch 2 times, most recently from e5f37eb to 1e8070e Compare July 14, 2026 23:31
Keep draft and verifier costs as separate one-dimensional tables, compute current confidence ordering only on TP rank zero, reduce manager staging state, and retain two request-count CUDA graph tiers.

Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
@LucasWilkinson LucasWilkinson force-pushed the codex/dspark-capacity-realloc branch from 1e8070e to 5716900 Compare July 15, 2026 01:23
LucasWilkinson and others added 10 commits July 15, 2026 01:50
Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nvidia performance Performance-related issues qwen Related to Qwen models speculative-decoding v1

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants