Repository navigation
[Refactor] speculative: One target-verify ring for EAGLE, NGRAM and DSpark - #52174
Conversation
…erify_accept hook
…ogprobs) across eagle, ngram and dspark
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
/rerun-test test_target_verify.py test_nv_runtime_gates.py test_model_runner_kv_weight_versions.py test_eagle_post_verify_graphs.py test_sharded_verify.py test_dspark_accept_tail.py test_dspark_sampling_accept_graph.py test_verify_penalty_paths.py test_spec_eagle.py test_spec_eagle_topk.py test_eagle_constrained_decoding.py test_spec_ngram.py test_dspark_simulated_bonus.py test_watermark.py test_synthid_watermark.py test_constrained_decoding_spec_reasoning.py |
|
🚀 🚀 🚀 🚀 |
|
/run-cpu-ci |
|
🚀 Running |
# Conflicts: # python/sglang/srt/speculative/dflash_worker_v2.py # python/sglang/srt/speculative/dspark_components/dspark_worker_v2.py
# Conflicts: # python/sglang/srt/speculative/dspark_components/dspark_worker_v2.py
# Conflicts: # python/sglang/srt/speculative/dspark_components/dspark_worker_v2.py # python/sglang/srt/speculative/eagle_worker_common.py # python/sglang/srt/speculative/ngram_worker.py
|
/run-cpu-ci |
|
🚀 Running |
Motivation
EAGLE, NGRAM and DSpark wrap their accept cores in the same steps, and each worker wrote its own copy of them:
commit_verify_accept;compute_spec_logprobs.NGRAM also copied EAGLE's whole tree accept core, including the switch between the NV runtime hooks' post-verify and
eagle_sample. A new spec worker, or a new step such as another per-request sampling state, had to be added to every copy.Modifications
speculative/target_verify.pywithTargetVerify, a frozenmsgspec.Struct:TargetVerify.prepare(batch, *, logits_output, grammar_tree, grammar_barrier, watermark_engine, watermark_full_mask)builds the grammar mask and binds the watermark. It returns the struct the accept core reads:grammar_mask,watermarkandwatermark_full_mask.verify.commit(batch, *, logits_output, accept)commits theVerifyAcceptthroughcommit_verify_accept. When the batch returns logprobs, it then computes them: a tree accept gathers through itsaccept_index, and a chain accept reads its rows at the width of its token block.accept_draft_treeineagle_worker_common.py. It is the tree accept core that EAGLE and NGRAM now share: the NaN/Inf probe, then the runtime hooks' post-verify underSGLANG_ENABLE_NV_MEGA_RUNTIME_OPTIMIZATION, otherwiseeagle_sample. EAGLE passes its sparse and simulated-acceptance options, and NGRAM keeps the defaults.prepareandcommitaround them, and still applies the grammar mask and the watermark to its logits itself.verify.commit, which does nothing for the batches those graphs take (no penalties, no watermark) and computes the same logprobs.No behavior change. Steps that moved only changed their order against independent work: the logprobs now run right after the commit, and the probe runs after the watermark bind.
Accuracy Tests
Differential end-to-end run of base #52164 against this PR, on one GPU, with Llama-3.1-8B-Instruct in float16 (the EAGLE3 draft checkpoint is float16). Each configuration sent the same 9 chat requests one at a time:
response_formatand 1 free-form;top_logprobs=2on every request.Sampled requests were left out, because the host's CUDA toolchain could not JIT-build the sampled tree verify kernel on either tree.
Checklist
test_nv_runtime_gates.pynow callsaccept_draft_treedirectly with EAGLE's options and with the defaults, instead of executing the gate it extracted from each worker's source.CI States
Latest PR Test (Base): ⊘ Skipped -- add the
run-cilabel to run CI tests.Latest PR Test (Extra): ⊘ Skipped -- add the
run-cilabel to run CI tests.Latest PR Test (AMD ROCm 10): ⊘ Skipped -- add the
run-cilabel to run CI tests.Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: