Repository navigation
DFlash2 speculative decoding: land #21 (review branch) + Strix Halo gfx1151 port, HDIM=128 Option-B fix - #33
Merged
Merged
Conversation
- 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>
…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).
…, needless borrow) Pre-existing lints in the dflash2 bring-up, flagged by clippy 1.93 deny-all.
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.
… 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.
…aths) 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]>
…76.60 norm on nvidia subject
… 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>
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.
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.
…p 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).
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.
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.
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.
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.
…arget 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.
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).
…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.
AzeezIsh
force-pushed
the
port/dflash2-strix-linux
branch
from
September 16, 2026 21:27
ec16983 to
a35abdb
Compare
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>
AzeezIsh
added a commit
that referenced
this pull request
Sep 18, 2026
The gfx1151 port landed on atlasinf/main added `try_kernel` probes for Strix-only kernels inside the shared dense_ffn / qwen3_attention / qwen3_ssm constructors — which every gb10 model instantiates too. The upstream kernel-resolution audit (phase 7, fail-closed) then refuses the boot with 12 unresolved lookups for (qwen3.8-27b, sm_121, nvfp4): w4a16_gemv_dp4a::* (9), w8a16_gemm_n_m128, w4a16::w4a16_gemm_t_m128_k16 and the dense_gemv_fp8w redundant probe. Every site is `handle != 0`-gated, so gb10 correctly falls back to the compiled w4a16_gemv / w8a16 / gemv_fp8w arms — these are absent BY DESIGN on sm_121 (porting them is a perf question for gfx1151, not a correctness one). Declare them [expected_absent] with stated reasons, mirroring the symmetric declarations strix-hip/*/MODEL.toml already carries for the gb10-only kernels it probes. This repairs a latent main-side regression the merge exposed: post-#33, no gb10 dense model could boot.
This was referenced Sep 18, 2026
Closed
2 of 3 tasks
andrew-vogulkin
added a commit
to andrew-vogulkin/atlas
that referenced
this pull request
Sep 29, 2026
…-absent The gfx1151 port (Atlas-Inf#9/Atlas-Inf#33) added a try_kernel probe for w4a16_gemm_t_m128_k16 in the shared dense_ffn constructor. 6f52a7d declared it [expected_absent] for gb10/qwen3.8-27b only; gb10/qwen3.6-27b, which qwen3.8-27b borrows its kernel tree from, was left out, so the kernel-resolution audit refuses to boot unsloth/Qwen3.6-27B-NVFP4 on GB10: 1 unresolved kernel lookup(s) for (qwen3.6-27b, sm_121, nvfp4) 1. w4a16::w4a16_gemm_t_m128_k16 at crates/spark-model/src/layers/dense_ffn.rs:450 That checkpoint is the required subject of the video-fidelity gate, so no video-fidelity record can be produced on main today. Same wording as the qwen3.8-27b entry; the site is handle!=0 gated and gb10 dispatches the compiled w4a16_gemm_t_m128 / w4a16_gemm arms. Found by the Atlas-Inf#91 gate campaign on GB10 (spark), 2026-09-29. Co-Authored-By: Claude Fable 5.1 <[email protected]> (cherry picked from commit 5668e8b)
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.
Summary
Lands DFlash2 speculative decoding for Qwen3.8-27B on both hardware sets in one merge:
review/pr21-fixes(a61f026: DFlash2 conv + bilinear candidate selector, SSM pool fix for K=γ,[dflash]pairing, per-sequence raw-argmax gate, first-index-wins argmax,--dflash-gammafrom MODEL.toml, 2.5h agentic perf runner) — merging this PR makes feat(dflash2): Qwen3.8-27B DFlash2 speculative decoding support #21's head reachable frommain, so feat(dflash2): Qwen3.8-27B DFlash2 speculative decoding support #21 closes as merged;Stacked on
origin/review/pr21-fixes+origin/main(clean merge). The Strix delta alone isgit diff origin/review/pr21-fixes...HEAD(~15 commits).Strix Halo port (
kernels/strix-hip,serve-amd.sh)dense_gemv_bf16_batchm,dflash_batch_{markov,anchor_add},dflash2_{conv,candidate_selector}, the threeinferspark_prefill_paged_*_sinkwrappers) and ported VARLEN / indirect-args /q_rope_pos/ sliding-window skip / attention-sink support into the gfx1151 WMMAprefill_paged_compute.cuh(both BR=32 kernels). This also brings the batched-prefill signature in line with the Rust dispatcher (pre-existing arity mismatch; untested at batch>1 — flagged in docs).kernels/strix-hip/qwen3.8-27b/MODEL.tomlgains the[dflash]pairing (incoai/Qwen3.8-27B-DFlash2, γ=8).serve-amd.sh:DFLASH=1 [DRAFT_MODEL=…] [DFLASH_GAMMA=…](forces MTP off, GPU_UTIL default 0.80 — 0.88 OOMs with the drafter resident),SSM_CKPT_INTERVALknob for long-context serving.mean_na3–6 on code/BFCL traffic).Engine defects fixed (apply to GB10 too)
_h128builds of the sink kernels (gb10 + strix-hip; nvcc-checked on sm_121) selected bypaged_sink_modules_for_head_dim. Strix A/B (dflash-h128-20260915T1546Z): mean_na 2.22–2.46 → 3.15–4.37, 5.35 → 7.57 tok/s. This is the leading candidate for the Option-B acceptance drop documented on GB10 (mean_na 5.54 → ~3.9) — hypothesis for GB10 until re-measured there.prefill_attn_dflash_fp8remains HDIM-256-only (flagged).dense_gemv_bf16_batchmon gfx1151 (cfg!(atlas_scale)default;ATLAS_DFLASH_SMALL_M_GEMV=1|0override; NVIDIA default unchanged). Propose 361 → 229 ms median at γ=8; off-arm control is bit-identical to the previous build.Measured on AzeezStrix (all fingerprinted;
docs/porting/QWEN38_STRIX_PORT.mdhas the full tables and outdir/fingerprint citations)tests/single_gpu_suite.py): coherence 3/3, fibonacci 1/1, tool calls 2/2, long-context 2/3 (the 16k>8192 harness artifact).DFLASH=1γ=8: overall 85.13 / normalized 78.41 (run-1789510215749772387, 5h04m, mean_na median 6.0 over 997 requests). Observations on other stacks: Strix MTP K=4 shipped-nvidia 83.22 / 79.02; GB10 nvidia MTP/n-gram 85.13 / 76.60 with the same simple_java 67.74 / simple_javascript 74.19 / hallucination profile (gap analysis §F.2 — checkpoint behaviour, not a code regression).dflash-agentic-20260915T2247Z, γ=8, 24K ctx, prefix caching, 20 Marconi slots); result will be appended to this PR when it completes (~03:00Z).Honest status on gfx1151
DFlash2 best observed 11.39 tok/s ≈ 0.5× MTP K=4 there: the K=γ+1-row verify lands on the float
w4a16_gemv_batch8/16tiers (verify 119 ms at K=5 → 292 ms at K=9) rather than the M=4 DP4A arm MTP uses, and propose is still ~190–230 ms vs a ~45 ms bandwidth estimate (rocprof ranking queued). MTP K=4 stays the default Strix recipe;DFLASH=1is opt-in. Acceptance collapses when the 4096-token drafter ctx window slides (observed at ~12.5K seq on the agentic leg).Known GB10 gate state (unchanged by this PR)
bfcl-subseton the nvidia subject fails its nvidia-calibrated normalized bar on both #21 and #23 (76.60; §F.2 — identical across branches and spec methods). The other 9 gates PASS onreview/pr21-fixes@ 0bf70e9 (records committed there).Test plan
cargo fmt --all -- --check; clippy (ATLAS_SKIP_BUILD=1) clean for spark-model / atlas-kernels / spark-server; typos clean; SPDX on every new file; ≤500 LoC capcargo test -p atlas-kernels37/37 (argmax tie-break contract now covers strix-hip; target_resolution allows only the 3.8-trained DFlash2 drafter on qwen3.8-27b);cargo test -p spark-model800 pass (incl.paged_sink_modules_for_head_dim,use_small_m_gemv)_h128kernels compile undernvcc -arch=sm_121 -Werror all-warnings(reiner)_h128kernels (ATLAS_DFLASH_OPTION_B=1) to confirm the mean_na hypothesisGenerated with Devin