[gfx1201] Enable quantization kernels for gfx1201#2351
Open
[gfx1201] Enable quantization kernels for gfx1201#2351
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
FP8 quantization operations fail on AMD gfx1201 (RDNA4) architecture due to three compatibility issues:
v_pk_mul_f32assembly instruction is not supported on gfx11/gfx12This PR enables FP8 quantization support on gfx1201 by addressing these incompatibilities.
Technical Details
1. FP8 Dtype Registration (
aiter/utility/dtypes.py)Added gfx1201 to the default FP8 dtype mapping to enable
torch.float8_e4m3fnsupport on RDNA4.2. Scalar Multiplication Fallback (
csrc/include/ck_tile/vec_convert.h)The
v_pk_mul_f32assembly instruction is not supported on gfx11/gfx12. Addedamd_scalar_mul_f32()function as a portable fallback:The conversion functions
fp32x2_t_to_fp8x2_tandfp32x2_t_to_int8x2_tnow conditionally use the scalar path:3. DPP Broadcast Replacement (
csrc/include/hip_reduce.h)DPP broadcast operations are not supported on gfx11/gfx12. Replaced with
rocprim::warp_shuffle()for cross-lane communication in:wave_reduce()- for WarpSize > 16 and WarpSize > 32 reductionsmultithread_reduce()- for 16-thread and 32-thread reduction pathsExample change:
4. Naive load to LDS fallback (
csrc/kernels/quant_kernels.cu)gfx12x Fallback to naive loading from global memory to LDS in
smooth_per_token_scaled_quant_kernel.Test Plan
Run the quantization test suite with various tensor sizes:
Test Result
All quantization tests pass successfully on gfx1201:
Submission Checklist