Repository navigation
qwen4_exp: SparkQwen's MXFP8 decode tiers, W8A8 prefill and EP-split MXFP8 shared expert on FP4-Local (opt-in) - #265
Merged
Conversation
…ensor-core tiers
SparkQwen 0.4.0 decodes FP4-Local's MXFP8 projections (GDN qkvz/out,
attention, indexer, shared expert) on `mxfp8_gemv_tc{8,16,32}`; main serves
them on the CUDA-core `mxfp8_proj` GEMV tiers. With the switch at 1, every
1..=32-row `mxfp8_proj` launch (decode, verify, `mxfp8_proj_exact_rows`
chunks) takes the tensor-core tier for its width instead. Both families are
row-invariant; they sum in different orders, so the switch is in startup
parity. Unset keeps today's tiers byte for byte.
Kernels: SparkQwen's `glm-5.3-flash/nvfp4/mxfp8_gemv.cu` (a superset of
main's: tiled, multi, SwiGLU and B128 forms over the same tc core), its PDL
touch helpers, `common/mxfp8_act_quant.cuh`, and the qwen3.8-flash-next
`mxfp8_gemv.cu` that includes them plus the SwiGLU twins.
Tests: dispatch per row count (32-row launches, tail tiers), the launch ABI,
the switch parse, the GEMV fallback, and an ignored GPU test that every row
of an m-row tc launch (m = 1..=65) equals its 1-row launch at the four
FP4-Local TP2 shapes on realistic and hostile bytes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Lt W8A8 GEMMs SparkQwen 0.4.0 prefills FP4-Local's MXFP8 projections (GDN qkvz/out, attention q/k/v/o) as MXFP8 x MXFP8 GEMMs on cuBLASLt's block-scaled tensor cores; main expands each weight to BF16 per call and runs a BF16 GEMM. With the switch at 1 each layer carries an `MxPrefill` (the checkpoint's E4M3 bytes, scales relaid once at load into cuBLASLt's 128x4 tiles, 3% of the weight) and every prefill pass takes it; decode and verify are unchanged. The prefill mHC collapse writes the qkvz / q-k-v input's MXFP8 image in its epilogue (`hc_up_mix_bf16_nt_mx`) so those rows skip the quant pass. Ported from SparkQwen's engine (Enntity/atlas spark-shared 9b25f57): - spark-runtime: `fp8_gemm_act_weight_t_mx` and its tuned per-row-bucket in-order kernel choice (`mx_algo`, the invariance sweep `mx_sweep`, the pinned kernel split into `mx_pinned` for the file cap), `fixed_algo`'s MXFP8 / block-FP8 operands, and `kchain_pin::in_order`, which also stops the BF16 k-chain pin from taking a negative split-K kernel - the arena's FP8 scale scratch holds a tiled MXFP8 image of any row count - `ops::mxfp8_act` (activation quant, scale relayout), `ops::MxW8a8`, `ops::qwen4exp_w8a8` (the switch, the collapse producer slots) and `common/mxfp8_act_quant.cu` - the PDL list check reads `atlas_pdl_enter_touch_tri`, and the GLM list names the tiled, block-FP8 and multi MXFP8 tiers the shared kernel file now defines (inert unless ATLAS_PDL=1) Unset keeps main's prefill byte for byte. Opt-in (`1`), where SparkQwen's engine reads it as default-on; SparkQwen sets it. In startup parity. Tests: switch parse, the per-layer operand lookup, the producer slots, activation quant against a host reference (ModelOpt rounding), cuBLASLt tile offsets, bucket/sweep tables, and ignored GPU tests that the quant and relayout kernels write the host reference's bytes and that W8A8 rows do not depend on the pass height and stay within 5e-2 (rel L2) of the BF16 expansion at the FP4-Local TP2 shapes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pert
SparkQwen 0.4.0 serves FP4-Local's MXFP8 shared expert three ways main
does not: decode and verify rows on the tensor-core SwiGLU tiers
(`mxfp8_gemv_tc{8,16,32}_swiglu`, gate/up and SiLU * up in one pass, then
down on the plain tiers), prefill as W8A8 GEMMs under
ATLAS_QWEN4EXP_PREFILL_W8A8=1, and under EP each rank holding half the
intermediate (column-parallel gate/up, row-parallel down: the reference's
TP2 layout) with its partial joining the routed partial before the EP
all-reduce or reduce-scatter. On EP decode steps it runs on a side stream
forked at the MoE's entry, overlapping the router and routed experts.
With the switch at 1 the layer carries `SeparateSharedExpert::Mxfp8Native`
(`layers/moe/shared_mxfp8.rs`, loaded by `weight_loader/qwen4_exp/
shared_mx8.rs`). `MoeLayer::shared_joins_reduce` keeps the partial in every
EP blend (single row, row pair, T rows, batched, MOE_FAST) and stops
`forward_ep_reduce` adding a shared expert after the reduce; prefill blends
it before the reduce, or per row range inside the q38 reduce-scatter pipe.
The atomic C4 arm, whose finalize adds a whole shared expert, steps aside.
A call that finds the lane forked joins it and checks it writes the lane's
rows. Unset keeps main's shared expert byte for byte. In startup parity.
Ported from SparkQwen's engine (Enntity/atlas spark-shared 9b25f57:
f7ee11e, 789285e, 802eddd, 9507c06, 89ffeed), with
`ops::mxfp8_swiglu_rows` for main's MXFP8 weight type.
Tests: SwiGLU row launches (tiers, 32-row chunks, ABI, k refusal), the
decode and W8A8-less prefill launch order, and twin shape refusals.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… paths Two SP prefill overlaps that SparkQwen 0.4.0 runs and main skipped on FP4-Local (one profiled 16K cold prefill on 03/04: +60 ms routing, +21 ms GDN out_proj against 0.4.0): - ATLAS_QWEN4EXP_PREFILL_SP_ROUTE routed a rank's own rows only through the NVFP4 router copy, which FP4-Local does not build (its router stays the checkpoint's BF16), so every rank routed all rows after the gather. It now routes them on the BF16 router's tile GEMM, the kernel the whole-batch prefill router already runs (`MoeLayer::try_bf16_router_gemm`, one function for both), as SparkQwen does (Enntity/atlas 28611c0). - ATLAS_QWEN4EXP_PREFILL_SP_RS_PIPE piped out_proj by row ranges only on the dense BF16 arm; an MXFP8 layer has no `out_proj_dense`, so its out_proj and reduce-scatter ran back to back. Native MXFP8 on W8A8 pipes too: its rows are independent (per-row quant, in-order kernels), so every byte is the unsplit pass's (`out_proj_rows_independent`). The ranges compute on one stream, so they share the activation scratch in order. Tests: the BF16 router GEMM launches only on a flagged layer, one 128x128 tile grid; out_proj pipes on dense BF16 and W8A8 MXFP8, not on MXFP8's GEMV tiers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 30, 2026
Contributor
Contributor
|
Merged #265 and #266 (main
Each column is a single boot of the same binary; only the switches differ. With the switches unset, main's outputs are unchanged. Next is #267. It conflicts with main in |
data-angel
added a commit
to Enntity/atlas
that referenced
this pull request
Oct 30, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]> # Conflicts: # crates/spark-model/src/weight_loader/qwen4_exp/mode.rs
data-angel
added a commit
to Enntity/atlas
that referenced
this pull request
Oct 30, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]> # Conflicts: # crates/spark-model/src/weight_loader/qwen4_exp/mode.rs
AzeezIsh
added a commit
that referenced
this pull request
Oct 30, 2026
…ft quantizer, BF16 KV-only prompt rows Pair-gated (#220, wave1b/1c): switches unset -> no change to C1/C8 vs refs; with MTP_BF16_ATTN/ROUTER on top of the #265/#266 set, decode-floor 89.97-90.00 vs 89.25-89.36 without (observed, one boot each); Spark mode (NVFP4 draft attn) gives C1 identical to the BF16-draft run. CI green except the PR benchmark gate.
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.
Part of #220. This is the core of the SparkQwen-on-main series. With the whole series, SparkQwen 0.4.0 runs on Atlas main byte for byte and at the same speed (Benchmarks).
Series
Merge order: #265 → #266 (stacked on it) → #267 → #268 (stacked on #267; it requires #265 and #266) → #269, #270 and #271 in any order.
What
Three opt-in switches and two SP prefill fixes for
nvidia/Qwen3.8-Flash-Next-FP4-Local, ported from SparkQwen's engine (Enntity/atlasspark-shared 9b25f57). With each switch unset, main runs exactly as before.ATLAS_QWEN4EXP_MXFP8_DECODE=1mxfp8_projlaunch (decode, verify,mxfp8_proj_exact_rowschunks) runs on the tensor-core tiersmxfp8_gemv_tc{8,16,32}(mxfp8_gemv.cu) instead of the CUDA-core GEMV tiers.ATLAS_QWEN4EXP_PREFILL_W8A8=1fp8_gemm_act_weight_t_mx;mx_algo: a tuned in-order kernel per row bucket, row-invariant;mx_sweep,mx_pinned;kchain_pin::in_order, which also stops the BF16 k-chain pin from accepting a negative split-K kernel.hc_up_mix_bf16_nt_mx), so those rows skip the activation quant.ATLAS_QWEN4EXP_MXFP8_SHARED=1: the shared expert as SparkQwen serves it.silu_and_mulrounds them.MoeLayer::shared_joins_reducekeeps the partial in every EP blend (row, row pair, T rows, batched, MOE_FAST). The atomic-C4 arm steps aside._PREFILL_SP_ROUTEnow routes a rank's own rows on the BF16 router's tile GEMM. That is the kernel the whole-batch FP4-Local router already runs, now one function,try_bf16_router_gemm. Before, the lane needed an NVFP4 router copy that FP4-Local never builds._PREFILL_SP_RS_PIPEnow pipes a W8A8out_projby row ranges. Before, it neededout_proj_dense.The three switches are in startup parity. A
[job]issue is not opened for this series; the measurements are below.Why
On Atlas main c998a49, SparkQwen 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). These arms are where that time went:
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.Enntity/atlas9b25f57, imageatlas-sparkqwen:3e0d9e7e4b29.Enntity/atlasenntity-stack/sq-integcf4200e = Atlas-Inf main a12bffa plus this PR series, imageatlas-sparkqwen:cc103bd6cc92.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).This PR's own contribution is observed, not isolated: each arm was measured inside the stack.
6f3b619ca2fehad this PR's first three arms plus the PLE, RDMA and MTP PRs, but not W4A4 or the SP fixes. Against 0.4.0 it measured:ATLAS_PROFILE_FIRST=1), before vs after the fix:gate_gemm+topk+sort): 87.4 → 26.7 ms; 0.4.0's fusedroutetook 27.7 ms;out_proj: 179.9 → 147.5 ms;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).
Default. These stay opt-in because they change FP4-Local's bytes against main's current paths, which #198 chose. The measurement that would flip them on: the FP4-Local ST-995 and agentic-webserver gates with the series on vs off.
Tests
mx_algobucket tables and the sweep;#[ignore]):cargo fmt --check,cargo clippy --workspace --testsandcargo doc --workspace --no-depspass.cargo testpasses for spark-model and spark-runtime.cargo test --workspace --releasepassed.spark benchmark run --pull-request-gaterecords at this tip.Authorship
AI-authored. Claude (Claude Code) ported this from SparkQwen's engine, whose code is itself AI-authored. No human-written code.
🤖 Generated with Claude Code