[None][fix] Skip no-op MXFP4 weight padding - #17259
Conversation
555773f to
c18721e
Compare
(cherry picked from commit d856d74) Signed-off-by: Jiagan Cheng <jiaganc@nvidia.com>
c18721e to
8e2e342
Compare
|
/bot run |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughChangesMXFP4 quantization
Estimated code review effort: 1 (Trivial) | ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
PR_Github #63918 [ run ] triggered by Bot. Commit: |
|
The optimization is right — Before this PR w2_weight = maybe_pad_for_mxfp4(w2_weight, self.weight_alignment)
# Divide bias by tp_size as we shard along the hidden dimension.
w2_weight /= module.tp_size # in-placeOn This isn't a rare branch. That class has Concrete failure: NVFP4 TRTLLM-gen MoE with The sibling site at Two ways to close it, either is fine:
Same question for contiguity, if you want to check it: |
|
PR_Github #63918 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #63942 [ run ] triggered by Bot. Commit: |
Signed-off-by: Jiagan Cheng <jiaganc@nvidia.com>
|
/bot run --disable-fail-fast |
|
PR_Github #63985 [ run ] triggered by Bot. Commit: |
|
PR_Github #63942 [ run ] completed with state |
BowenFu
left a comment
There was a problem hiding this comment.
The aliasing issue I raised is closed. w2_weight = w2_weight / module.tp_size (quantization.py:5011) is out-of-place, so the no-op path can no longer divide weights["down_proj.bias"][expert_id] in the shared dict. I audited all 28 maybe_pad_for_mxfp4 call sites at this head — no other one mutates the returned tensor in place.
Also checked and cleared the contiguity worry raised earlier: the eight .view(dst.dtype) sites all reinterpret one-byte storage as another one-byte dtype (uint8 / float8_e4m3fn, and float4_sf_dtype is uint8), and view(dtype) only imposes stride requirements when item sizes differ — so dropping the F.pad copy can't break them. The new guard also preserves every case that used to pad.
Not blocking on it, but the full L0 run on c80388f (PR_Github #63985) hadn't reported when I looked — worth a glance before merge.
|
PR_Github #63985 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #64039 [ run ] triggered by Bot. Commit: |
|
PR_Github #64039 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #64085 [ run ] triggered by Bot. Commit: |
|
PR_Github #64085 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #64143 [ run ] triggered by Bot. Commit: |
|
PR_Github #64143 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #64258 [ run ] triggered by Bot. Commit: |
Description
Avoid materializing a duplicate MXFP4 weight tensor when its dimensions already satisfy the requested row and column alignments.
maybe_pad_for_mxfp4previously calledtorch.nn.functional.padeven when every padding width was zero. PyTorch still allocated a new tensor for that no-op, which duplicated already-aligned expert weights during Kimi K3 TP8 model loading and could stall server startup under memory pressure. Return the original tensor for the zero-padding cases while preserving the existing padding behavior for unaligned weights.Test Coverage
pre-commit run --files tensorrt_llm/_torch/modules/fused_moe/quantization.pyPR Checklist
PR description clearly explains what and why.
PR follows the TRT-LLM coding guidelines to the best of my knowledge.
No API changes, new dependencies, ownership changes, or architecture changes.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, comment
/bot help.Dev Engineer Review
maybe_pad_for_mxfp4skipsF.padwhen both dimensions meet MXFP4 alignment requirements. This avoids unnecessary allocation during Kimi K3 TP8 model loading. Padding remains enabled for unaligned weights.The MXFP4 TRTLLM-Gen
w2bias scaling now uses out-of-place division. This prevents mutation of shared bias tensors during reloads or retries.The change is limited to
tensorrt_llm/_torch/modules/fused_moe/quantization.py. No public declarations, configuration files, or test-list files changed.The no-op path should be checked for contiguous-tensor requirements because
F.padpreviously returned a contiguous tensor.Verdict: sufficient, with a follow-up check for downstream contiguous-tensor requirements.
QA Engineer Review
No test changes.