Repository navigation
spark-model: grammar-mask the DFlash2 drafter's pos+1 rows so draft 0 is always legal (#102) - #103
Conversation
#102) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Triage (2026-09-26). Small and targeted. It fixes #102's first limiter by masking rows 0–1 so draft 0 is always grammar-legal, and CI is green apart from the non-blocking benchmark gate. Merge condition: a re-run of the job-448 config on this branch, showing:
If mean accepted is still well below MTP's on that leg, the DFlash2 agentic lane should stop here (see the note on #104). |
|
HIP compile check for the strix-hip twin (CI only builds the gb10 PTX): |
|
GB10 validation (reiner job 483,
Reading:
This PR doesn't make DFlash2 competitive with MTP for agentic serving. It does remove a structural waste at no measured cost. Merging. |
Fixes the first limiter in #102. DFlash2 drafts in grammar-constrained (tool-call) output were not grammar-masked:
propose_drafts_on_lanereceived the live bitmask and ignored it (_grammar_bitmask).truncate_drafts_at_grammar_boundarytherefore often truncated at draft 0 (kept=0), which threw away the step's γ-row propose. On the 27B agentic leg that meant thousands of truncations and mean accepted of 0.8–1.3.What changes:
atlas_apply_grammar_bitmask(kernels/{gb10,strix-hip}/common/grammar_bitmask.cu) writes bf16 −inf over disallowed ids in one logits row. It follows the xgrammar convention: a set bit means allowed.DflashScratch.grammar_bitmask_dev. Batched propose uploads per-sequence masks intobatch_grammar_bitmask(batch_capacity × ceil(vocab/32)words) and masks rowsi·γandi·γ+1. The scheduler passes per-sequence masks (mtp_grammar_masks_for) on the DFlash batch, K4-batch and bootstrap paths.graph_eligible &&= mask.is_none()), because a captured graph would bake in a stale mask.try_kernel. It's acommon/kernel, so every target ships it.Validation:
cargo check --features cuda, typos,check_kernel_shadows, line cap.cargo test -p spark-model --release grammar_bitmask -- --ignored --nocapture. The masked argmax must pick a legal id, rows 2 and 3 must be untouched, and −inf must be written.kept=0truncations, mean accepted and turn time.