Fix nvfp4 convert_and_update_tensor shape check#2670
Fix nvfp4 convert_and_update_tensor shape check#2670skydoorkai wants to merge 10 commits intoNVIDIA:mainfrom
Conversation
Signed-off-by: 乙划 <zht108229@antgroup.com>
for more information, see https://pre-commit.ci
Greptile OverviewGreptile SummaryFixes shape mismatch error in NVFP4 quantization when using N-dimensional tensors with both rowwise and columnwise quantization modes. Key changes:
Technical context: Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant NVFP4Quantizer
participant convert_and_update_tensor
participant compressShapeTo2D
User->>NVFP4Quantizer: quantize 3D tensor [32,4,128]
NVFP4Quantizer->>NVFP4Quantizer: Create rowwise data [32,4,64]
NVFP4Quantizer->>NVFP4Quantizer: Create columnwise data [128,64]
User->>NVFP4Quantizer: update_quantized()
NVFP4Quantizer->>convert_and_update_tensor: Validate shapes
convert_and_update_tensor->>convert_and_update_tensor: convert_shape_back_from_fp4(columnwise, true)<br/>Returns: [128, 128]
convert_and_update_tensor->>convert_and_update_tensor: convert_shape_back_from_fp4(rowwise, false)<br/>Returns: [32, 4, 128]
convert_and_update_tensor->>compressShapeTo2D: Compress rowwise [32,4,128]
compressShapeTo2D-->>convert_and_update_tensor: [128, 128]
convert_and_update_tensor->>compressShapeTo2D: Compress columnwise [128,128]
compressShapeTo2D-->>convert_and_update_tensor: [128, 128]
convert_and_update_tensor->>convert_and_update_tensor: Compare [128,128] == [128,128] ✓
convert_and_update_tensor->>convert_and_update_tensor: Use rowwise shape [32,4,128] as ground truth
convert_and_update_tensor-->>User: Success
Last reviewed commit: 075ebf6 |
Additional Comments (2)
|
|
@skydoorkai I think the comments from Greptile make sense (even though they are not very high priority). Could you fix those? Other than that LGTM. |
Signed-off-by: 乙划 <zht108229@antgroup.com>
for more information, see https://pre-commit.ci
Updated according to Greptile comments to add headers and compare 2D shapes. |
|
/te-ci pytorch |
Signed-off-by: 乙划 <zht108229@antgroup.com>
for more information, see https://pre-commit.ci
Description
This is to fix #2607
For nvfp4's columnwise data , it is using enforced 2D shape. Thus, the original check would fail if rowwise_data shape is 3D shape.
To fix :
(1) expected_data should be enforced into 2D shape from rowwise_data's shape.
(2) use rowwise_data's shape as the “ground truth" shape.
Fixes # (issue)
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: