Skip to content

[Feat] dspark: Let the draft fold its verify commit and cap step logits - #51298

Merged
zcnrex merged 4 commits into
sgl-project:mainfrom
zcnrex:chunan/dspark-draft-commit-hooks
Nov 19, 2026
Merged

zcnrex merged 4 commits into
sgl-project:mainfrom
zcnrex:chunan/dspark-draft-commit-hooks

Conversation

@zcnrex

@zcnrex zcnrex commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Split out of #50186 (Inkling-2-Small support). The Inkling2 MTP draft runs on DSpark. It needs a few hooks in the DSpark worker and verify path that do not depend on the model.

Modifications

  • DsparkVerifyEpilogue: when the draft model sets folds_static_verify_commit and shares the target's FULL id space (no write translation), the static verify graph calls draft_model.store_verify_commit(...). folds_static_commit is now resolved once and cached.
  • DSparkWorkerV2:
    • the static commit fold also turns on for such drafts;
    • adds two subclass hooks, _build_verify_executor and _on_prefill_target_hidden;
    • the mamba commit after verify uses fused_commit_track_indices without accept_index (a chain), with an eager fallback off CUDA.
  • fused_commit_track_indices: accept_index is optional (HAS_ACCEPT_INDEX).
  • fused_conv_window_scatter_multi: a CONTIGUOUS fast path for contiguous source windows.
  • Markov sampling: BaseDSparkMarkovHead.step_softcap / step_vocab_limit apply a tanh softcap to the step logits and mask ids from vocab_limit on. Both default to off.

Tests

  • test_verify_commit_triton.py: new test_chain_commit_steps_matches_eager (CUDA), which checks the chain mode against the eager reference.
  • The DSpark epilogue fixtures set the new cache fields.

Accuracy Tests

These changes are moved unchanged from #50186, where they were validated together with the Inkling-2-Small model (see that PR and the cookbook page). The code is unchanged. I have not run it separately on this branch. CI runs the unit tests listed above.

Speed Tests and Profiling

None separately; see #50186.

Co-authored with @ispobock.

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ✅ Run #44406803958
Latest PR Test (Extra): ⊘ Skipped -- add the run-ci-nv-extra label to opt in.
Latest PR Test (AMD ROCm 10): ⏳ Run #44406803778

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@zcnrex
zcnrex force-pushed the chunan/dspark-draft-commit-hooks branch 2 times, most recently from dc8a89e to 73dfb0a Compare November 18, 2026 19:14
Adds a folds_static_verify_commit draft hook, subclass hooks on the DSpark v2 worker, a step-logit softcap and vocab limit in Markov sampling, and a chain (no accept_index) mode for fused_commit_track_indices.

Split out of the Inkling-2-Small support PR (sgl-project#50186).

Co-authored-by: Qiaolin Yu <[email protected]>
Co-authored-by: ispobock <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zcnrex
zcnrex force-pushed the chunan/dspark-draft-commit-hooks branch from 73dfb0a to 3905cc7 Compare November 18, 2026 19:46
@zcnrex zcnrex added the run-ci CI: run the baseline test suite on this PR label Nov 18, 2026
zcnrex and others added 2 commits November 18, 2026 12:54
… can fold

The worker turned the static epilogue on whenever the draft set
folds_static_verify_commit, but the epilogue folds only when the draft's FULL
slots are the target's, unremapped. A non-V4.1 target with a draft that could
not fold still ran the V4.1 static epilogue. Both now use one
draft_folds_static_commit check, which also returns False instead of raising
when a runner has no FULL space.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

This comment has been minimized.

@zcnrex
zcnrex merged commit 21be218 into sgl-project:main Nov 19, 2026
176 of 178 checks passed
@zcnrex
zcnrex deleted the chunan/dspark-draft-commit-hooks branch November 19, 2026 07:15
weireweire added a commit to weireweire/sglang that referenced this pull request Nov 19, 2026
…tail-glue

One conflict hunk, in dspark_verify.py DsparkVerifyEpilogue.run_static.

Main (sgl-project#51298) renamed the static epilogue's fold predicate to
folds_static_commit (folds_commit, or a draft that stores the verify commit
itself) and added a store_verify_commit call on the folded path, before the
draft KV staging. This branch added the fused greedy accept tail branch that
runs the relay scatter, engram commit and KV staging in the accept launch and
returns early.

Resolution: run_static takes main's folds_static_commit and keeps the fused
tail branch. _commit_tail_plan now returns None when the draft stores the
verify commit itself, so that configuration keeps main's separate path
(store_verify_commit ordered before the staging); the fused accept still
runs there, only the commits stay separate. No draft model in the tree opts
into that mode today, so served behaviour for the existing drafts is the
branch's.

Auto-merged files touched by both sides: dspark_worker_v2.py (main's
draft_folds_static_commit wiring next to this branch's in-place verify ids
slot; disjoint hunks).
YAMY1234 added a commit to sgl-project/sgl-nvidia-mega that referenced this pull request Nov 29, 2026
…PI v3 and contract (#103)

* [Fix] minimax_m31: Speak megakernel API version 3 and follow SGLang main's contract

#66 merged after #81 moved the unit tests to SGLang main, but its last unit
run was against the old pinned SGLang, where the MiniMax-M3.1 checks are
skipped. On SGLang main the spec is refused at registration and four
contract checks fail, so main's unit job has been red since #66.

- Megakernel API 3 (sgl-project/sglang#52054 replaced the verify penalty
  tables with step_penalties): declare 3, as #81 did for the other specs.
  The package reads no verify sampling penalties (its slots are the verify
  forward and the DSpark draft proposal), so nothing else changes.
- sgl-project/sglang#52870 moved minimax_sparse_nvfp4_backend.py to
  minimax_sparse/msa_v1_backend.py; msa_v1_decode_plan is the same field.
  Name the new file first and keep the old one as the alternative.
- fused_experts_none_to_flashinfer_trtllm_fp4: sgl-project/sglang#50195
  passes the ignored output buffer on the logits-routed path too; the
  routed-top-k path moe_nofill follows already passed it. Re-pin.
- _draft_step and _markov_sample_partial_kernel: sgl-project/sglang#51298
  adds a step softcap and vocab limit that only Inkling2's MTP head sets,
  and #52728 a folded-bias kernel path _draft_step never takes. The chain
  serves only VanillaMarkov, which leaves both None. Re-pin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* [Fix] qwen3_5: Follow SGLang main's GDNAttnBackend.forward_extend

sgl-project/sglang#39595 (FlyDSL GDN prefill on AMD) passes
prefill_metadata=self.kernel_prefill_metadata to the extend kernel in the
prefill arm of forward_extend, None for every kernel but FlyDSL, and adds
kernel_prefill_metadata = None to GDNAttnBackend.

- gdn/prefill.py serves only the Triton prefill kernel (view.kernel_id),
  and gdn/verify.py mirrors the target-verify arm, which the change does
  not touch. Re-pin both mirrors.
- The runtime tests' fake GDN backend gains kernel_prefill_metadata=None,
  as SGLang's class now defines it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* [Fix] kimi_k31: Follow SGLang main's verify sampling stages in the DFlash runtime

sgl-project/sglang#52406 deleted sampling_batch_info.adjusts_logits and
speculative/target_verify.py (adjust_verify_logits). SGLang's DFlash round
now reads VerifyRoute.adjusts_logits and calls VerifyStep.adjust from
SamplingPipeline.plan_verify. The K3.1 DFlash runtime imported both old
names, so it no longer imported on SGLang main.

- _unserved: VerifyRoute.derive(...).adjusts_logits is the same predicate
  as adjusts_logits (grammar, watermark, penalties, logit bias or a custom
  logit processor), so the same rounds go back to SGLang.
- _accept, greedy round on gathered logits: the target's
  sampling_pipeline.plan_verify(batch, watermark_full_mask=False).adjust()
  runs the same stages in the same order as adjust_verify_logits did:
  penalties along the chain, logit bias and the custom logit processor,
  each width rows per request, with no grammar mask. DFlash refuses the
  watermark, so none is bound. As before, _unserved already refuses every
  round these stages would change.
- The test fakes gain the target's sampling_pipeline and
  need_min_p_sampling, which SGLang's SamplingBatchInfo defines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* [Fix] qwen3_5: Re-pin GDNAttnBackend.forward_extend after sgl-project/sglang#44195

sgl-project/sglang#44195 gives the Triton GDN kernel an FP32 track
snapshot and gates the snapshot in forward_extend's prefill arm on
use_track_state_snapshot(): a snapshot-capable kernel in batch-invariant
mode.

- gdn/prefill.py: only --enable-deterministic-inference turns on
  batch-invariant mode, and it refuses the trtllm_mha attention backend
  this spec requires. The served prefill arm still writes checkpoints from
  the per-chunk states, as the slot does. Re-pin.
- gdn/verify.py mirrors the target-verify arm, which the change does not
  touch. Re-pin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jit-kernel run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants