Repository navigation
Improve the dimension checks for the FP8 recipes - #2894
Conversation
[Medium impact] The changes affect low-precision GEMM and distributed gather workflows across several recipes. The PR still needs the remaining Findings
SummaryThe PR replaces shared FP8 dimension checks with recipe-specific checks.
Reviews (20) · Last reviewed commit: "Move the test" · Reviewed by Greptile |
|
/te-ci |
|
Please update the docs also |
|
Merged main and resolved conflicts for @ptrendx |
|
/te-ci |
kainzhong
left a comment
There was a problem hiding this comment.
CC told me that in this branch tests/pytorch/test_recipe.py:593-594 still uses the deleted is_quantizable() method. Other parts seem fine.
|
/te-ci |
1 similar comment
|
/te-ci |
Comments Outside DiffThese findings could not be posted inline.
|
|
/te-ci |
|
/te-ci |
Integrate recipe-aware FP8 and FP4 dimension checks while preserving main's current NVFP4 scale-swizzling helper. Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
5f85ea7 to
99bcbd6
Compare
|
/te-ci |
| rowwise_scale_inv_shape = [ | ||
| first_dim, | ||
| ceil_div(last_dim, MXFP8_BLOCK_SCALING_SIZE), | ||
| ] | ||
| columnwise_scale_inv_shape = [ | ||
| first_dim // MXFP8_BLOCK_SCALING_SIZE, | ||
| ceil_div(first_dim, MXFP8_BLOCK_SCALING_SIZE), | ||
| last_dim, |
There was a problem hiding this comment.
The relaxed new_zeros branch returns MXFP8 tensors with unpadded scale buffers. For (16, 16), it allocates rowwise scales of shape (16, 1). But MXFP8 dequantization uses a padded stride of 4 and reads scales for a full tile. Calling .dequantize() on this newly accepted result can read past the scale buffer.
Allocate scales with get_scale_shape, including its padding, rather than using only ceil-division.
timmoon10
left a comment
There was a problem hiding this comment.
Overall LGTM, with several nits.
| - Float8BlockScaling swizzle requires data_rows (first dim) % 4. | ||
| - NVFP4 RHT requires input first dim % 16 (subsumed by 32-elt alignment for training). | ||
| """ | ||
| if recipe_obj.delayed() or recipe_obj.float8_current_scaling(): |
There was a problem hiding this comment.
Should we also test BF16 GEMMs?
| if recipe_obj.delayed() or recipe_obj.float8_current_scaling(): | |
| if recipe is None: | |
| return (1, 8, 8, 8, 8, 8) | |
| if recipe_obj.delayed() or recipe_obj.float8_current_scaling(): |
There was a problem hiding this comment.
Why? This whole PR is about the quantized gemms.
Co-authored-by: Tim Moon <4406448+timmoon10@users.noreply.github.com> Signed-off-by: Przemyslaw Tredak <ptrendx@gmail.com>
Co-authored-by: Tim Moon <4406448+timmoon10@users.noreply.github.com> Signed-off-by: Przemyslaw Tredak <ptrendx@gmail.com>
Signed-off-by: Przemek Tredak <ptredak@nvidia.com>
|
/te-ci |
1 similar comment
|
/te-ci |
Since NVIDIA#2894, MXFP8 accepts a last dimension that is a multiple of 16, and a partial last block keeps its own scale, so rowwise tensors carry ceil(K / 32) scale columns. export_components now returns all of them instead of K // 32. Tests cover K = 48 and K = 16, including rows that are not a multiple of 32 and GEMM-swizzled scales. Signed-off-by: Bindu Bhargava R Chintam <bindubhargavareddy@gmail.com>
Description
Improved the dimension checks for the FP8 recipes. The old one was too restrictive and did not have any recipe-aware logic.
Dimension check changes
assert_dim_for_fp8_exec(utils.py)M % 8 == 0∧last_dim % 16 == 0, run before the recipe is knownMXFP8Quantizer::create_tensor/get_scale_shapefirst_dim % 32∧last_dim % 32last_dim % 16only (TMA 16 B alignment). Scale tensor usesDIVUPfor partial trailing blocksNVFP4Quantizer::create_tensor/get_scale_shapefirst_dim % 32∧last_dim % 32last_dim % 32always;first_dim % 16only when RHT is enabled (Hadamard block size)swizzle_block_scaling.cukerneldata_rows % 4 == 0data_rowscublaslt_gemm.cuMXFP8 pathlda % 16 == 0∧ldb % 16 == 0viamin_alignment_elements(dtype)usingtypeToNumBits(16 B alignment for FP8)cublaslt_gemm.cuNVFP4 pathlda % 32 == 0∧ldb % 32 == 0(16 B alignment for FP4 = 32 elements)cublaslt_gemm.cu1D block-scaled FP8 pathn % 8 == 0for the native 1D block-scaling pathis_quantizable→supports_quantized_allgather(mxfp8_tensor.py)% 32last_dim % 16; alsofirst_dim % 32when columnwise usage (block boundary across ranks)is_quantizable→supports_quantized_allgather(nvfp4_tensor.py)% 32last_dim % 32; alsofirst_dim % 16when columnwise usageFixes # (issue)
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: