Repository navigation
Conversation
cf8ef21 to
a30d34a
Compare
Kh4L
left a comment
There was a problem hiding this comment.
Self-review (/review-pr-team), per the contributor self-review policy
Scoped to this PR's own increment (be5015649..8f6003694 as reviewed — the mxfp8 commit plus its ruff-format fix). The two layers below have their own posted self-reviews and were not re-reviewed.
The headline: the bf16 default path is a strict no-op and is safe, but the mxfp8 path could not complete setup() on any config in this repo, and on the model this work targets it quantized the MoE router. Four findings are fixed in a30d34a; six are left inline for your judgement because each needs a design decision I did not want to make unilaterally on someone else's design.
Fixed in a30d34a
- MoE routers were being quantized.
SKIP_WEIGHT_SUBSTRINGSheld"router"and"mlp.gate.", which between them miss most router spellings. A top-k router is a discrete argmax, so quantization error flips expert selection — a rollout/trainer policy divergence, the one failure an RL run can't absorb. Widened to.gate.+shared_expert_gate., coveringmlp.gate.(Qwen3-MoE, DeepSeek),block_sparse_moe.gate.(Mixtral),mixer.gate.(NemotronH/nanov3) and Qwen2-MoE's separate gate, while leavinggate_proj/gate_up_proj/shared_expert.gate_projquantized. The repo already draws this line inDEFAULT_NVFP4_IGNOREand the nanov3 recipe'sreal_quant_ignore. CONVERTER_VERSION→ 5, mandatory given (1)._quantization_fingerprinthashes the config knobs but not the module-level selection constants, so changing the skip list without bumping it silently reuses a cached checkpoint whose router is already quantized — while the refit, now skipping it, sends BF16 into a slot the engine loaded as MXFP8. See the inline comment on the fingerprint for the durable fix.convert_mxfp8requiredmodel.safetensors.index.json. That's every shipped SGLang recipe: all five run Qwen2.5-Math-1.5B-Instruct, which ships a singlemodel.safetensorsand no index._checkpoint_weight_namesin the same module already handled both layouts; the converter now takes the same branch.test_quantized_refit_requires_megatron_backendasserted nothing — only the two non-raising cases. Neutering the guard to a barereturnleft all 17 tests green. Plusruff checkfailures (two unused imports, three import-ordering) that the earlier ruff-format commit didn't cover butlint-checkwould have caught, and a 2025 copyright header on two files added in a 2026 commit.
Process disclosure
The adversarial pass ran but was unreliable to reach; several rounds produced nothing before it reported. It ultimately delivered, and it earned its place — it overturned my own fix. My first version of finding (1) enumerated block_sparse_moe.gate. and shared_expert_gate., which still left backbone.layers.N.mixer.gate.weight quantized — the router of NVIDIA-Nemotron-3-Nano-30B-A3B, the model this work targets. It caught that by fetching the real checkpoint's safetensors header and running should_quantize against the actual tensor names and shapes. The committed fix is its .gate. widening, not mine.
It also corrected the review in three other directions worth recording: it disputed a confidence-90 finding of chained .get() at grpo.py:1402 as a style note on code matching pre-existing house style exactly (dropped); it downgraded a coverage claim after showing three independent hand-rolled measurements disagreed on the denominator (so no percentage appears below); and it found one agent's cited test artifact did not exist, so that agent's numbers are not cited here.
Environment caveats
No GPU and no sglang/flashinfer installed, so nothing involving SGLang's or flashinfer's runtime behaviour was executed by anyone. Findings are marked traced-vs-executed inline. pytest could not run the repo suite (uv.lock is Linux-only on this machine); the new test file's assertions were verified by executing the real should_quantize against them, and the file will collect normally in CI, where transformers is a core dependency.
What would take this from "unexercised" to "shippable"
The PR body is candid that no mxfp8 run exists. In rough order of cost:
- One smoke run — GRPO + Megatron + SGLang +
scheme: mxfp8, 2–3 steps, on a sharded model. This alone exercises everything fixed above. - Round-trip correctness — per-token logprob agreement between the mxfp8 SGLang rollout and the Megatron policy on a fixed prompt batch. The existing sglang recipes already gate on
median(token_mult_prob_error) < 1.1, so the same number under mxfp8 vs the bf16 baseline is the natural A/B with no new tooling. - ≥3 refits, not 1, with the importance-sampling ratio logged per step — drift from quantizing during refit only shows after several updates.
- Throughput and memory A/B, bf16 vs mxfp8, same model/TP/batch. Without this there is no stated benefit.
- A run with
num_layers_at_start_in_bf16 > 0where the emittedconfig.jsonis inspected — the cheapest possible check, and it would have caught the layer-band issue flagged inline.
No docs/ page accompanies seven new user-facing config keys. docs/fp8.md is the natural home — it already documents the vLLM FP8 story including the equivalent layer-band knobs.
Generated by Claude Code
fdd2c03 to
84713d6
Compare
84713d6 to
f60ca44
Compare
f60ca44 to
3c88ad3
Compare
|
/ok to test 3c88ad3 |
3c88ad3 to
2e2bffe
Compare
|
/ok to test 2e2bffe |
…ation Signed-off-by: Serge Panev <[email protected]>
|
/ok to test 6e5e486 |
Merge current main to include the release changelog fix. Mark real MXFP8 checkpoint conversion tests with sglang so CI runs them with FlashInfer installed, while CPU checkpoint integrity checks remain in the base shard. Signed-off-by: fujial <[email protected]>
|
/ok to test 29d6e4c |
|
Hi @jQizhang could you help review this PR? Thanks! |
Reject pre-Blackwell CUDA tensors before FlashInfer launches its SM100-only quantization kernel. Keep real quantization checks on supported GPUs while exercising checkpoint serialization on CPU. Cover installed SGLang compatibility patches and repeated refits into persistent padded weight and scale buffers. Validation: 83 focused tests passed on CPU with 3 hardware-dependent skips; the H100 rejection regression passed in the prior GPU run. Ruff 0.9.9 lint and formatting checks pass. Signed-off-by: fujial <[email protected]>
|
/ok to test 0b9e32c |
jQizhang
left a comment
There was a problem hiding this comment.
Thanks for this contribution. I left a few comments inline, please take a look.
| raise ValueError( | ||
| "SGLang MXFP8 startup does not quantize in the Ray driver because its " | ||
| "base environment has no backend-specific FlashInfer package and may " | ||
| "have no assigned GPU. Run convert_mxfp8 offline in a GPU environment, " | ||
| "then set quantization.converted_model_path to the output directory. " | ||
| f"The deterministic cache path for this source and policy is {save_dir!r}." | ||
| ) |
There was a problem hiding this comment.
Does running MXFP8 inference require a pre-converted MXFP8 checkpoint? Why not take the vLLM path's approach, where the quantization config is injected through hf_overrides and the real weights arrive via refit?
If the offline conversion is required, could you add a converter script (e.g. examples/converters/convert_hf_to_mxfp8.py that reads --config) so users don't have to roll their own?
There was a problem hiding this comment.
SGLang needs the serialized E4M3 weights and UE8M0 scales at startup. The offline converter is in examples/converters/convert_hf_to_mxfp8.py. The SGLang MXFP8 section of docs/fp8.md has the Blackwell requirements and the conversion and training commands. The paired GB200 results are in #3614 (comment).
| converted_model_path: str | ||
| cache_root: str |
There was a problem hiding this comment.
This adds a user-facing feature (new config keys, offline conversion step, Megatron/Blackwell-only), but there are no docs for it: vLLM MXFP8 has a section in docs/fp8.md, SGLang isn't mentioned. Could you add a short SGLang MXFP8 section there (config keys, how to run the converter, requirements) and a one-line comment on converted_model_path / cache_root?
There was a problem hiding this comment.
Added the SGLang MXFP8 rollout and refit section to docs/fp8.md (Blackwell/Megatron requirements, offline converter command with examples/converters/convert_hf_to_mxfp8.py, training command, and precision/cache config keys), and added one-line comments on converted_model_path and cache_root in nemo_rl/models/generation/sglang/config.py.
| if real_quantization and ( | ||
| not torch.cuda.is_available() or torch.cuda.get_device_capability()[0] < 10 | ||
| ): | ||
| pytest.skip("FlashInfer MXFP8 quantization requires SM100 or newer (Blackwell)") |
There was a problem hiding this comment.
The only test here that runs real MXFP8 quantization doesn't actually run in CI. The real_quantization=True case skips below SM100, and the SGLang unit shard (L0_Unit_Tests_Sglang.sh) runs on H100 only, so it is always skipped. The remaining tests either mock quantize_mxfp8 or never reach the kernel, so FlashInfer is never called.
I also couldn't find any functional or nightly recipe that sets SGLang scheme: mxfp8 (the GB200 MXFP8 script only covers vLLM). So right now nothing in CI exercises real MXFP8 quantization or refit for SGLang.
Could you share a run on Blackwell at the current head: a few steps with refit, plus token_mult_prob_error next to a BF16 baseline? Ideally this also gets a GB200 test, like vLLM has in L1_Functional_Tests_GB200_MXFP8.sh.
There was a problem hiding this comment.
Ran Qwen3-0.6B on GSM8K on two GB200s, with three GRPO steps and three refits per mode. Per-step token_mult_prob_error was 1.0942, 1.0653, 1.0822 for MXFP8 on fb2bd2a and 1.0146, 1.0129, 1.0132 for BF16 on its parent 84d394b. Both modes had nonzero gradient norms on all three steps. The first MXFP8 warmup exposed a Qwen activation cast to FP8 before FlashInfer quantization. fb2bd2a fixes that cast. Both real FlashInfer checkpoint-layout tests also passed on GB200. The PR includes GB200 coverage for the kernels and the paired training recipe.
Signed-off-by: Serge Panev <[email protected]>
|
/ok to test 740d2e2 |
Signed-off-by: Serge Panev <[email protected]>
|
/ok to test 775fca1 |
Signed-off-by: Serge Panev <[email protected]>
|
/ok to test 84d394b |
Signed-off-by: Serge Panev <[email protected]>
|
/ok to test fb2bd2a |
Signed-off-by: Serge Panev <[email protected]>
Signed-off-by: Serge Panev <[email protected]>
|
/ok to test f126151 |
Signed-off-by: Serge Panev <[email protected]>
|
/ok to test 0b05d47 |
|
Hey @jQizhang — replied on the docs thread (discussion_r4780853121) pointing to the SGLang MXFP8 section in |
| logger.wandb_enabled=false | ||
| checkpointing.enabled=false | ||
| ) | ||
| for precision in bf16 mxfp8; do |
There was a problem hiding this comment.
Could we just run mxfp8 here? Also, could we add a train/gen_kl_error check here too?
| rows must be added immediately before swizzling and removed again before a | ||
| subsequent weight update. | ||
| """ | ||
| file_to_patch = _get_sglang_file("srt/layers/quantization/fp8.py") |
There was a problem hiding this comment.
Both _patch_sglang_non_gated_fp8_moe and _patch_sglang_mxfp8_moe_scale_layout edit fp8.py — could concurrent workers race here and overwrite each other? I haven't actually tested this, could you check it?
Original work: #3188 by @xiuhu17. Re-cut at his request; the original authorship and sign-offs are preserved.
Add MXFP8 SGLang rollouts with Megatron weight refit. Startup and refit share precision exclusions and weight/scale grouping; MoE router weights remain BF16. Startup requires a local checkpoint produced by the explicit offline GPU converter.
#3613 is merged. This PR contains the MXFP8 increment against main; #3615 builds on it.
Current main refresh
Head
321e18808b8b249ef2ae15f015a51262fdfbdddbincorporates maincfd9de9902bde17e93d6f7514b0789b907606a13. The merge is clean. The quantization core, checkpoint-selection and grouping modules are unchanged from the previous PR head. Dependency files and submodule pins match main.Historical GPU evidence: HSG job
6588661completed four Nemotron-3-Nano optimizer steps and four MXFP8 broadcast refits on three nodes / 12 GPUs, with decode CUDA graphs and the expected 2688-to-2816 hidden-size padding. That run predates this main refresh and does not validate the current head.Fresh CI is requested for the current commit. Maintainer review remains required.