Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions tests/cpp/test_common.cu
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,17 @@ std::pair<scale_inv_meta, scale_inv_meta> get_scales(const NVTEShape& shape,
size_t scale_dim_X_colwise = DIVUP_TO_MULTIPLE(last_dim, scale_tensor_alignment_X_colwise);
ret_colwise.shape = {scale_dim_Y_colwise, scale_dim_X_colwise};

#ifdef __HIP_PLATFORM_AMD__
// gfx1250 MX pre-swizzle pads MXFP8 scales to a multiple of 4 in both dims
if (getDeviceComputeCapability() == 125) {
const size_t align = mxfp8_gfx1250_scale_tensor_alignment;
ret_rowwise.shape = {DIVUP_TO_MULTIPLE(ret_rowwise.shape[0], align),
DIVUP_TO_MULTIPLE(ret_rowwise.shape[1], align)};
ret_colwise.shape = {DIVUP_TO_MULTIPLE(ret_colwise.shape[0], align),
DIVUP_TO_MULTIPLE(ret_colwise.shape[1], align)};
}
#endif

ret_rowwise.type = DType::kFloat8E8M0;
ret_rowwise.type_size_bits = typeToNumBits(DType::kFloat8E8M0);
ret_colwise.type = DType::kFloat8E8M0;
Expand Down Expand Up @@ -1321,9 +1332,12 @@ std::array<size_t, 4> get_scale_tensor_dims(const size_t rows,
: nvfp4_scale_tensor_alignment_Y_colwise;
alignment_X = is_rowwise ? nvfp4_scale_tensor_alignment_X_rowwise
: nvfp4_scale_tensor_alignment_X_colwise;
} else if (scaling_mode == NVTE_MXFP8_1D_SCALING) {
// gfx1250 MX pre-swizzle requires MXFP8 scales padded to a multiple of 4 in both dims (1 on other architectures)
alignment_Y = alignment_X =
(getDeviceComputeCapability() == 125) ? mxfp8_gfx1250_scale_tensor_alignment : 1;
} else {
alignment_Y = 1;
alignment_X = 1;
alignment_Y = alignment_X = 1;
}
#else
const size_t alignment_Y = is_rowwise
Expand Down
2 changes: 2 additions & 0 deletions tests/cpp/test_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ constexpr size_t scale_tensor_alignment_X_rowwise = 1;
constexpr size_t scale_tensor_alignment_Y_rowwise = 1;
constexpr size_t scale_tensor_alignment_X_colwise = 1;
constexpr size_t scale_tensor_alignment_Y_colwise = 1;
// gfx1250 MX pre-swizzle pads MXFP8 scales to a multiple of 4 in both dims
constexpr size_t mxfp8_gfx1250_scale_tensor_alignment = 4;

// For nvfp4:
constexpr size_t nvfp4_scale_tensor_alignment_Y_rowwise = 128;
Expand Down
Loading