Repository navigation
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/25436
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Cancelled Job, 2 PendingAs of commit f22ee37 with merge base 9f49fe2 ( NEW FAILURE - The following job has failed:
CANCELLED JOB - The following job was cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
|
@claude /pr-review |
|
Claude finished @Gasoonjia's task in 36m 2s —— View job Request Changes: CI never runs the new sm_120 MXFP8 kernel and skips the emulation tests on the sm_89+ GPUs that use emulation, marked weights silently ignore the documented Detailed review of #25436SummaryThis PR adds a per-weight There are three main problems:
These findings come from reading the code. No kernels or tests were run. Code Quality
Testing
API Design
Backward Compatibility
RecommendationRequest Changes Blocking:
The other findings can be addressed in this PR or in a follow-up. Review progress
|
[ghstack-poisoned]
…n projections Pull Request resolved: #25436 `CudaNVFP4Tensor` gets an `act_dtype` attribute (serialized with the tensor) that selects how a linear treats its activations: - `fp4` (default): unchanged -- W4A4 where FP4 tensor cores exist, timed against W4A16 per shape. - `mxfp8`: prefill with K % 32 == 0 that the decode GEMV and the small-M buckets do not serve runs MXFP8 x MXFP8 with the weights still stored NVFP4 (`triton::nvfp4_mxfp8`; "MXFP8" rather than "W4A8", which elsewhere in the backend means INT8 activations). Decode never quantizes activations to FP4: M = 1 runs the W4A16 GEMV (on GPUs without FP4 conversion `nvfp4_auto_decode` times the INT8-activation W4A8 GEMV against it), and M = 2..16 (static, or dynamic bounded by 16) runs the small-M bucket ops `nvfp4_small_m_gemm_m{2,4,8,16}` with `weight_only=True` (only the BF16-activation `rows` and `w4a16` kernels), except decode-size M where the decode GEMVs serve it (with native FP4, and for `mxfp8` under `w4a8`). - `bf16`: weight-only, W4A16 on every path. MXFP8 numerics (`nvfp4_mxfp8.py`): - Activations: E4M3 elements with one UE8M0 scale per 32 elements along K, exponent `ceil(log2(amax / 448))`, so a block maximum never saturates. Note that the OCP MX specification and torchao default to `floor(log2(amax)) - 8`, which can clip the block maximum. - Weights: each tile is converted in registers -- E2M1 codes decode exactly to FP16 (`cvt.rn.f16x2.e2m1x2`), each K32 group gets `e = ceil(log2(6 * max|s16 pair| / 448))` (magnitude, so negative scale bytes convert correctly), each element becomes `code * (s16 * 2^-e)` in FP16 (exact) and is rounded once, to nearest even, to E4M3. Products with at most 4 significant bits stay exact (unless the pair's scales differ by about 2^10 or more and the smaller block lands in the E4M3 subnormal range); the rest move by at most half an E4M3 ulp. Inexact conversions are common: any code of magnitude 1.5, 3 or 6 times a normal K16 scale byte whose mantissa is 1, 3, 5, 6 or 7 (for a subnormal byte, mantissa 7 only). - `tl.dot_scaled` e4m3 x e4m3 with ue8m0 scales, FP32 accumulation, per-tensor scale in the epilogue. Hardware: the native kernel needs FP4 conversion and block-scaled FP8 MMA (sm_120), and the op raises without it. Elsewhere `mxfp8` prefill uses BF16 activations (W4A16, higher precision and faster); `ET_CUDA_NVFP4_MXFP8_EMULATE=1` instead emulates it on the dequant + BF16 GEMM path (`nvfp4_mxfp8_emu.py`): activation QDQ and weight dequant onto exactly the native kernel's MXFP8 grids, BF16 GEMM with FP32 accumulation, so the result differs from the native kernel by accumulation order and output rounding; NaN activations stay NaN as in the native kernel, and since it dequantizes, `ET_CUDA_NVFP4_PREFILL_IMPL=kernel` turns it off. Policies: marked weights follow `ET_CUDA_NVFP4_ACT=w4a16` (no MXFP8 or INT8 activations), `w4a8` (INT8-activation decode for mxfp8, which raises on ROCm like `fp4` weights; MXFP8 prefill stays), `ET_CUDA_NVFP4_PREFILL_IMPL` (`kernel` forbids dequant and runs `nvfp4_w4a16` where MXFP8 does not apply, `dequant` skips MXFP8) and `ET_CUDA_NVFP4_SMALL_M`, never take W4A4 (`w4a4` means `auto` for them), and keep the activation dtype under the FP32 prefill output policy (FP32 activations then run in BF16 instead of the dense FP32 fallback); under `w4a8` they keep the weight-only small-M buckets (above decode size for `mxfp8`); the `nvfp4_dispatch` docstring states this, and the `--nvfp4-attn-act` help and `act_dtype` docstrings point to it. Prefill that misses the MXFP8 path follows `ET_CUDA_NVFP4_PREFILL_IMPL` exactly as `fp4` weights under `w4a16` do: in `auto`, the fused W4A16 kernel with native FP4 or for static M <= 64, dequant + matmul otherwise (RTX 5090, M = 512, 52 layers: fused W4A16 141.5 ms vs dequant + matmul 168.1 ms per forward). `ET_CUDA_NVFP4_MXFP8_EMULATE=1` also runs decode on the W4A16 GEMV, so it reproduces SM120 numerics for the marked weights end to end (other weights still differ: SM120 `auto` may time W4A4 for them). Muse Glimmer: `export_solo.py --nvfp4-attn-act {fp4,mxfp8,bf16}` sets `act_dtype` on the attention projections (fused qko/qkv or q/k/og, v, o) and fails if there are none; FFN, embedding and lm_head keep their paths. Authored with Claude Code. Differential Revision: [D132444851](https://our.internmc.facebook.com/intern/diff/D132444851/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D132444851/)! ghstack-source-id: 481052930
|
Thanks.
|
|
@claude /pr-review |
|
Claude finished @Gasoonjia's task in 43m 57s —— View job PR Review: #25436Approve. Nothing blocks. Two dispatch docstrings are wrong for marked weights, the M=17 boundary is never asserted, four test gaps from round 6 are still open, the SM120 MXFP8 path at static M 17–64 has not been measured, and Detailed reviewSummaryThe PR does five things:
Nothing blocks. I reviewed the code without running it: no SM120 hardware was available, and nothing was executed. Code Quality
Testing
API Design
Performance
RecommendationApprove. None of these findings breaks behavior on shapes that can occur today. The docstring fixes and the M=17 assertion are one-line changes. The SM120 measurement and the round-6 test items can come in a follow-up. Todo
|
[ghstack-poisoned]
…n projections Pull Request resolved: #25436 `CudaNVFP4Tensor` gets an `act_dtype` attribute (serialized with the tensor) that selects how a linear treats its activations: - `fp4` (default): unchanged -- W4A4 where FP4 tensor cores exist, timed against W4A16 per shape. - `mxfp8`: prefill with K % 32 == 0 that the decode GEMV and the small-M buckets do not serve runs MXFP8 x MXFP8 with the weights still stored NVFP4 (`triton::nvfp4_mxfp8`; "MXFP8" rather than "W4A8", which elsewhere in the backend means INT8 activations). Decode never quantizes activations to FP4: M = 1 runs the W4A16 GEMV (on GPUs without FP4 conversion `nvfp4_auto_decode` times the INT8-activation W4A8 GEMV against it), and M = 2..16 (static, or dynamic bounded by 16) runs the small-M bucket ops `nvfp4_small_m_gemm_m{2,4,8,16}` with `weight_only=True` (only the BF16-activation `rows` and `w4a16` kernels), except decode-size M where the decode GEMVs serve it (with native FP4, and for `mxfp8` under `w4a8`). - `bf16`: weight-only, W4A16 on every path. MXFP8 numerics (`nvfp4_mxfp8.py`): - Activations: E4M3 elements with one UE8M0 scale per 32 elements along K, exponent `ceil(log2(amax / 448))`, so a block maximum never saturates. Note that the OCP MX specification and torchao default to `floor(log2(amax)) - 8`, which can clip the block maximum. - Weights: each tile is converted in registers -- E2M1 codes decode exactly to FP16 (`cvt.rn.f16x2.e2m1x2`), each K32 group gets `e = ceil(log2(6 * max|s16 pair| / 448))` (magnitude, so negative scale bytes convert correctly), each element becomes `code * (s16 * 2^-e)` in FP16 (exact) and is rounded once, to nearest even, to E4M3. Products with at most 4 significant bits stay exact (unless the pair's scales differ by about 2^10 or more and the smaller block lands in the E4M3 subnormal range); the rest move by at most half an E4M3 ulp. Inexact conversions are common: any code of magnitude 1.5, 3 or 6 times a normal K16 scale byte whose mantissa is 1, 3, 5, 6 or 7 (for a subnormal byte, mantissa 7 only). - `tl.dot_scaled` e4m3 x e4m3 with ue8m0 scales, FP32 accumulation, per-tensor scale in the epilogue. Hardware: the native kernel needs FP4 conversion and block-scaled FP8 MMA (sm_120), and the op raises without it. Elsewhere `mxfp8` prefill uses BF16 activations (W4A16, higher precision and faster); `ET_CUDA_NVFP4_MXFP8_EMULATE=1` instead emulates it on the dequant + BF16 GEMM path (`nvfp4_mxfp8_emu.py`): activation QDQ and weight dequant onto exactly the native kernel's MXFP8 grids, BF16 GEMM with FP32 accumulation, so the result differs from the native kernel by accumulation order and output rounding; NaN activations stay NaN as in the native kernel, and since it dequantizes, `ET_CUDA_NVFP4_PREFILL_IMPL=kernel` turns it off. Policies: marked weights follow `ET_CUDA_NVFP4_ACT=w4a16` (no MXFP8 or INT8 activations), `w4a8` (INT8-activation decode for mxfp8, which raises on ROCm like `fp4` weights; MXFP8 prefill stays), `ET_CUDA_NVFP4_PREFILL_IMPL` (`kernel` forbids dequant and runs `nvfp4_w4a16` where MXFP8 does not apply, `dequant` skips MXFP8) and `ET_CUDA_NVFP4_SMALL_M`, never take W4A4 (`w4a4` means `auto` for them), and keep the activation dtype under the FP32 prefill output policy (FP32 activations then run in BF16 instead of the dense FP32 fallback); under `w4a8` they keep the weight-only small-M buckets (above decode size for `mxfp8`); the `nvfp4_dispatch` docstring states this, and the `--nvfp4-attn-act` help and `act_dtype` docstrings point to it. Prefill that misses the MXFP8 path follows `ET_CUDA_NVFP4_PREFILL_IMPL` exactly as `fp4` weights under `w4a16` do: in `auto`, the fused W4A16 kernel with native FP4 or for static M <= 64, dequant + matmul otherwise (RTX 5090, M = 512, 52 layers: fused W4A16 141.5 ms vs dequant + matmul 168.1 ms per forward). `ET_CUDA_NVFP4_MXFP8_EMULATE=1` also runs decode on the W4A16 GEMV, so it reproduces SM120 numerics for the marked weights end to end (other weights still differ: SM120 `auto` may time W4A4 for them). Muse Glimmer: `export_solo.py --nvfp4-attn-act {fp4,mxfp8,bf16}` sets `act_dtype` on the attention projections (fused qko/qkv or q/k/og, v, o) and fails if there are none; FFN, embedding and lm_head keep their paths. Authored with Claude Code. Differential Revision: [D132444851](https://our.internmc.facebook.com/intern/diff/D132444851/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D132444851/)! ghstack-source-id: 481200154
[ghstack-poisoned]
|
CI update: the A10G Authored with Claude Code. |
|
@claude /pr-review |
|
Claude finished @Gasoonjia's task in 42m 38s —— View job PR Review: #25436Approve. Nothing blocks landing. The main new issue is that Detailed reviewSummaryThis PR adds a per-weight
All 11 changed files were reviewed. This was a static review only: running Python needed approval and no GPU was available, so nothing was executed. Code Quality
Infrastructure
Testing
API Design
Performance
RecommendationApprove. Nothing here blocks landing. The missing
|
[ghstack-poisoned]
|
Done.
Authored with Claude Code. |
Stack from ghstack (oldest at bottom):
CudaNVFP4Tensorgets anact_dtypeattribute (serialized with the tensor) that selects how a linear treats its activations:fp4(default): unchanged -- W4A4 where FP4 tensor cores exist, timed against W4A16 per shape.mxfp8: prefill with K % 32 == 0 that the decode GEMV and the small-M buckets do not serve runs MXFP8 x MXFP8 with the weights still stored NVFP4 (triton::nvfp4_mxfp8; "MXFP8" rather than "W4A8", which elsewhere in the backend means INT8 activations). Decode never quantizes activations to FP4: M = 1 runs the W4A16 GEMV (on GPUs without FP4 conversionnvfp4_auto_decodetimes the INT8-activation W4A8 GEMV against it), and M = 2..16 (static, or dynamic bounded by 16) runs the small-M bucket opsnvfp4_small_m_gemm_m{2,4,8,16}withweight_only=True(only the BF16-activationrowsandw4a16kernels), except decode-size M where the decode GEMVs serve it (with native FP4, and formxfp8underw4a8).bf16: weight-only, W4A16 on every path.MXFP8 numerics (
nvfp4_mxfp8.py):ceil(log2(amax / 448)), so a block maximum never saturates. Note that the OCP MX specification and torchao default tofloor(log2(amax)) - 8, which can clip the block maximum.cvt.rn.f16x2.e2m1x2), each K32 group getse = ceil(log2(6 * max|s16 pair| / 448))(magnitude, so negative scale bytes convert correctly), each element becomescode * (s16 * 2^-e)in FP16 (exact) and is rounded once, to nearest even, to E4M3. Products with at most 4 significant bits stay exact (unless the pair's scales differ by about 2^10 or more and the smaller block lands in the E4M3 subnormal range); the rest move by at most half an E4M3 ulp. Inexact conversions are common: any code of magnitude 1.5, 3 or 6 times a normal K16 scale byte whose mantissa is 1, 3, 5, 6 or 7 (for a subnormal byte, mantissa 7 only).tl.dot_scalede4m3 x e4m3 with ue8m0 scales, FP32 accumulation, per-tensor scale in the epilogue.Hardware: the native kernel needs FP4 conversion and block-scaled FP8 MMA (sm_120), and the op raises without it. Elsewhere
mxfp8prefill uses BF16 activations (W4A16, higher precision and faster);ET_CUDA_NVFP4_MXFP8_EMULATE=1instead emulates it on the dequant + BF16 GEMM path (nvfp4_mxfp8_emu.py): activation QDQ and weight dequant onto exactly the native kernel's MXFP8 grids, BF16 GEMM with FP32 accumulation, so the result differs from the native kernel by accumulation order and output rounding; NaN activations stay NaN as in the native kernel, and since it dequantizes,ET_CUDA_NVFP4_PREFILL_IMPL=kernelturns it off.Policies: marked weights follow
ET_CUDA_NVFP4_ACT=w4a16(no MXFP8 or INT8 activations),w4a8(INT8-activation decode for mxfp8, which raises on ROCm likefp4weights; MXFP8 prefill stays),ET_CUDA_NVFP4_PREFILL_IMPL(kernelforbids dequant and runsnvfp4_w4a16where MXFP8 does not apply,dequantskips MXFP8) andET_CUDA_NVFP4_SMALL_M, never take W4A4 (w4a4meansautofor them), and keep the activation dtype under the FP32 prefill output policy (FP32 activations then run in BF16 instead of the dense FP32 fallback); underw4a8they keep the weight-only small-M buckets (above decode size formxfp8); thenvfp4_dispatchdocstring states this, and the--nvfp4-attn-acthelp andact_dtypedocstrings point to it. Prefill that misses the MXFP8 path followsET_CUDA_NVFP4_PREFILL_IMPLexactly asfp4weights underw4a16do: inauto, the fused W4A16 kernel with native FP4 or for static M <= 64, dequant + matmul otherwise (RTX 5090, M = 512, 52 layers: fused W4A16 141.5 ms vs dequant + matmul 168.1 ms per forward).ET_CUDA_NVFP4_MXFP8_EMULATE=1also runs decode on the W4A16 GEMV, so it reproduces SM120 numerics for the marked weights end to end (other weights still differ: SM120automay time W4A4 for them).Muse Glimmer:
export_solo.py --nvfp4-attn-act {fp4,mxfp8,bf16}setsact_dtypeon the attention projections (fused qko/qkv or q/k/og, v, o) and fails if there are none; FFN, embedding and lm_head keep their paths.Authored with Claude Code.
Differential Revision: D132444851