Skip to content

qwen4-35b-a3b: ModelOpt loader, repeat-2 GDN fusion, batched MoE I=512, native tokenizer, and GB10 validation - #462

Open
maplepaladin73 wants to merge 13 commits into
Atlas-Inf:feat/qwen4-35b-a3b-targetsfrom
maplepaladin73:feat/qwen4-35b-a3b
Open

maplepaladin73 wants to merge 13 commits into
Atlas-Inf:feat/qwen4-35b-a3b-targetsfrom
maplepaladin73:feat/qwen4-35b-a3b

Conversation

@maplepaladin73

@maplepaladin73 maplepaladin73 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stacked on top of PR #459 (feat/qwen4-35b-a3b-targets), this completes Qwen4-35B-A3B-NVFP4 runtime support, kernel fusion, checkpoint-native tokenizer parity, and GB10 performance optimization:

  1. ModelOpt checkpoint & PLE compatibility (9a2f2cbf, 1dd9d66a, 29d7a126, 42445023)

    • Expand ModelOpt config_groups into quantization specs in atlas-core.
    • Accept Qwen4's FP32 scalar PLE table scale (ple_host.rs) and switch PLE pinned slot staging to copy_h2d_async_retained (eliminating per-gather cuStreamSynchronize stalls).
    • Download ModelOpt quantization sidecars (hf_quant_config.json) and Qwen4 native tokenizer artifacts (tiktoken.model, encoding_qwen4.py, tokenization_qwen4.py, qwen4_detector.py).
  2. Fused GDN repeat=2 decode, batched rows, exact verify, defer, and commit (e3d7fcbc, 81d32d0d)

    • Added __cluster_dims__(2, 1, 1) CUDA siblings (and Strix-HIP decode/rows siblings) for qwen4exp_gdn_decode_fused_r2, qwen4exp_gdn_decode_fused_rows_r2, qwen4exp_gdn_verify_fused_rows_r2, qwen4exp_gdn_verify_defer_rows_r2, and qwen4exp_gdn_commit_layers_r2, selected by nv/nk ratio.
    • Fixed atlas-closure quoted-include search roots so HIP compat headers are content-hashed and the vision_encoder.cu -> atlas_ptx_emu.h unresolved-include warning is eliminated.
  3. Qwen4 H=2048/I=512 MoE kernels, W4A4 prefill, batched FP8 LM head, and speculative defaults (d2af1378, f29e5a6c, d6a91555, 94d83984, 18605e5a, 42445023)

    • Added K=512 instantiations of qwen4exp_moe_rows_silu_down[_nc]_512, H=2048/I=512 instantiations of persistent TC v3 qwen4exp_moe_c8_tc3[_nc]_2048, and qwen4exp_moe_tcp_{gate_up[_nc],down}_2048.
    • Unlocked native FP4 tensor-core MoE prefill (ATLAS_QWEN4EXP_PREFILL_W4A4=1) on (2048, 512), skipping the 16.9 GiB routed-expert K-major transpose pass.
    • Wired dense_gemv_fp8w_batchm (up to 8 rows per weight pass, bit-identical per row) into lm_head_batched.rs and impl_a3.rs.
    • Set default_num_drafts = 2 (K=3 MTP optimum on GB10) in kernels/gb10/qwen4-35b-a3b/MODEL.toml, unclamped verify_max_drafts() on the qwen4_exp exact lane (K=3 for built-in MTP, K=8 for DFlash2), and wired 5..8-row FP8 GDN exact projections through fp8_verify_gemv_tier.
    • Parameterized qwen4exp_moe_w4a4_bench (QWEN4_35B=1, QWEN4_EP2=1) for Qwen4's 2048/512/top-8/256-expert geometry.
  4. Checkpoint-native segment-aware Qwen4 tokenizer (8dd3d93e)

    • Ported encoding_qwen4.py's Qwen4ChatEncoder as ChatEncoding::Qwen4 with an added-token-free plain_tokenizer for data segments (preventing control-token injection), reasoning_effort mapping (none → off), tool_call_id tool-result reordering, preserve_thinking, and multimodal marker triples.

Verification

CI / unit checks (rustc 1.93.1 on GB10)

  • cargo fmt --all -- --check — clean
  • ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests — zero warnings
  • bash scripts/check-license-headers.sh — 4,483 files checked, 0 invalid
  • Unit tests: atlas-kernels qwen4_35b_a3b_resolution (1/1); spark-model GDN defer (7/7), MoE (307/307), qwen4exp (96/96), exact_verify (20/20); spark-server tokenizer (126/126)
  • Token-ID parity vs Python encoding_qwen4.py + tokenization_qwen4.py (tiktoken.model): 4/4 fixtures identical (including <|im_end|> injection, out-of-order tool results, preserve_thinking=false, effort=none)

GB10 GPU kernel harnesses (sm_121)

  • qwen4exp_decode_fuse_bench (16k/32v, 8k/16v, 16k/48v, 8k/24v) — bitwise PASS
  • qwen4exp_batch_exact_bench.sh check & small-check (8k/16v, 16k/32v) — bitwise PASS
  • qwen4exp_batch_exact_bench.sh defer-check (8k/16v 843 commits, 16k/32v 879 commits) — bitwise PASS
  • QWEN4_35B=1 qwen4exp_moe_w4a4_bench.sh check (single-GPU EL=256 and EP2 EL=128) — PASS

GB10 runtime validation (RadixArk/Qwen4-35B-A3B-NVFP4, single GB10, release build 42445023)

  • Real-weight boot at 8 lanes × 262,144 context (3,258,608 max KV tokens, 62.2 GB BF16 KV after 16.9 GiB W4A4 transpose savings)
  • PLE long-context retrieval (9,985 tokens, NgramRowCache 92.7% hit, 0 evictions) + ATLAS_PLE_RESIDENT=1 PCND rejection on FP8 PLE
  • Vision (PNG) & video (animated GIF + --video-allow-ffmpeg)
  • Native tokenizer anti-injection live prompt + structured tool calling + reversed-order tool results
  • Single-host GB10 observations (f341, uncontended, --speculative default K=3, --lm-head-dtype fp8, 8 lanes × 262K, BF16 KV, MOE_TC=1, PREFILL_W4A4=1, BF16_GDN=0, DRAFT_HEAD_NVFP4=1, HC_FAST=1, MOE_NO_CLAMP=1, reasoning_effort=none, temp 0, median of n=3, 256 tok/stream):
    • Decode C=1..4:
      • C=1: 85.5 tok/s (82.8 wall), TPOT 11.7 ms, TTFT 101 ms
      • C=2: 118.4 tok/s (113.0 wall, 59.8/stream), TPOT 17.4 ms, TTFT 96 ms
      • C=3: 145.4 tok/s (136.3 wall, 48.7/stream), TPOT 20.6 ms, TTFT 97 ms
      • C=4: 158.7 tok/s (145.7 wall, 39.8/stream), TPOT 25.3 ms, TTFT 94 ms
    • Prefill (fresh prose, cached_tokens=0, chunk 8192): 3,330 tok/s @ 4K, 2,988 tok/s @ 8K, 2,869 tok/s @ 16K, 2,716 tok/s @ 32K.
    • Note: --kv-cache-dtype fp8/nvfp4 are blocked by QSA sparse attention's raw BF16 gather (QSA selection requires a plain BF16 KV cache); BF16 KV remains the required default.

Generated with Devin

AzeezIsh and others added 10 commits December 3, 2026 22:14
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Add repeat=2 CUDA/HIP fused GDN decode and batched-row variants, extend the exact harnesses, resolve HIP compatibility headers in closure attestations, and download Qwen4 native tokenizer reference artifacts.

Generated with [Devin](https://devin.ai)
Add __cluster_dims__(2, 1, 1) siblings for qwen4exp_gdn_verify_fused_rows,
qwen4exp_gdn_verify_defer_rows, and qwen4exp_gdn_commit_layers so Qwen4's
2:1 value/key-head ratio runs the fused exact-verify and deferred-commit
paths instead of falling back. Extend batch_small and gdn_defer parity
harnesses to validate Qwen4 TP1 (16k/32v) and TP2 (8k/16v) shapes.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Allow overriding H/I/TOPK/NE/EL via Q4_* macros and add QWEN4_35B=1
(plus QWEN4_EP2=1) in qwen4exp_moe_w4a4_bench.sh to validate Qwen4's
2048/512/top-8/256-expert geometry in both single-GPU and EP2 modes.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port encoding_qwen4.py's Qwen4ChatEncoder as ChatEncoding::Qwen4 so
protocol delimiters encode with special tokens enabled while user,
assistant, reasoning, and tool-body data segments encode on an
added-token-free tokenizer (preventing control-token injection).
Supports reasoning_effort mapping (including none -> off), tool-result
reordering by tool_call_id, preserve_thinking, and multimodal pads.

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

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

Add K=512 instantiations of qwen4exp_moe_rows_silu_down[_nc] and
H=2048/I=512 instantiations of qwen4exp_moe_c8_tc3[_nc], and wire them
into Qwen4ExpMoeRows and MoeLayer::rows_pair_eligible so Qwen4-35B-A3B
uses batched expert-sorted MoE on verify and multi-sequence decode
instead of falling back to per-row launches.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…..8-row FP8 GDN tier

Allow DFlash2 on the qwen4_exp exact batching lane to verify up to
DEEP_MAX_DEPTH (7 drafts) without requiring ATLAS_QWEN4EXP_MTP_DEPTH,
and route 5..8-row FP8 GDN exact projections through fp8_verify_gemv_tier.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh
AzeezIsh force-pushed the feat/qwen4-35b-a3b-targets branch from e1601ac to f5c8c5b Compare December 4, 2026 18:53
maplepaladin73 and others added 3 commits December 4, 2026 14:07
…512)

Templatize qwen4exp_moe_tcp_gate_up[_nc] and qwen4exp_moe_tcp_down for
H=2048/I=512 and admit (2048, 512) in forward_prefill_tcp and
forward_prefill_w4a4 so Qwen4-35B-A3B runs native FP4 tensor-core MoE
prefill and skips the 16.9 GiB routed-expert K-major transpose pass.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Use dense_gemv_fp8w_batchm (up to 8 rows per weight pass, bit-identical
per row to dense_gemv_fp8w) in lm_head_batched and the multi-token
verify head instead of looping dense_gemv_fp8w per row.

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

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

- Switch PLE slot staging copy from copy_h2d_async to
  copy_h2d_async_retained (backed by long-lived slots_pinned), avoiding
  a forced cuStreamSynchronize on every gather.
- Set default_num_drafts = 2 in kernels/gb10/qwen4-35b-a3b/MODEL.toml
  and allow K=3 built-in MTP on the qwen4_exp H=2048 exact lane without
  requiring ATLAS_QWEN4EXP_MTP_DEPTH=2.
- Silence the spurious non-TC units_fit warning when ATLAS_QWEN4EXP_MOE_TC=1
  is active on H=2048/I=512 (covered by tc3_2048).

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh
AzeezIsh force-pushed the feat/qwen4-35b-a3b-targets branch from f5c8c5b to 4f1be0b Compare December 4, 2026 19:31

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants