This repository was archived by the owner on Oct 6, 2026. It is now read-only.
Repository navigation
NVFP4-CSF: expand_scales() for ahead-of-call scale expansion - #477
Merged
voipmonitor merged 2 commits intoOct 4, 2026
Merged
Conversation
expand_scales(experts) expands every expert's NVFP4-CSF scales into the experts' scratch on the current stream (decode_all, the full expansion long prefills already use), and bind(..., scales_expanded=True) skips the per-call expansion. An integration whose layers share one scale scratch can expand the next layer on a side stream while that layer's attention runs, instead of serially before its MoE, where the expansion took 4% of a GLM-5.3 TP2 A4 prefill. Calls of the micro kernel, whose barrier reset is fused into the expansion, ignore the flag and expand as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 4, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
NVFP4-CSF layers share one scale scratch. Every eager prefill call expands its experts' scales into it serially, right before the MoE. In a GLM-5.3-Flash
glm53-tp2A4 prefill trace, those expansions took 4.1% of the GPU time with no kernel on any other stream overlapping them.This PR adds what an integration needs to move the expansion off the critical path:
fused_moe.expand_scales(experts)expands every expert's NVFP4-CSF scales into the experts' scratch on the current stream (Nvfp4CsfDecoder.decode_all). Long prefills already use this full expansion (mode 3), so the bytes are identical. It returns False and does nothing for experts without compressed scales.bind(..., scales_expanded=True)makes the call skip its own expansion. The caller orders the streams: after the previous user of the scratch, before the bound call. Calls of the micro kernel, whose barrier reset is fused into the expansion, ignore the flag and expand as before.vLLM (paired PR) expands the next layer's scales on a side stream while that layer's attention runs.
Evidence
glm53-tp2(stored QAD CSF checkpoint, TP2/DCP2 MTP3, DMA all-reduce) on two RTX PRO 6000 Max-Q, side-stream prefetch off vs on (two runs each):Decode is unchanged (it runs from CUDA graphs and reads compressed scales per stage). Needle-checksum with the prefetch, 3 salted runs each: A4 495, 490, 492 (492, 492, 490 before); A16 498, 495, 497.
Tests
tests/moe/test_nvfp4_csf.py,tests/moe/test_w4a16_a4_prefill.py,tests/quantization/test_nvfp4_csf.py: 84 passed on an RTX PRO 6000. Newtest_prefetched_scales_replace_the_per_call_expansion:expand_scalesthen restores the bit-exact native result.🤖 Generated with Claude Code