qwen35: DSpark speculative decoding (Qwen3.8-27B drafters) - #625
Draft
davide221 wants to merge 2 commits into
Draft
qwen35: DSpark speculative decoding (Qwen3.8-27B drafters)#625davide221 wants to merge 2 commits into
davide221 wants to merge 2 commits into
Conversation
Wire the DSpark drafter heads (low-rank Markov bigram correction + confidence head) into the qwen35 spec-decode loop, so Qwen3.8-27B DSpark drafters (e.g. RadixArk/Qwen3.8-27B-DSpark) run with full head support: - spec loop: markov-corrected greedy chain (fused single-graph variant with non-fused fallback) replaces plain argmax projection when the drafter ships DSpark heads; DDTree candidate top-k gets the markov bias too. Env-gated: DFLASH_QWEN35_DSPARK, DFLASH_QWEN35_FUSED_DSPARK, DFLASH_QWEN35_DSPARK_TREE (all default on). - target capture layers now follow the drafter GGUF's dflash.target_layer_ids instead of the evenly-spaced derivation; the Qwen3.8 drafter is trained on layers 4/16/28/40/52, not 1/16/31/46/61. - draft loader: dflash.mask_token_id from the drafter GGUF wins over the family default (Qwen3.8 drafter uses 248077, default was 248070), and optional YaRN rope scaling keys are parsed into DraftWeights. - draft graph: rope calls honor the drafter's YaRN config (previously hardcoded plain NEOX rope). - Qwen35DFlashTarget exposes lm_head for the fused head path. - convert_dflash_to_gguf.py: handle single-file DSpark releases (markov/ confidence heads inline in model.safetensors), transformers>=5 nested rope_parameters and dflash_config.mask_token_id, and emit YaRN scaling metadata. The confidence-gate adaptive block length is not wired yet (q_len sizes the per-request step buffers); the chain runs with the gate off.
Verify/accept now run over v_len (the drafted chain's actual length) instead of the buffer-sizing q_len, so the DSpark confidence gate's adaptive block truncation is structurally supported. The gate itself stays off by default (DFLASH_QWEN35_DSPARK_CONFIDENCE_THRESHOLD=0): with the RadixArk Qwen3.8 drafter, any threshold in 0.1-0.5 truncates to the same short chain regardless of value, so the confidence scores coming out of the shared head path look mis-scaled and need a separate investigation before the gate can help. threshold=0 is bench-verified regression-free.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds DSpark drafter support to the qwen35 family spec-decode loop, targeting the published Qwen3.8-27B DSpark checkpoints (DFlash backbone + low-rank Markov bigram head + confidence head, e.g.
RadixArk/Qwen3.8-27B-DSpark).What's in here
Spec loop (
qwen35_backend.cpp)DFLASH_QWEN35_DSPARK,DFLASH_QWEN35_FUSED_DSPARK,DFLASH_QWEN35_DSPARK_TREE.dflash.target_layer_idsinstead of the evenly-spaced derivation. The Qwen3.8 drafter is trained on layers 4/16/28/40/52; capturing the derived 1/16/31/46/61 silently destroys acceptance.Draft loader (
draft_gguf_loader.cpp)dflash.mask_token_idfrom the drafter GGUF wins over the family default (this drafter trains with MASK 248077; the default was 248070 — another silent acceptance killer).rope.scaling.*) parsed intoDraftWeights.Draft graph (
draft_graph.cpp)Converter (
convert_dflash_to_gguf.py)model.safetensors, nodflash_aux_heads.ptsidecar) now convert directly.rope_parameters(theta + YaRN) anddflash_config.mask_token_id; emits YaRN scaling metadata.Fused head path:
Qwen35DFlashTargetexposeslm_head_tensor()(the fused chain needs the target lm_head; layer-split target falls back gracefully).Validation (R9700 / gfx1201, Qwen3.8-27B Q4_K_M, greedy, 300-token gens)
Serving config for the numbers: q4-mix requantized drafter,
--fa-window 2048, q8_0 KV,DFLASH_SINGLE_CHAIN_CHECKPOINT_F32=1 DFLASH_FAST_ROLLBACK_THRESHOLD=1. Acceptance length matches the checkpoint's published SGLang reference (~3.4 tokens/step incl. bonus).Known limitations / follow-ups
q_len); the chain runs with the gate off.