Repository navigation
qwen4_exp MTP: drafter BF16 attention and router, RNE draft quantizer, BF16 KV-only prompt rows - #267
Conversation
…under a mode Enntity's quantize_bf16_to_nvfp4_weight_rne (CUDA's nearest-even E4M3 scale and E2M1 conversion) had no kernel in this stack, so under ATLAS_QWEN4EXP_SERVING_MODE mode::weight_quantizer() named the standard converter and the draft copies did not carry Enntity's rounding. The kernel lands as a qwen3.8-flash-next shadow of common/'s quantize_bf16_to_nvfp4.cu (the common file included unchanged, one entry point added; body byte-identical to Enntity's glm-5.3-flash file, which Enntity shares into this target by symlink -- here the GLM target is left untouched). weight_quantizer() names it whenever a mode is selected, as Enntity's does, and the draft head's NVFP4 copy (ATLAS_QWEN4EXP_DRAFT_HEAD_NVFP4, Spark) now takes it like the MTP drafter already did. Unset: the standard converter everywhere, as before. Under draft TP both ranks build the head copy from the mode, which startup parity already pins. PDL lists unchanged. check_qwen4exp_kernel_names.py follows a shadow's .cu include (Enntity 7e056d6's translation_unit) so the included entry points still resolve. Ported from Enntity/atlas 9b25f57 (mode.rs weight_quantizer, qwen4exp_draft_head.rs, glm-5.3-flash/nvfp4/quantize_bf16_to_nvfp4.cu via f4d95a1/70c35846, scripts/dev/check_qwen4exp_kernel_names.py), AGPL-3.0-only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…_MTP_BF16_ATTN / _ROUTER) The MTP loader requantized the drafter layer's BF16 Q/K/V/O and router to NVFP4. ATLAS_QWEN4EXP_MTP_BF16_ATTN=1 builds the drafter body with attn_proj_bf16 (the --attn-proj-dtype bf16 arms) on its own TP=1 config only. ATLAS_QWEN4EXP_MTP_BF16_ROUTER=1 gives the drafter Enntity's MoE: the checkpoint's BF16 router (gate_nvfp4 None, on the scalar BF16 arms as Enntity runs it, not the target's row-invariant tiers) and the shared expert as an NVFP4 copy (mode::weight_quantizer) fused into the expert kernels, in place of this stack's NVFP4 router copy and BF16-native shared-expert chain. Enntity removed its _ROUTER switch when the BF16 router became its only drafter MoE (28611c0), so either serving mode selects it here too. Each switch is on only at 1; both default off, and unset (no mode) keeps today's drafter byte for byte. The target is untouched. Drafts only, on the drafting rank, so as in Enntity neither is a startup-parity setting. The switches are read in one place, helpers::MtpPrecision (Enntity's helpers.rs mtp_drafter_config / mtp_router_nvfp4 after 030ec26), with the lookup injectable for the unit tests. Ported from Enntity/atlas 15ecb5e, 030ec26, the drafter hunk of 28611c0 and the mtp.rs/helpers.rs hunks of 7e056d6 (AGPL-3.0-only). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…contract) With ATLAS_QWEN4EXP_MTP_BF16_ATTN implemented, the serving-mode drafter flags take Enntity's contract: Strict requires MTP_BF16_ATTN=1 beside DRAFT_HEAD_NVFP4=0, Spark MTP_BF16_ATTN=0 beside DRAFT_HEAD_NVFP4=1. The file header no longer lists the switch among the ones this stack lacks (and, since the previous commits, no longer says the RNE converter is missing). REQUIRED_FLAGS are unchanged. Ported from Enntity/atlas 9b25f57 mode.rs drafter_flags (7e056d6), AGPL-3.0-only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…PDL list It enters PDL before reading its inputs, as production lists it; the PDL list check fails without it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tches Under ATLAS_QWEN4EXP_MTP_BF16_ATTN=1 (Strict) the drafter's attention is BF16, and the KV-only rows of the MTP absorb and the prompt pass (ATLAS_QWEN4EXP_MTP_PREFILL) fell back to the full Q/K/V phase: every prompt row projected Q too, about 0.2 ms a token of Strict TTFT (2K 0.70 -> 1.34 s, 16K 3.9 -> 7.2 s on 03/04 against 0.4.0). K and V now go through dense_gemv_batchm in groups of up to eight rows (the scalar GEMV's K order and reduction tree), as in SparkQwen 0.4.0; Q is never read. Ported from Enntity/atlas 9263250 (production's dense_mx check is main's QuantWeight::Mxfp8, already excluded by the k/v weight checks); its GPU test reads production-only checkpoint helpers and is not carried. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> # Conflicts: # crates/spark-model/src/weight_loader/qwen4_exp/mode.rs
|
Thanks. Your merge hadn't reached the branch (the head was still dad0c33 and showed as conflicting), so I pushed the same thing: a normal Separately, I'm running the two FP4-Local gates its BENCH.toml declares (bfcl-subset ST-995 and agentic-webserver) on one GB10 each, at main + #267–#271, with the four switches on and off. I'll post the records here. 🤖 Generated with Claude Code |
|
Correction to my last comment: I'm not running the FP4-Local gates after all, so no gate records are coming from us. The pair checks you're running per PR are the verification. The 🤖 Generated with Claude Code |
|
@data-angel, a correction to my earlier note on this PR: the "conflict resolution" merge I mentioned went to a branch of the same name in Atlas-Inf ( Merged after the pair checks on main + #267…#271 (
#268's strict boot is being checked now. Our rc16 profile exports |
Part of #220. The qwen4_exp MTP drafter, as SparkQwen 0.4.0 runs it.
weight_loader/qwen4_exp/mode.rslisted what was missing for this.What
ATLAS_QWEN4EXP_MTP_BF16_ATTN=1: the drafter's own TP1 config getsattn_proj_bf16.ATLAS_QWEN4EXP_MTP_BF16_ROUTER=1, or either serving mode: the drafter MoE uses the checkpoint's BF16 router (no NVFP4 copy), and its shared expert becomes an NVFP4 copy fused into the expert kernels. This matches production's_ROUTER=1.quantize_bf16_to_nvfp4_weight_rne, qwen3.8-flash-next target):weight_quantizer()returns it under a mode;MTP_BF16_ATTN=1withDRAFT_HEAD_NVFP4=0; Spark requires=0with=1.ATLAS_QWEN4EXP_MTP_PREFILL) project K and V throughdense_gemv_batchmin 8-row groups.dense_mxcheck is main'sQuantWeight::Mxfp8, already excluded.Why
Strict on main drafted on NVFP4 attention. That flattered its speed, and it is not what SparkQwen serves. With BF16 drafter attention but without the KV-only rows, Strict's prompt pass projected Q for every row: cold TTFT was 1.34 s at 2K and 7.17 s at 16K, against 0.70 / 3.94 s on 0.4.0 (image
6f3b619ca2fe).Benchmarks
Fingerprint (every number below). ennspark03/04, two GB10s at TP=EP=2 over RoCE, 2026-10-29. Checkpoint
nvidia/Qwen3.8-Flash-Next-FP4-Local. Served by the SparkQwen launcher, profile8x32k(--speculative --num-drafts=7 --max-num-seqs=8 --max-seq-len=32768 --max-prefill-tokens=16384 --kv-cache-dtype=bf16 --gpu-memory-utilization=0.88 --enable-prefix-caching), Strict and Spark modes.Baseline: SparkQwen 0.4.0, engine
Enntity/atlas9b25f57, imageatlas-sparkqwen:3e0d9e7e4b29.Candidate:
Enntity/atlasenntity-stack/sq-integcf4200e = Atlas-Inf main a12bffa plus this PR series, imageatlas-sparkqwen:cc103bd6cc92.Harness: SparkQwen
bench/sq_bench.py: streamed, temperature 0,reasoning_effortlow; decode = 384-token prose/code/JSON, 3 reps; cold TTFT at 2K/8K/16K/28K, 2 reps; aggregate decode at C1–C8, 256 tokens per stream, 2 reps; warm 8K/20K conversations. Medians per cell. Plusgreedy_eq.py(8 prompts, 320 tokens, temp 0) andlp_dump.py(echo prompt logprobs at 1K/6K/20K tokens).Baseline and candidate arms interleaved on the same pair in one session.
One box and one harness, so these are observations under this fingerprint, not cross-validated claims.
With the KV-only rows, Strict cold TTFT came back to 0.677 / 3.95 s at 2K / 16K. That image also carried W4A4, worth about 0.3 s at 16K, so the two are not separated.
Under the whole series, the drafts that 0.4.0 makes give byte-identical outputs and the same decode speed in both modes (table below).
Whole series vs SparkQwen 0.4.0 (arms
q-040-*/q-fix-*):For reference, Atlas-Inf main c998a49 with the same launcher measured −9..−12% at C1, −15% at C2, −21..−25% at C4 and +21% cold TTFT against 0.4.0 (2026-10-29, same pair and harness).
Tests
MtpPrecisionswitch parsing, 4 tests;fmt,clippy,docand the atlas-kernels, spark-model and spark-runtime tests pass.attn_proj_bf16. It saves memory only (~13 MB a layer) and touches the shared attention builder.Authorship
AI-authored (Claude Code), ported from SparkQwen's AI-authored engine. No human-written code.
🤖 Generated with Claude Code