Repository navigation
qwen4_exp: Strict and Spark modes require SparkQwen's native-precision paths - #268
Merged
Merged
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]>
A serving mode now refuses to start unless ATLAS_QWEN4EXP_MXFP8_DECODE, _PREFILL_W8A8, _MXFP8_SHARED and _PREFILL_W4A4 are each 1: the tensor-core MXFP8 decode tiers, W8A8 prefill, the EP-split MXFP8 shared expert and the W4A4 routed prefill that make the modes serve SparkQwen 0.4.0's bytes. They stay opt-in outside a mode. (The switches arrive in their own PRs; this only checks the environment, so it builds without them.) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
Conflict with main resolved: normal |
Co-Authored-By: Claude Opus 5.5 <[email protected]> # Conflicts: # crates/spark-model/src/weight_loader/qwen4_exp/mode.rs
Co-Authored-By: Claude Opus 5.5 <[email protected]> # Conflicts: # crates/spark-model/src/weight_loader/qwen4_exp/mode.rs
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. Stacked on #267: review the top commit only. It needs #265 and #266 merged first; it builds without them, because it only checks the environment.
What
ATLAS_QWEN4EXP_SERVING_MODE=strict|sparknow refuses to start unless each of these is set to1:ATLAS_QWEN4EXP_MXFP8_DECODEATLAS_QWEN4EXP_PREFILL_W8A8ATLAS_QWEN4EXP_MXFP8_SHAREDATLAS_QWEN4EXP_PREFILL_W4A4Outside a mode they stay opt-in.
mode.rsloses its "no implementation here" paragraph.Why
A mode is the promise that SparkQwen serves 0.4.0's bytes. Those bytes need all four paths (Benchmarks in #265). Without this contract a mode could start on main's other numerics silently.
Benchmarks
None of its own. This is a startup contract; the series' measurements are in #265.
Tests
modes_require_the_native_precision_paths, written first: it failed, then passed.qwen_modetests pass.fmt,clippyanddocpass.Authorship
AI-authored (Claude Code). No human-written code.
🤖 Generated with Claude Code