Skip to content

feat(dflash2): Qwen3.8-27B DFlash2 speculative decoding support - #21

Closed
AzeezIsh wants to merge 6 commits into
mainfrom
feat/qwen38-dflash2
Closed

AzeezIsh wants to merge 6 commits into
mainfrom
feat/qwen38-dflash2

Conversation

@AzeezIsh

@AzeezIsh AzeezIsh commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds complete support for DFlash2 block-diffusion speculative decoding on Qwen3.8-27B (unsloth/Qwen3.8-27B-NVFP4 target paired with incoai/Qwen3.8-27B-DFlash2 drafter, $\gamma=8$, =7$ verify drafts).

Changes

  1. DFlash2 Grouped Dynamic Causal Convolutions:
    • Added dflash2_conv.cu implementing 2-tap grouped dynamic causal convolution with dynamic kernel deltas generated via per-layer kernel_projection.
    • Wired Dflash2Conv pre- and post-attention/MLP in forward_block_layer.rs and forward_block_layer_paged.rs.
  2. Bilinear Candidate Selector:
    • Implemented Dflash2CandidateSelector scoring draft token candidates using unary logits, projected hidden states, and predecessor/successor codebook embeddings.
    • Aligned row evaluation order ( = \text{anchor}$, {1\dots 7} = \text{mask drafts}$) with CUDA verify graphs.
  3. SSM State Pool & Verify Graph Allocation:
    • Fixed MTP intermediate buffer reservation (ssm_pool.rs) to allocate uniform full-width intermediates when =\gamma=8$, avoiding fallback to ladder caps.
  4. Weight Loader & Admission:
    • Added DFlash2 configuration parsing and tensor loading for convolution kernels and candidate selector codebooks.
    • Updated kernels/gb10/qwen3.8-27b/MODEL.toml with [dflash] configuration.

Verification & Performance

  • Live Serving on GB10: Tested with 512-token chat completions.
  • Speculative Acceptance:
    • Observed 100% burst acceptance (/7$ drafts accepted consecutively across multiple steps).
    • Overall code-generation acceptance rate: 84% (269 accepted draft tokens out of 320 content tokens; 512 tokens total).
    • Generated Python code and reasoning tokens are 100% coherent.
  • Throughput: .8\times$ speedup over baseline serial generation on GB10 (.6\text{ tok/s}$ vs .4\text{ tok/s}$).
  • Testing: All 83 spark-model DFlash unit tests passing; cargo fmt verified.

AzeezIsh and others added 4 commits September 3, 2026 09:11
- Add DFlash2 dynamic grouped causal convolution kernel and layer wrapping
  for attention and MLP sublayers.
- Add bilinear candidate selector scoring top-k draft candidates with
  predecessor/successor codebook embeddings and projected hidden states.
- Support incoai/Qwen3.8-27B-DFlash2 drafter architecture and weight loader.
- Fix SSM pool MTP ladder allocation for γ=8 verify slots via full-width reservation.
- Configure MODEL.toml pairing for Qwen3.8-27B with DFlash2.
Eliminates the 4MB D2H sync and 1.74M float CPU top-k bubble scan in
Dflash2CandidateSelector. Moves candidate selection into a fused GPU
kernel dflash2_candidate_selector that executes warp-level top-4 reduction,
context dot-product scoring, and greedy draft advancement in <0.05ms
directly in GPU shared memory.
Windows .cmd/.bat launchers can't escape inner double quotes, so the
natural Windows spelling --default-chat-template-kwargs
'{"enable_thinking":true}' arrives at argv with the single quotes
literal (CommandLineToArgvW has no POSIX single-quote semantics) and the
flag failed fail-fast JSON parsing. Strip one wrapping '...' layer
before serde_json::from_str. No valid kwargs JSON begins/ends with ', so
valid inputs are unaffected and typo fail-fast is preserved.

Recipe fixture updated to carry the quoted spelling so the recipe ->
serve_args path exercises the strip end-to-end.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Measured on GB10 (gx10-e3a3, 119.6 GB) at 9bafa476

Paired single-user measurement, unsloth/Qwen3.8-27B-NVFP4 + incoai/Qwen3.8-27B-DFlash2, temp 0, all penalties explicitly zeroed, max_tokens=256, --max-batch-size 1 --gpu-memory-utilization 0.78 --kv-cache-dtype bf16 --lm-head-dtype bf16:

Prompt class Serial tok/s DFlash2 tok/s Speedup mean_na tok_step
code (LCS) 13.0 26.2 2.0x 8.885 9.885
JSON 13.3 34.2 2.6x 7.500 8.500
short prose 13.2 14.8 1.1x 2.706 3.706
recall list 13.3 29.9 2.2x 6.167 7.167

Median ~2.0x serial decode; per-step acceptance 0–47% with bursts to 59% — broadly consistent with the PR's 1.8x claim and the independent SGLang evidence (3.95 tok/step at D=16; here γ=15 verify, up to 8.9 accepted/step). Earlier mixed code+prose request: 11.7 tok/s with the arbiter keeping spec on only 20% of steps — the gate correctly sheds spec when acceptance collapses.

Gate records run on this head

  • concurrency-sweep PASS (4/4 cells; C1 21.1 / C4 48.0 / C8 60.0 / C16 89.5 tok/s)
  • decode-floor PASS — 22.2 tok/s, accept_len 2.64 (needed --serve-override gpu_memory_utilization=0.92: the pinned recipe is sized for a 121.7 GB box and OOMs at 0.85 on this 119.6 GB one — 59.8 committed + 43.0 reserve > 101.7 budget)
  • bfcl-subset FAIL — normalized 83.10 < 83.32 (overall 86.23). This is the inherited last-index-wins argmax regression from 07755218, digit-for-digit what PR qwen4_exp: seven fixes for long-form serving of Qwen3.8-Flash-Next on a GB10 #23 documented and db0bc097 fixes — not a dflash2 defect. Expect PASS once that revert lands/merges.

Two findings worth addressing

  1. DFlash verify bypasses the sampling pipeline. step_verify_dflash uses verified_argmax directly when dflash_verify_raw_argmax is set, so presence/frequency/repetition penalties (and any temp>0 semantics) never reach the emitted stream — the non-thinking preset for this model ships presence_penalty=1.5. Reproduced: identical temp-0 requests diverge vs serial only while penalties are active; with penalties zeroed, 2/4 prompts are byte-identical and the other 2 differ at single near-tie positions (verify-row argmax vs decode argmax — same tie-break class PR qwen4_exp: seven fixes for long-form serving of Qwen3.8-Flash-Next on a GB10 #23's db0bc097 addresses; kernel merges keep lower-lane not lower-index). The verify itself is honest — accepted ⟺ draft == target argmax — but under penalized/sampled requests the emitted distribution isn't the one the request asked for. Consider gating the raw-argmax path to temperature<=0 && !penalties_active, or routing verified through verify_pick_all_with_pipeline otherwise (the pipeline branch already exists, just unreachable when the lever is set).

  2. Boot memory ceiling on this box. --dflash at --gpu-memory-utilization 0.85 + max-batch-size 4 dies in drafter build (cuMemAlloc OOM, 646 MB free). 0.78 + bs=1 is comfortable — worth a note in the PR body or the serve docs since the gate recipes pin 0.85.

Minor: --dflash --enable-prefix-caching prints a community-reported SM12.x correctness warning — surfaced cleanly at boot, good.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Follow-up — nvidia/Qwen3.8-27B-NVFP4 (the stock ModelOpt pack) also brings up clean on this branch. Served with --dflash --draft-model incoai/Qwen3.8-27B-DFlash2: model_type=qwen3_5 resolves, MTP weights load inline from the 3-shard layout (no separate model_mtp.safetensors needed), drafter engages, verify steps run.

Same 4-prompt probe (temp 0, penalties zeroed, bs1): 24.1 / 24.6 / 11.3 / 26.4 tok/s, mean_na 2.1–8.4 — same envelope as the unsloth pack (26.2/34.2/14.8/29.9). Both packs serve equivalently; note BENCH.toml's gate entries only register unsloth/Qwen3.8-27B-NVFP4, so gate records stay on the unsloth subject unless a nvidia/ checkpoint entry is added.

…bfcl-subset fails on the inherited argmax regression

Records produced by `spark benchmark run <gate> --pull-request-gate` on
gx10-e3a3 (NVIDIA GB10, 119.6 GB, driver 580.126.09, CUDA 13.0). Two
environment notes on this box:

* The pinned qwen3.8 serve recipes are sized to dgx2's 121.7 GB. On this
  119.6 GB box the committed footprint exceeds the pinned budget
  (59.8 GB Atlas-own + 43.0 GB reserve vs 101.7 GB at 0.85), so
  decode-floor and bfcl-subset ran with --serve-override
  gpu_memory_utilization=0.92/0.75 — recorded inside each record.
* ttft-cold/ttft-warm had no prior baseline on this box; they record as
  info and become the reiner baselines.

bfcl-subset: FAIL at normalized 83.10 vs baseline 83.32 (overall 86.23).
This is the last-index-wins argmax regression inherited from 0775521 —
identical numbers to what #23 documents and db0bc09
fixes — not a dflash2 defect. Re-run after the argmax revert lands.

agentic-webserver and bfcl-subset-echolp not run on this box (their
subjects are the 3.6 checkpoints; download completed but runs were
declined pending a 3.8-scoped bench call).
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Review follow-up — two commits pushed to review/pr21-fixes (on top of the gate-records head 683a0db0):

  1. 323a7e1d scheduler: gate DFlash raw-argmax verify per sequence, not process-wide. The --dflash flag applied raw-argmax verification to every sequence — for requests with active penalties or grammar, the emitted stream silently followed unpenalized argmax instead of the request's distribution (this model's non-thinking preset carries presence_penalty=1.5, so it was the common case). Reproduced live: identical temp-0 prompts diverged from serial only while penalties were active; byte-identical once zeroed. The fix adds dflash_seq_uses_raw_argmax — raw path requires the process flag AND a neutral-greedy sequence (PenaltyGate::Neutral, no grammar, no require_tool_call); everything else falls back to the existing verify_pick_all_with_pipeline branch, matching MTP semantics. Unit test covers the gate. Cross-checked against SGLang's reference dflash_worker_v2: it applies per-request verify-logit adjustments (apply_dflash_verify_logits_adjustments) and uses argmax accept-prefix only for the greedy arm — same conclusion.

  2. 5fc53c1a clippy cleanup — the PR's dflash_head files fail clippy 1.93 deny-all (manual div_ceil, doc list indent, ref on .as_ref()): fixed.

Neither adds flags/env vars — behavior-only.

…r and concurrency-sweep pass, bfcl-subset fails on the inherited argmax regression

Re-measured at the post-ee15431a head after the earlier 9bafa47 records
were invalidated by the serve.rs change. Same box (gx10-e3a3, GB10, 119.6
GB): decode-floor 22.3 tok/s (floor 20.5, util override 0.92 recorded),
concurrency-sweep 4/4 cells, bfcl-subset FAIL 86.23/83.10 — byte-for-byte
the same draw as the 9bafa47 record, i.e. the last-index-wins argmax
regression inherited from 0775521 that #23/db0bc097 fixes.
Not a dflash2 defect; re-run after the revert lands.
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Live verification of 323a7e1d on nvidia/Qwen3.8-27B-NVFP4 + --dflash (GB10, review/pr21-fixes build): 4-prompt temp-0 probe with penalties active (non-thinking preset, presence_penalty=1.5) — 3/4 outputs now byte-identical to serial decode; the 4th differs only at two near-tie positions (verify-row argmax vs decode argmax kernel resolution — the known tie-break class, same as PR #23's db0bc097 issue). Pre-fix, the same prompts diverged mid-stream whenever penalties were active. Under neutral penalties all 4 remain byte-identical.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Complete gate re-run on the fix head 323a7e1d (review/pr21-fixes, records commit 48159c63): 9/10 required gates PASS on GB10.

Gate Result
ttft-warm / ttft-cold PASS (+0.4% / +0.5% median)
ssm-state-poisoning PASS (12/12 byte-identical replays)
vision / video fidelity PASS
decode-floor PASS (22.2 tok/s vs 20.5 floor, accept_len 2.64)
concurrency-sweep PASS (C1 20.9 → C16 ~89 tok/s)
agentic-webserver PASS (10/10, 5.65s/turn)
bfcl-subset-echolp PASS (87.85 / 87.90)
bfcl-subset FAIL (86.23 / 83.10 — third identical draw; the last-index-wins argmax regression inherited from 07755218, fixed by #23's db0bc097. Not a dflash2 defect — needs the revert merged.)

The verify-gate fix (323a7e1d) introduced no measurable regression: decode-floor and sweep match the pre-fix records. bfcl-subset needs the argmax revert from #23 to clear.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Update: review/pr21-fixes @ d83653f2 — argmax revert cherry-picked, bfcl-subset re-measuring

The one red gate (bfcl-subset 86.23/83.10) was provably the inherited last-index-wins argmax regression from 07755218 — three bit-identical draws across three heads, and PR #23's db0bc097 documents the same mechanism (9 of 207 answers flipped, 3 correct lost, 86.53→86.23).

To make this branch self-contained I cherry-picked db0bc097 onto review/pr21-fixes (→ d83653f2; clean pick, no conflicts) and re-launched bfcl-subset on it. If the mechanism attribution is right the draw should return to the 86.53/83.38 range PR23 measured at the same fix — will post the record when it lands (~3.5h).

Nothing else in this branch depends on the revert — the per-seq verify gate (323a7e1d) and the gate records at 48159c63 are unchanged.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

bfcl-subset FAIL on the nvidia subject — the promised re-run landed, and it fails.

Records committed on review/pr21-fixes (.benchmarks/bfcl-subset/2026-09-12-0bf70e9f13.json) and review/pr23-fixes. Three consecutive runs, identical signature:

run tree spec overall normalized
run-1789206159965049753 pr21 @ 0bf70e9 MTP (recipe default) 85.13 76.60
run-1789263813340128511 pr23 @ 9da215a MTP 85.13 76.60
run-1789290824981666674 pr23 @ 9da215a n-gram 85.03 76.53

Bars: committed min 83.82/83.72 (noise 0.4 → effective 83.42/83.32). Prior unsloth records on the same recipe and draw scored norm 82.2–83.4 (09-03 → 09-11, marginal band). These are the first-ever nvidia bfcl-subset records on this box.

Category split vs the 08-14 dgx1 baseline (84.12 norm): hallucination 84.85 → 55.11 (live_irrelevance 47.73, irrelevance 62.50) while simple_java 45.16→67.74 and simple_javascript 29.03→74.19 improved — the suspected-2026-08 template defect partially healed; the new drop is the model emitting tool calls when it should abstain.

Classification: not a PR regression — identical on both branches; n-gram vs MTP differ only in noise. Candidate mechanisms, in order: (a) nvidia checkpoint abstention behavior (mixed-precision hf_quant_config ≠ unsloth flat NVFP4); (b) checkpoint chat_template / generation_config vs the recipe expectations; (c) box + build-vintage drift vs the dgx1 baseline.

Decisive bisect (queued for the next GPU window): one bfcl-subset leg on --checkpoint unsloth/Qwen3.8-27B-NVFP4 on the current head (~3.5 h). ~83 isolates the checkpoint; ~76.6 indicts the code.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Heads-up: #33 stacks review/pr21-fixes (a61f026) + main with the Strix Halo (gfx1151) port and two engine fixes found while porting (Option-B paged attention ran the HDIM=256 kernel against the drafter's head_dim=128 KV — likely the source of the Option-B acceptance drop; small-M drafter GEMM routing). Merging #33 lands this PR's commits, so it will close as merged.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

2026-09-15 update — review/pr21-fixes @ 7dec982e1 (nvidia 27B + DFlash2)

Full record: docs/porting/QWEN38_NVIDIA_PORT_LOG_2026-09-15.md (+ the queue scripts under docs/porting/qwen38-nvidia-2026-09-15/jobs/). Every number below carries its run-record id in that file.

bfcl-subset FAIL on nvidia — resolved, not a checkpoint or kernel problem. The 76.6 normalized was the recipe's disable_thinking pin on this checkpoint (abstention lives in the thinking pass on nvidia; §I of the gap analysis). Gate run with --serve-override disable_thinking=false + reasoning_effort:"medium": PASS 87.94 / 88.24 (run-1789419056919283587, n=995) — best nvidia score on record. Ship fix = recipe (sparkrun-recipes), then re-derive the stale 83.x bars. The unsloth control leg is moot for the nvidia target.

Every gate-driven --dflash serve was crashing (CUDA 700) — root cause found, fix landed.

  • Not prefix caching (runs with pcache OFF died identically). Bisect: γ=16 × Option B × the second sequence's first propose — 5/5 variants; γ≤15 never faults; legacy (non-OB) γ=16 ran 503 agentic turns clean.
  • Gate serves ran γ=16 because the clap default shadowed MODEL.toml's [dflash] gamma = 8 (the field's own doc admitted the fallback was unreachable. : now resolves flag → MODEL.toml → 16, logged with its source; 4 unit tests. Under Option B γ=8 is also the measured optimum (~22 tok/s vs 17.8 at γ=16 on the MinHeap fingerprint).
  • The faulting launch is named ( backtrace): in the drafter's layer-0 propose. The kernel bounds every read, so the inputs are suspect; adds (gated diagnostic) and a dump job is queued.

Option B, measured (bs1, MinHeap code prompt, temp 0): 22.1–22.5 tok/s vs 12.5 serial vs 15.1–15.6 legacy; propose 50 ms flat. Acceptance dips 5.5→3.9 vs legacy and the ablations show it is inherent to OB's ctx construction (no-ctx → mean_na 0.05), not an incremental-precompute bug.

Where it does not accelerate yet: C8 agg 27 vs 65 serial (batched K=γ verify; gate sweep queued); 9.7K-ctx prose 8.7–10.1 vs 11.2 serial (p1 ≤ 0.14); first agentic gate record with OB γ=8: 48/50 webserver_ok, 0 faults, 19.6 s/turn vs 57.3 legacy, Σwall 9907 s > 9000 (FAIL by 10 %; record marked throttle-INVALID for speed). Drafter acceptance on prose/agentic text (mean_na 1.8) is now the gap, not step cost.

Output parity / KL (serial vs OB γ=8, temp 0, penalties zeroed, top-10 logprobs): 2/5 and 4/8 byte-identical; divergences are exact BF16 ties except one 0.25-nat flip; shared-prefix top-10 KL ≈ 0.01 nats (fold gate threshold is 1e-3 — a policy call for this PR). Found and documented: with penalties active the DFlash lane reports pre-penalty while serial reports post-penalty ones (33/940 positions emitted ≠ reported argmax; 0 with penalties zeroed) — reporting defect in , not an acceptance bug.

Fingerprint correction for the earlier profile numbers: is ignored on this checkpoint (pre-packed NVFP4 head) — all nvidia-27B numbers ran the NVFP4 head.

Queued overnight on : ST-995 with DFlash2+OB γ=8 + thinking ON (one variable vs the 87.94 MTP record), the MTP-27B agentic reference (no such record existed — the 5.5 s/turn figures were the 35B subject), and the concurrency-sweep gate.
EOF
)

AzeezIsh added a commit that referenced this pull request Sep 16, 2026
…fx1151 port, HDIM=128 Option-B fix (#33)

* feat(dflash2): add Qwen3.8-27B DFlash2 speculative decoding support

- Add DFlash2 dynamic grouped causal convolution kernel and layer wrapping
  for attention and MLP sublayers.
- Add bilinear candidate selector scoring top-k draft candidates with
  predecessor/successor codebook embeddings and projected hidden states.
- Support incoai/Qwen3.8-27B-DFlash2 drafter architecture and weight loader.
- Fix SSM pool MTP ladder allocation for γ=8 verify slots via full-width reservation.
- Configure MODEL.toml pairing for Qwen3.8-27B with DFlash2.

* perf(dflash2): fused on-device bilinear candidate selector kernel

Eliminates the 4MB D2H sync and 1.74M float CPU top-k bubble scan in
Dflash2CandidateSelector. Moves candidate selection into a fused GPU
kernel dflash2_candidate_selector that executes warp-level top-4 reduction,
context dot-product scoring, and greedy draft advancement in <0.05ms
directly in GPU shared memory.

* feat(bench): add MLPerf edge agentic performance leg (2.5h) runner and template

* spark-server: accept single-quoted --default-chat-template-kwargs

Windows .cmd/.bat launchers can't escape inner double quotes, so the
natural Windows spelling --default-chat-template-kwargs
'{"enable_thinking":true}' arrives at argv with the single quotes
literal (CommandLineToArgvW has no POSIX single-quote semantics) and the
flag failed fail-fast JSON parsing. Strip one wrapping '...' layer
before serde_json::from_str. No valid kwargs JSON begins/ends with ', so
valid inputs are unaffected and typo fail-fast is preserved.

Recipe fixture updated to carry the quoted spelling so the recipe ->
serve_args path exercises the strip end-to-end.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* bench: gate records for 9bafa47 on reiner — 5 pass, 2 baseline-info, bfcl-subset fails on the inherited argmax regression

Records produced by `spark benchmark run <gate> --pull-request-gate` on
gx10-e3a3 (NVIDIA GB10, 119.6 GB, driver 580.126.09, CUDA 13.0). Two
environment notes on this box:

* The pinned qwen3.8 serve recipes are sized to dgx2's 121.7 GB. On this
  119.6 GB box the committed footprint exceeds the pinned budget
  (59.8 GB Atlas-own + 43.0 GB reserve vs 101.7 GB at 0.85), so
  decode-floor and bfcl-subset ran with --serve-override
  gpu_memory_utilization=0.92/0.75 — recorded inside each record.
* ttft-cold/ttft-warm had no prior baseline on this box; they record as
  info and become the reiner baselines.

bfcl-subset: FAIL at normalized 83.10 vs baseline 83.32 (overall 86.23).
This is the last-index-wins argmax regression inherited from 0775521 —
identical numbers to what #23 documents and db0bc09
fixes — not a dflash2 defect. Re-run after the argmax revert lands.

agentic-webserver and bfcl-subset-echolp not run on this box (their
subjects are the 3.6 checkpoints; download completed but runs were
declined pending a 3.8-scoped bench call).

* spark-model: clippy cleanup in dflash_head (div_ceil, doc list indent, needless borrow)

Pre-existing lints in the dflash2 bring-up, flagged by clippy 1.93 deny-all.

* scheduler: gate DFlash raw-argmax verify per sequence, not process-wide

The --dflash flag made raw-argmax verify apply to EVERY sequence. For sequences whose effective verify pick is not the raw argmax — presence/frequency/repetition penalties, LZ/DRY, grammar, or tool-call EOS suppression — the emitted stream silently followed the unpenalized argmax instead of the request's distribution. This target's non-thinking preset carries presence_penalty=1.5, so it was the common case, not an edge.

Now dflash_seq_uses_raw_argmax requires the process flag AND a neutral-greedy sequence (PenaltyGate::Neutral, no grammar, no require_tool_call). Other sequences fall back to the existing pipeline verify, matching what MTP does for the same request. Measured on GB10: identical prompts diverged vs serial only while penalties were active; byte-identical once zeroed.

Matches SGLang's reference dflash_worker_v2 semantics: verify logits get per-request adjustments (apply_dflash_verify_logits_adjustments) before acceptance; argmax accept-prefix is the greedy arm only.

* bench: gate records for 323a7e1 on reiner — 9 pass, bfcl-subset fails on the inherited argmax regression

Full suite re-measured on the review-fix head (per-sequence DFlash
raw-argmax gate + dflash_head clippy cleanup). gx10-e3a3, NVIDIA GB10
119.6 GB, driver 580.126.09, CUDA 13.0. decode-floor ran
--serve-override gpu_memory_utilization=0.92 and bfcl-subset 0.75 —
recorded in provenance — because the pinned budgets were sized for a
121.7 GB box.

bfcl-subset draws 86.23/83.10 for the third time in a row (9bafa47,
683a0db, 323a7e1): the last-index-wins argmax regression inherited
from 0775521, fixed by #23/db0bc097 — not a dflash2
defect. echolp on the 35B subject passes 87.85/87.90.

* greedy: restore first-index-wins argmax tie-breaking (kernel + host paths)

0775521 switched the greedy tie-break from "first strict maximum wins" to
"value descending, then higher vocabulary index" in argmax_bf16.cu and moved
the host verify argmax and the greedy logit processor to the same last-wins
rule. With BF16 logits at temperature 0 exact ties are common, so the rule
change moves tokens: on the bfcl-subset gate draw for unsloth/Qwen3.8-27B-
NVFP4 it flipped 9 of 207 replayed answers, cost 3 correct ones, and took
the checkpoint from 86.53/83.38 to 86.23/83.10 (bars 83.42/83.32) — main
itself fails its own committed record under the new rule. Reverting only the
kernel on top of main restored all nine samples; reverting the other
accumulation-order change in the same commit restored none.

First-index-wins is also what llama.cpp's greedy sampler and vLLM's
torch.argmax do, so it is the rule the recorded baselines and the other
engines share. This restores:
  * kernels/gb10/common/argmax_bf16.cu — the 61f6976 kernel, verbatim
  * scheduler/verify_pipeline_helper/argmax.rs — argmax_first_wins
  * scheduler/verify_pipeline_helper.rs, logit_processors/mod.rs — call the
    first-wins helper (spark_runtime::sampler::argmax_first_wins_f32)
  * atlas-kernels/tests/argmax_tiebreak_contract.rs — now locks the
    first-wins rule instead of the last-wins comparator

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* bench: gate records for 0bf70e9 on reiner — 9 pass; bfcl-subset FAIL 76.60 norm on nvidia subject

* spark-server: resolve --dflash-gamma from MODEL.toml when the flag is absent

The clap default (16) shadowed the target's `[dflash] gamma`, so every
recipe-driven `--dflash` serve ran γ=16 regardless of MODEL.toml — the
serve_args doc comment already admitted the fallback was unreachable.
Precedence now mirrors --num-drafts: flag → MODEL.toml → engine default
16, logged once at boot with its source. qwen3.8-27b's `gamma = 8` is the
measured Option-B optimum on this box (γ=8 ~22 tok/s vs γ=16 17.8, job 026)
and sidesteps the γ=16 second-sequence status-700 fault (job 040 bisect).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* kernels: copy DFlash2 + sink paged-attention kernels to strix-hip

Verbatim ports from kernels/gb10/common: dense_gemv_bf16_batchm,
dflash_batch_anchor_add, dflash_batch_markov, dflash2_conv,
dflash2_candidate_selector, and the three ATLAS_ATTN_SINKS paged
wrappers (sink / indirect_sink / batched_sink). The wrappers'
LOAD_KV_TILE already matches the strix atlas_cp16 idiom.

* atlas-kernels: extend argmax tie-break contract test to strix-hip

strix-hip/common/argmax_bf16.cu already implements first-index-wins
(it is byte-identical to the post-revert gb10 kernel); the contract
test now reads both per-hardware copies so the rule cannot silently
regress on either target.

* kernels: port batched/indirect/rope-override/sink support to strix-hip prefill header

Mirrors the four gb10 features the DFlash2 sink wrappers need, in both
the BR=32 kernel and the clamped _64 entry:
- non-const kv_len/q_offset; PREFILL_BATCHED gains cu_seqlens/kv_lens
  (fixing a pre-existing arity mismatch: ops::prefill_attention_paged_batched
  already passes them) plus the PREFILL_BATCHED_INDIRECT_ARGS
  batch_indirect_args parameter;
- VARLEN per-stream geometry (q_base_b, q_len_eff) and the indirect
  kv_len/q_offset override; q_batch_off now derives from q_base_b;
- q_rope_pos (batch_indirect_args[b*3+2], Q_ROPE_POS_OVERRIDE, default
  q_offset) feeding the softmax mask row and the sliding-window
  kv_block_lo loop bound;
- ATLAS_ATTN_SINKS epilogue: sink logit joins the denominator in
  smem_ml, acc_o rescaled via smem_resc on the PV C-fragment map.
Default-path codegen is unchanged: with no new macros defined the only
deltas are parameter const-ness and the q_len->q_len_eff rename
(q_rope_pos == q_offset there).

* strix: wire DFlash2 into MODEL.toml + serve-amd.sh

kernels/strix-hip/qwen3.8-27b/MODEL.toml gains the [dflash] section
(incoai/Qwen3.8-27B-DFlash2, gamma 8, window 4096, mask 248070, layers
[5,19,33,47,61]) now that the strix-hip tree carries the kernels; the
SCALE strix MODEL.toml keeps DFlash absent with a pointer to strix-hip.
serve-amd.sh adds DFLASH=1 (--dflash --draft-model, optional
DFLASH_GAMMA), mutually exclusive with the MTP --speculative args.

* kernels: register the strix-hip sink-prefill module renames

Dispatch asks for prefill_paged_sink / prefill_paged_indirect_sink
(the same [modules] renames gb10 declares); without them the new
wrappers registered under their raw inferspark_ stems and the DFlash
drafter load failed the startup kernel audit.

* strix: size the default GPU_UTIL for the DFlash2 drafter

The KV budget is computed before the ~5 GB drafter allocates, so the
0.88 default OOM'd the DFlash serve on gfx1151 (cuMemAlloc status 2,
4.2 GB free at a 635 MB request). Default to 0.80 when DFLASH=1;
explicit GPU_UTIL still wins.

* kernels: HDIM=128 builds of the DFlash sink paged-attention kernels

DFlash2 drafters run head_dim=128 (incoai config), but the sink
wrappers include prefill_paged_compute.cuh at the default HDIM=256:
the tile loaders' HDIM/8-chunk rows and the HDIM/16 QK contraction
then read the neighbouring head's data into every score. Adds the
_h128 variants (identical source, #define HDIM 128 before the
header include) on gb10 and strix-hip, with the prefill_paged_*_h128
module renames matching the existing convention. The batched variant
keeps its raw stem like its sibling.

* atlas-kernels: allow the 3.8-trained DFlash2 drafter in the qwen3.8 target test

The merge of main's target_resolution test asserted [dflash] absent on
qwen3.8-27b, but PR21 legitimately added incoai/Qwen3.8-27B-DFlash2 — a
drafter trained on 3.8 hidden states. The test now permits exactly that
draft_model and still rejects the 3.6-trained one.

* dflash: select paged sink attention kernels by drafter head_dim

The drafter KV cache is head_dim=128, but Option B dispatched the
HDIM=256 sink builds: tile loaders iterate HDIM/8 chunks per row and
the QK loop contracts HDIM/16 steps, so each row's dims 128..255 were
the neighbouring head's data contaminating every score — the likely
source of the Option-B acceptance drop. paged_sink_modules_for_head_dim
maps head_dim onto the _h128 builds (128) or the original names (256)
and bails otherwise; prefill_attn_dflash_fp8 stays HDIM-256-only
(flagged in-code). The acceptance effect is measured in the Strix
A/B matrix (strix:~/dp4a-ab/out/dflash-ab-*, this branch).

* dflash: route M<=8 drafter BF16 projections through the batched GEMV on gfx1151

Every drafter projection at decode runs at M=gamma rows (gamma <= 8), but
dense_gemm_bf16_pipelined is a 128-row M-tile WMMA GEMM — ~94% padded MMA
work on gfx1151's ~2-3.5 TFLOPS BF16 WMMA, which is why Option-B propose
measured ~358 ms/step on Strix (dflash-h128-20260915T1546Z). The
bandwidth-bound dense_gemv_bf16_batchm kernel (MAX_M 8) already covers
every gamma the drafter uses.

New drafter_dense_gemm() on BlockDiffusionDraftHead picks the batched
GEMV when m in 1..=8 and the arm is enabled (default ON under
cfg!(atlas_scale), OFF on NVIDIA; ATLAS_DFLASH_SMALL_M_GEMV=1|0
overrides). conv::prepare and selector::select_candidates now take a
gemm closure instead of a KernelHandle so callers choose the arm; the
legacy non-paged path passes a pipelined-GEMM closure unchanged.
precompute_ctx_kv routes both ctx GEMMs through it (prefill-time n is
large and falls through to the GEMM automatically). Both arms
accumulate in FP32 but are not bit-identical.

* strix: default the DFlash2 serve to the paged Option-B drafter path

* ci: keep dflash forward_block_layer under the 500-LoC cap

* docs(strix): DFlash2 speculative decoding on gfx1151 — port, measurements, known gaps

* strix: expose the SSM checkpoint interval as SSM_CKPT_INTERVAL

* docs(strix): record the DFlash2 ST-995 golden-draw result

* scripts(strix): DFlash2 A/B, leg and concurrency runners

* docs(strix): record the GB10 DFlash2 batched-concurrency gap

Job 132 concurrency-sweep (nvidia/Qwen3.8-27B-NVFP4, dflash=true +
Option-B, gamma=8, bs16, util 0.70): all cells ran clean but aggregate
throughput is flat ~24-25.6 tok/s at C1-C16 vs MTP 20.9->85.2 scaling.
Documented as known gap / future work in the porting log and committed
both gate records (concurrency-sweep + agentic-webserver).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Andrei Vogulkin <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
@github-actions github-actions Bot added the needs-rebase Conflicts with main — its green checks are NOT real (GitHub skips merge-commit workflows) label Sep 17, 2026
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Closing as superseded: this PR's DFlash2 work landed on main through the reviewed branch review/pr21-fixes, merged by #33 (95f674951, "DFlash2 speculative decoding: land #21 (review branch) + Strix Halo gfx1151 port, HDIM=128 Option-B fix"), with follow-ups #37 and #38. This branch's head (3416ba464) is not itself reachable from main because the review branch carried the fixes forward, hence GitHub shows it as CONFLICTING rather than merged.

Post-merge verification of the landed code (main @ da943853, DFlash2 γ=8 Option-B, nvidia/Qwen3.8-27B-NVFP4, pinned ST-995 golden draw, temp 0, no overrides): Windows 11 / gfx1151 / ROCm 10.0.0 — overall 85.43 / normalized 79.49, n=995, zero fault lines (run-1789814994376463100, 2026-09-19). The Linux gfx1151 rerun on the same commit is in flight and will be recorded with the BENCH.toml entries.

@AzeezIsh AzeezIsh closed this Sep 19, 2026
AzeezIsh added a commit that referenced this pull request Oct 28, 2026
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
AzeezIsh added a commit that referenced this pull request Oct 28, 2026
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Conflicts with main — its green checks are NOT real (GitHub skips merge-commit workflows)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant