Repository navigation
feat(qwen4_moe): Qwen4-35B-A3B config, tokenizer-compat fallback, and DFlash2 mHC capture - #458
Conversation
…, and DFlash2 mHC capture
…BF16 lm_head, and effort=off alias
…ed mHC, wire verify_d piecewise graphs, and enable scalar NVFP4 DFlash head
Eliminates the dominant multi-row bottlenecks observed on gfx1151
(run 47268706905, where K=8 DFlash2 verify ran ~81 ms/step vs ~41 ms C1):
- Allow dense_gemv_batchm (chunked <=8) for gated BF16 QKV projections
(tightening qkv_is_dense_bf16 to None | Dense only) with per-row
deinterleave_qg, avoiding N-way sequential weight reads at n=2..32.
- Port gb10 vectorized multi-token mHC kernels (hc_pre_{stage,down,finish}_vec*
and hc_post_vec) to strix-hip/hyper_connection.cu with plain vector loads
and enable ATLAS_QWEN4EXP_HC_FAST on HIP (still default off).
- Switch PLE slot upload from copy_h2d_async to copy_h2d_async_retained
so pinned staging no longer forces a per-step stream synchronize.
- Wire qwen4_exp piecewise graphs (decode_pieces, PieceStep::VerifyKgamma)
into K=gamma verify_d.rs with full-row kgamma_dflash_capture.
- Add w4a16_gemv_batch{4,8,16} fallback in DFlash project_head so
ATLAS_DFLASH_NVFP4_HEAD=1 works on strix-hip without tensor-core tiers.
- Batch BF16 MoE router GEMV in forward_rows_t when no router pre-norm.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…8_dyn_vl2_n2 in exact_rows, and retained DFlash markov H2D Fixes three gfx1151 bottlenecks pinpointed by prof-k8 (run 47278407115): - Lower strix-hip vectorized mHC ring depths (U=4, DN=2/1, FIN_UNROLL=4) and add __launch_bounds__(128) so T=5..8/rows stay in VGPRs without spilling (previously 321 us/site = 26.6 ms/step at K=8). - Route qwen3_ssm exact_rows FP8 projections at 5..=8 rows (and 8-row chunks on HIP) through ops::fp8_verify_gemv_tier (w8a16_gemv_batch8_dyn_vl2_n2) instead of high-VGPR w8a16_gemv_batch16. - Switch dflash_head/markov.rs seed_markov_prev from copy_h2d_async to copy_h2d_async_retained to remove the per-propose stream synchronize on the pinned staging buffer. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
AMD Strix Halo (
|
| Arm | Metric | Run 47268706905 (bf59e87a9, r3 baseline) |
Run 47278407115 (be6dc85f1, r4) |
Run 47289055632 (12e8cfa40, r5) |
|---|---|---|---|---|
| base (BF16 head) | C1 prose / code / json | 21.6 / 24.1 / 24.2 | 31.8 / 31.8 / 31.7 | 29.1 / 30.1 / 30.0 |
| base (BF16 head) | C2 / C4 / C8 agg | 44.3 / 66.3 / 80.4 | 51.2 / 68.7 / 69.9 | 50.4 / 70.6 / 80.2 |
| base (BF16 head) | prefill 7.4K / 29.4K | 1529 / 1394 tok/s | 1522 / 1389 (ctrl) · 1428 / 1310 (tuned) | — |
| mtp1 (K=2, BF16 head) | C1 prose / code / json | 36.6 / 42.9 / 40.9 | 45.3 / 53.6 / 50.3 | 43.6 / 51.9 / 48.8 |
| mtp1 (K=2, BF16 head) | C2 / C4 / C8 agg | 58.9 / 74.5 / 81.3 | 63.7 / 69.4 / 71.5 | 65.8 / 78.6 / 81.2 |
| mtp3 (K=4, BF16 head) | C1 prose / code / json | — | — | 34.6 / 46.2 / 41.5 (C4 78.0, C8 80.9) |
| dflash2 (BF16 target + NVFP4 drafter head) | think-on-512 |
67.9 (AL 5.28) | 56.0 (AL 5.0) | 65.7 (AL 5.0) |
| dflash2 (BF16 target + NVFP4 drafter head) | C1 prose / code / json | 22.7 / 36.0 / 27.4 | 25.9 / 35.0 / 28.6 | 26.6 / 43.2 / 29.9 |
| dflash2 (BF16 target + NVFP4 drafter head) | C2 / C4 / C8 agg | 35.3 / 44.9 / 80.6 | 36.7 / 43.9 / 70.8 | 39.5 / 47.7 / 77.0 |
| dflash2-fp4 (NVFP4 head) | think-on-512 |
67.0 (AL 5.05) | 59.8 (AL 5.1) | 70.4 (AL 5.1) |
| dflash2-fp4 (NVFP4 head) | think-math / think-code / think-prose |
— | 47.0 / 34.3 / 21.5 | 54.6 / 39.1 / 25.1 |
| dflash2-fp4 (NVFP4 head) | C1 prose / code / json | 25.1 / 39.2 / 29.3 | 29.0 / 33.9 / 31.2 | 29.8 / 38.4 / 31.8 |
| dflash2-fp4 (NVFP4 head) | C2 / C4 / C8 agg | 37.8 / 46.9 / 81.5 | 39.5 / 46.7 / 71.9 | 41.4 / 48.2 / 77.5 |
| dflash2-tuned | 21,103-tok 3-needle retrieval | — | 3/3 exact | 3/3 exact |
K=8 stage profile (prof-k8, ATLAS_QWEN4EXP_VERIFY_PROF=1):
hc_pre_attn/hc_pre_ffn: 321 / 322 µs → 131 / 131 µs (-59% / 2.45× faster across 81 mHC sites after RDNA3.5 zero-spill ring tuning in12e8cfa40, saving ~15.4 ms/step).moe+hc_post_ffn (rows): 711 µs/L (28.4 ms across 40L vs 18.9 ms roofline).QSA full-attn body: 336 µs/L (3.4 ms across 10L vs 2.5 ms roofline — BF16 gated QKV batching brought QSA to ~75% of ceiling).PLE gather: 3.29 ms → 0.48 ms (-85% viaATLAS_PLE_FAULT_POOL=1 ATLAS_PLE_CACHE_GB=4+copy_h2d_async_retained).PAGE-LOCKEDcopy_h2d_asyncwarnings: 0 across all 6 arms.- Note on host variance / open lever:
47278407115(X2-LA03-S04-D07) and47289055632(X2-LA03-S03-D06) ran on different ephemeral runners;GDN bodyinprof-k8measured 516 µs/L in r4 (w8a16_gemv_batch16) vs 605 µs/L in r5 (w8a16_gemv_batch8_dyn_vl2_n2), worth an interleaved same-runner A/B onexact_rows+ checking FP8 mHC (radiance#801idea) and FP8/NVFP4 dense trunk.
All workspace CI checks on 12e8cfa40 (cargo test --workspace, cargo llvm-cov, nvcc -> PTX (all gb10 targets), Linux x86_64/aarch64 CUDA builds, clippy, fmt, ≤500 LoC, SPDX) are green. Still draft / do not merge yet.
…AT=2 fused decode, DFlash ctx/conv scalar NVFP4, and OOTB serve-amd.sh Qwen4-35B-A3B defaults
Makes RadixArk/Qwen4-35B-A3B-NVFP4 (+ DFlash2) serve cleanly out of the box
on AMD Strix Halo (gfx1151) with zero manual env flags:
- Change --dflash-window-size to Option<usize> and resolve CLI -> MODEL.toml
[dflash].window_size -> drafter config.json sliding_window -> 4096 (so
Qwen4-35B-A3B inherits window=2048 automatically).
- Parameterize strix-hip qwen4exp_decode_fuse.cu on REPEAT and add _r2
fused GDN decode/rows kernels for Qwen4-35B-A3B's 16K/32V geometry.
- Generalize DFlash scalar w4a16_gemv_batch{4,8,16} NVFP4 fallback to
ctx_projection (ATLAS_DFLASH_CTX_NVFP4) and conv_delta_gemm
(ATLAS_DFLASH_CONV_TWIN=nvfp4) on targets without tensor-core tiers.
- Bump strix-hip HC_V_DOWN_DN8 / HC_V_WIDE_DOWN_DN from 1 to 2 for normed
load overlap at T=5..8.
- Add Qwen4-35B-A3B out-of-the-box profile defaults in serve-amd.sh
(fixing the MAX_BATCH>1 FP8_GDN override, avoiding the hardcoded 27B
DRAFT_MODEL, and enabling validated Strix flags when unset).
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Same-runner interleaved A/B on Strix Halo (run 47392973648, X2-LA03-S04-D08) showed plain w8a16_gemv_batch8 (VL2=0) beats w8a16_gemv_batch8_dyn_vl2_n2 at Qwen4-35B-A3B's K=2048 width by -2.62 ms/step on K=8 DFlash2 (76.78 / 76.66 ms controls vs 74.10 ms VL2=0) and +2.4 tok/s on C8 (92.7 / 92.6 vs 95.1 tok/s). Still overridable via ATLAS_GEMV_VL2=1. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Strix Halo (
|
Arm (all on X2-LA03-S04-D08) |
think-on-512 |
think-math/code/prose |
C1 prose / code / json | C2 / C4 / C8 agg | rows=8 med step |
21K needle |
|---|---|---|---|---|---|---|
ootb-mtp (./serve-amd.sh "$CK") |
36.1 (serial) | — | 44.7 / 53.5 / 51.6 | 68.2 / 79.1 / 92.7 | 79.9 ms | — |
ootb-dflash2 (DFLASH=1, ctrl1) |
68.7 (AL 5.0) | 41.4 / 40.5 / 31.1 | 31.0 / 43.4 / 32.1 | 42.2 / 50.9 / 92.7 | 76.78 ms | 3/3 exact (21,103 tok) |
ootb-dflash2-vl2off (DFLASH=1 ATLAS_GEMV_VL2=0) |
— | 40.4 / 41.2 / 23.4 | 31.2 / 37.9 / 32.9 | 41.9 / 51.0 / 95.1 | 74.10 ms | — |
ootb-dflash2-bf16head (DFLASH=1 LM_HEAD=bf16) |
— | 53.5 / 29.0 / 24.2 | 27.7 / 41.2 / 30.1 | 39.7 / 49.5 / 91.7 | 77.71 ms | — |
ootb-dflash2-ctrl2 (DFLASH=1, interleaved ctrl2) |
— | 41.5 / 37.5 / 24.7 | 30.0 / 38.9 / 33.6 | 42.6 / 51.3 / 92.6 | 76.66 ms | — |
Key verified outcomes:
- Zero-flag OOTB serving works end-to-end:
MODEL.tomlauto-resolvedRadixArk/Qwen4-35B-A3B-Dflash2,γ=8, andwindow=2048;serve-amd.shauto-armedqwen4exp_gdn_decode_fused_r2/_rows_r2(0x5),HC_FAST=1,FP8_GDN=1,DECODE_GRAPH=1+WIDE=1,PLE_CACHE_GB=4,DFLASH_SPEC_THINK=1,CTX_NVFP4=1,CONV_TWIN=nvfp4, and async DFlash uploads.PAGE-LOCKEDwarnings = 0 across all 6 arms. qwen4exp_gdn_decode_fused_r2/_rows_r2impact: Apples-to-apples BF16-head C8 jumped 77.0 → 91.7 tok/s (+19.1%) vs47289055632; serial C1 (ootb-mtp) jumped 30.2 → 36.1 tok/s.- Scalar NVFP4
ctx+convDFlash twins: Step tail (L39 + head + DFlash2 5L propose) dropped 16.09 → 14.22 ms (-1.87 ms/step). - Same-runner interleaved A/B (
ctrl1 → candidate → ctrl2, 0.15% drift):ATLAS_GEMV_VL2=0(w8a16_gemv_batch8) beatw8a16_gemv_batch8_dyn_vl2_n2by -2.62 ms/step on K=8 (76.78 / 76.66 → 74.10 ms) and +2.4 tok/s on C8 (92.7 / 92.6 → 95.1 tok/s). Locked in via10a14ba93(ATLAS_GEMV_VL2="${ATLAS_GEMV_VL2:-0}"for Qwen4-35B-A3B inserve-amd.sh).
…0.061 NLL drift Run 47402881193 KL gate showed quantizing Qwen4-35B-A3B's BF16 lm_head.weight to NVFP4 adds +0.061 prompt NLL (max |dlp|=0.930) and 3x higher decode KL for only ~0.9 ms/step (1.2%) on DFlash2. Keeping target LM_HEAD=bf16 (with ATLAS_DFLASH_NVFP4_HEAD=1 still accelerating the drafter head) preserves 0.0000 prompt NLL delta vs golden and removes the padded-stride warning. Still overridable via LM_HEAD=nvfp4. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Strix Halo (
|
Summary
PR (1/2) in the
Qwen/Qwen4-35B-A3Bbring-up stack (model_type = "qwen4_moe", 40L 3:1 GDN/QSA, 256E/8A,H = 2048, 1M native context, PLE n-gram, 1 MTP layer, ViT, DFlash2). Stacked with #459 (feat/qwen4-35b-a3b-targets).Adds the core config, tokenizer, and DFlash2 capture support needed to serve
Qwen/Qwen4-35B-A3BandRadixArk/Qwen4-35B-A3B-NVFP4(+RadixArk/Qwen4-35B-A3B-Dflash2):atlas-core):"qwen4_moe"and"Qwen4MoeForConditionalGeneration"indispatch.rstoparse_qwen4_exp(normalizing to"qwen4_exp").parse_ngram_pleinqwen4_exp.rs:make_ngram_vocab_size_divisible_bypads the summed per-head prime table (Qwen4ExpNgram::padded_rows), notngram_vocab_size_baseitself (Qwen4-35B-A3B usesngram_vocab_size_base = 10_000_000withmake_ngram_vocab_size_divisible_by = 512).Qwen/Qwen4-35B-A3Bconfig.jsontest fixture + parser unit test (qwen4_35b_a3b_tests.rs).tokenizer-compat/fallback &reasoning_effort = "off"(spark-server):tiktoken.modelat the repo root and places HFtokenizer.json,tokenizer_config.json, andchat_template.jinjaundertokenizer-compat/.ChatTokenizer::resolve_tokenizer_dirfallback totokenizer-compat/inload.rsandserve_phases/config.rs, and includestokenizer-compat/{tokenizer.json,tokenizer_config.json,chat_template.jinja}inmodel_download/plan.rs(+ unit test).enable_thinking = false/reasoning_effort = "none") to"off"when the loaded template accepts only('xhigh', 'high', 'low', 'off')(Qwen4'schat_template.jinjaraises on"none").spark-model+strix-hip+gb10):hc_contract_strided(FP32 stream-mean highway contraction) to bothkernels/strix-hip/qwen3.8-flash-next/nvfp4/hyper_connection.cuandkernels/gb10/qwen3.8-flash-next/nvfp4/hyper_connection.cu, and enablesqwen4_expalongsideglm5_nextinimpl_b3_dflash.rs/capture_rows.rs.Stack & How to Try / Contribute
feat/qwen4-35b-a3b-core→main)feat/qwen4-35b-a3b-targets→feat/qwen4-35b-a3b-core) — check outfeat/qwen4-35b-a3b-targetsfor the full runnable tree:Open Areas for Contributors
RadixArk/Qwen4-35B-A3B-NVFP4(+RadixArk/Qwen4-35B-A3B-Dflash2) on GB10, verifycargo test -p atlas-kernels -- --ignored, and audit any unresolved probes.nv / nk = 2):qwen4exp_decode_fusecurrently assumesGDN_REPEAT = 3(48V / 16Kon Flash-Next) and cleanly skips on32V / 16K; parameterizing arepeat = 2arm benefits both Strix Halo and GB10.tiktoken/encoding_qwen4.pyparity: Current PR uses the checkpoint's shippedtokenizer-compat/HF tokenizer + Jinja template; native anti-injectionencoding_qwen4.pyencoding is a clean follow-up.