[Spec] Share the grammar mask build and verify-tree staging across spec workers - #32393
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
/rerun-test test_spec_ngram.py test_eagle_constrained_decoding.py test_spec_standalone.py |
|
Results for 🚀 |
|
/rerun-test test_spec_ngram.py test_eagle_constrained_decoding.py test_spec_standalone.py |
|
Results for 🚀 |
|
/rerun-test test_spec_ngram.py test_eagle_constrained_decoding.py test_spec_standalone.py |
|
Results for 🚀 |
|
/rerun-test test_spec_eagle.py test_spec_eagle_topk.py test_frozen_kv_mtp.py |
|
Results for 🚀 🚀 |
Summary
spec_utils.build_grammar_vocab_mask()— bitmask build,non_blockingupload, and clearing the stale extend-stage mask, which EAGLE and NGRAM each spelled out separatelyspec_utils.StagedGrammarTree— the three verify-tree tensors copied D2H under one event, replacing the hand-rolled_async_d2hx3 + event +synchronize()in the EAGLE verify pathBackground
generate_token_bitmask->.to(device, non_blocking=True)-> clearsampling_info.vocab_mask), and the copy discipline that keeps it off the critical path is easy to get wrong: the copies must be staged before the target verify launch and resolved after it, and the upload must benon_blockingor the pinned bitmask silently degrades to a blocking copyNotes for reviewers
StagedGrammarTreeis deliberately narrow — it copies on the current stream and relies onrecord_streamrather than cloning, because the tree copies must stay ordered behind the draft kernels and ahead of the verify launch. The general side-stream variant iskv_canarysFutureTensors, whose clone-per-tensor and dedicated stream are wrong for a per-step verify pathretrive_next_token#32380) — so it calls the mask helper directly, which is what makes the split usefuleagle_sampleand the mamba / gdn / kda / hybrid-linear backends read themAccuracy Tests
{ "name": "Paris", "population": 2148000 }, a regex constraint yields an exactly-matching string, and unconstrained decode is unaffectedCI States
Latest PR Test (Base): ❌ Run #30153858856
Latest PR Test (Extra): ❌ Run #30153858796