add MXFP8 pre-swizzling for gfx1250 GEMM#568
Conversation
ddf19da to
313a6b7
Compare
| asm volatile("ds_swizzle_b32 %0, %1 offset:0x041F\n\t" | ||
| "s_waitcnt lgkmcnt(0)" : "=v"(r) : "v"(v)); | ||
| return r; | ||
| return __shfl_xor(v, 1); |
There was a problem hiding this comment.
Do we still need these helper functions now that we're just doing a __shfl_xor?
There was a problem hiding this comment.
This change is only inadvertently part of this PR, it is already part of #571. Will revert here.
| const int k = idx % K_scale; | ||
|
|
||
| uint8_t val = 127; | ||
| if (m < original_M && k < original_K) { |
There was a problem hiding this comment.
Could we move this check to the hostside, or remove it completely?
| #include <cstdint> | ||
|
|
||
| #include "../common.h" | ||
| #include "../util/cuda_runtime.h" |
There was a problem hiding this comment.
Why is this include needed?
| " (got shape=", shape, ")"); | ||
| #ifdef USE_ROCM | ||
| // gfx1250 MX pre-swizzle (Tensile 3D) layout requires M padded to multiple of 4. | ||
| // Other ROCm architectures use 128x4 tiles but currently skip padding |
There was a problem hiding this comment.
I'm not sure this is true regarding us using 128x4 tiles. 128x4 scaling is an upstream requirement. We also have padding expectations in pytorch, jax, and all 3 test dirs have padding that will probably need fixing.
| // Simple GPU reference kernel for MXFP8 GEMM: D = A * B^T (TN layout) | ||
| // A is [M, K] row-major, B is [N, K] row-major, D is [M, N] column-major | ||
| // Scales are E8M0, one per group of 32 elements along K. | ||
| __global__ void mxfp8_gemm_ref_kernel( |
There was a problem hiding this comment.
Why do we need a second mxfp8 reference kernel?
| class MxGemmSwizzleGfx1250TestSuite | ||
| : public ::testing::TestWithParam<MxGemmParams> {}; | ||
|
|
||
| TEST_P(MxGemmSwizzleGfx1250TestSuite, TestMxfp8GemmE2E) { |
There was a problem hiding this comment.
My understanding is we must swizzle scales for gfx1250. I think ideally we would fuse this with the existing mxfp8 GEMM tests -- pre-1250 we don't swizzle, 1250+ we do.
|
|
||
| #ifdef USE_ROCM | ||
| // On ROCm, only MXFP8 on gfx1250 needs scale pre-swizzling | ||
| if (scaling_mode != NVTE_MXFP8_1D_SCALING || transformer_engine::cuda::sm_arch() != 125) { |
There was a problem hiding this comment.
Sometimes we use == 125, sometimes >= 125. Should probably be consistent one or the other.
Description
Fixes https://github.com/ROCm/frameworks-internal/issues/16428
This was lightly tested on gfx1250.
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: