Repository navigation
[RL, Spec] Introduce top-p mask capture for spec and add DFlash/DSpark impl - #34201
Conversation
68839a8 to
149832b
Compare
149832b to
078b356
Compare
078b356 to
7b8fa2b
Compare
|
/rerun-test test/registered/spec/dflash/test_dflash.py |
|
7b8fa2b to
0159b00
Compare
0159b00 to
d8d999c
Compare
|
/rerun-test test/registered/sampling/test_sampling_mask.py test/registered/spec/dflash/test_dflash.py test/registered/core/test_basic_sanity_dspark.py |
|
|
/rerun-test test/registered/sampling/test_sampling_mask.py test/registered/spec/dflash/test_dflash.py test/registered/core/test_basic_sanity_dspark.py |
|
Results for 🚀 🚀 |
803d3cd to
d69b33f
Compare
dd8bd86 to
f02586d
Compare
|
/rerun-test test/registered/sampling/test_sampling_mask.py test/registered/spec/dflash/test_dflash.py test/registered/core/test_basic_sanity_dspark.py |
|
Results for 🚀 🚀 🚀 |
12270e3 to
061d3c0
Compare
|
/rerun-test test_basic_sanity_dflash.py test_basic_sanity_dspark.py test_sampling_mask.py test_scheduler_sampling_mask_validation.py test_batch_result_processor_hidden_states.py test_output_streamer_customized_info.py test_sampling_batch_info.py test_graph_pool_borrow.py |
|
Results for 🚀 🚀 🚀 🚀 |
…nd DSpark (sgl-project#34201) (cherry picked from commit 201c4b9) Retain release worker and test dependencies; preserve capture regression coverage against the merged API.
…k impl (sgl-project#34201) Co-authored-by: hnyls2002 <lsyincs@gmail.com> (cherry picked from commit 201c4b9)
Relationship to existing work
#27408 introduced sampling-mask output support. #35205 restored the finite-
top_krequirement and bounded support packing for sampling masks. #33459 added the DFlash SpecV2 logprob path.This PR extends that machinery to the DFlash family, with worker-specific adapters for DFlash and DSpark, while preserving the finite-
top_kcontract from #35205.Motivation
Sampling masks let RL trainers reconstruct the inference policy more accurately and reduce rollout/training policy mismatch. This change makes that metadata available when using DFlash or DSpark speculative decoding, and introduces a contract that other spec implementations can implement for their own support.
Modifications
speculative/spec_sampling_mask.py, the speculative sampling-mask contract shared by DFlash and DSpark:validate_spec_sampling_mask_requestrejects configurations whose committed tokens are not exact samples from the captured target distribution: unsupported speculative methods,min_p, simulated acceptance, and for DFlash, acceptance thresholds other than 1.0 or missing sampling-verification support.SpeculativeSamplingMaskCapture.from_logitsrebuilds the target policy after acceptance from the final adjusted logits (grammar, penalties, logit bias, custom logit processors), only for batches with mask requests; greedy rows emit singleton masks with logprob 0.out_tokens/commit_lensviaSamplingMaskOutput.num_accept_tokens; the result processor appends one support row per accepted token and trims atfinished_len.top_konSamplingBatchInfo(sampling_mask_top_ks, maintained on filter/merge) to bound the packed support width; unbounded top-k stays rejected per [Sampling] Restore finite top-k requirement for sampling masks #35205.build_dflash_verify_target_probstobuild_speculative_verify_target_probs, as it is shared by DFlash, DSpark, UNO and the capture.Tests
SpecSamplingMaskKit(mixed greedy/sampling batch,selectedandsupportmodes) and run it in the DFlash and DSpark basic sanity suites.SamplingMaskOutputobjects.Performance considerations
Capture remains opt-in: batches without mask requests do no extra work. Support is bounded by the largest finite mask
top_kin the batch and packed before device-to-host transfer. For batches with mask requests, both DFlash and DSpark recompute the target policy once after verification.Accuracy Tests
Targeted final implementation:
4/4 DFlash sampling-mask unit tests passed in Modal:
Added
SpecSamplingMaskKitcoverage asserting:Full Qwen3.6 NVFP4+DFlash B200 run:
This feature only returns metadata and is not intended to change sampling decisions, so no downstream task-accuracy benchmark was run.
Speed Tests and Profiling
One B200 with:
Results:
The difference was within run-to-run noise. A complete repeat also showed no slowdown.
These numbers were measured on an earlier revision in which DFlash reused the verification probabilities instead of recomputing them after accept; requests without masks are unaffected either way.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): 🚫 Run #36681727080
Latest PR Test (Extra): ❌ Run #36681726706
Latest PR Test (AMD ROCm 10): ❌ Run #36681727472