Skip to content

qwen4_exp: release the nvidia pack's MTP expert FP8 sources after requant (~2.5 GB) - #78

Merged
AzeezIsh merged 1 commit into
mainfrom
fix/qwen4exp-mtp-fp8-reclaim
Sep 26, 2026
Merged

AzeezIsh merged 1 commit into
mainfrom
fix/qwen4exp-mtp-fp8-reclaim

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

On the nvidia Flash-Next pack the 512 MTP experts are per-expert FP8 block-scaled; the loader dequants each to BF16 and requants to NVFP4 through quantized_from_fp8. That helper frees its FP8 source only when BOTH global FP8 readers are off (GDN native-FP8 prefill — on by default — and the dense FP8 attention overlay), because those read dense linear_attn / self_attn tensors as FP8. No reader ever consumes a routed MoE expert as FP8, so for the MTP experts the source is dead weight: ~4.9 MB per expert, ~2.5 GB over 512 (estimate).

Evidence it matters: job 244 (GB10, main66) — with --speculative the nvidia pack reaches 104.6 GB pre-KV and refuses --gpu-memory-utilization 0.88 ("No memory left for KV cache"), so MTP currently needs util ≥ 0.93, which leaves little host headroom on a unified-memory box.

Change: after each MTP expert's three NVFP4 copies are built, reclaim its weight and weight_scale_inv (WeightStore::reclaim is idempotent and a no-op for tensors that are not resident). Weights used at inference are unchanged, so output must be identical.

Validation (queued on reiner)

  • pre-KV "Atlas-own" with --speculative: main66 vs this branch (expect ~−2.5 GB)
  • MTP boots at util 0.90 (and 0.88?) on this branch
  • greedy output byte-identical to main66 at util 0.93

Workstream: job #70.

🤖 Generated with Claude Code

…r requant

quantized_from_fp8 keeps its FP8 source whenever the GDN native-FP8 prefill
(default on) or the dense FP8 attention overlay is enabled, because those
read dense linear_attn / self_attn tensors as FP8. The nvidia Flash-Next
pack routes its 512 MTP experts through the same function, and nothing
ever reads a routed MoE expert as FP8 — so ~2.5 GB of FP8 source stayed
resident for no consumer. With MTP on, pre-KV reached 104.6 GB and the
serve refused util 0.88 (job 244). Reclaim each expert's weight and
weight_scale_inv right after its NVFP4 copy is built.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Validated (reiner job 256): Flash-Next nvidia NVFP4 with --speculative, same box, consecutive arms.

arm util pre-KV KV budget boot
main66 0.93 103.4 GB 3.1 GB ok
#78 0.93 101.1 GB 5.4 GB (+74 %) ok
#78 0.90 101.3 GB 1.7 GB ok (main66 cannot boot here)
#78 0.88 101.1 GB — refused: no memory left for KV

Marking ready for review.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Merged as part of the GB10 merge train (main 1ab38536b). The train was #78, #67, #68, #82, #83, then #89 and #90.

Gates on the combined tree:

  • ST-995 (job 280): PASS, 84.72 / 84.68 against bars of 82.72 / 81.65.
  • Agentic perf leg (job 298): VALID. 1007 of 1007 turns, 0 failed, 0 missing, 89 min.
  • Support matrix (job 346): green. Nemotron-3.5-Lightning NVFP4, Qwen3.6-35B-A3B NVFP4 and Qwen3.6-35B-A3B FP8 each boot with 0 unresolved lookups on main66 + fixes and on the train tree. Greedy probes are identical between the two trees (mean |Δlogprob| 0.0000), and 10k TTFT is equal or slightly faster.

Tree check: main has the same tree as the job-346 build (f8a04db1f): git diff is empty. main also differs from the tree the gates ran on (53f4a3d3a) only by the marker [expected_absent] declarations (f261446bd), which are TOML and tests only.

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.

1 participant