Skip to content

CK Tile MXFP8 Group GEMM gfx1250#578

Open
aris134 wants to merge 18 commits into
gfx1250from
amartin/ck-mxfp8-group-gemm-gfx1250-clean
Open

CK Tile MXFP8 Group GEMM gfx1250#578
aris134 wants to merge 18 commits into
gfx1250from
amartin/ck-mxfp8-group-gemm-gfx1250-clean

Conversation

@aris134
Copy link
Copy Markdown
Contributor

@aris134 aris134 commented May 6, 2026

Description

This PR integrates CK Tile MXFP8 grouped GEMM backend with TDM into TE. Replaces 3rdparty/aiter with 3rdparty/rocm-libraries for the gfx1250 changes from CK.

Fixes # (16490)

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • Change A
  • Change B

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@aris134 aris134 self-assigned this May 6, 2026
@aris134 aris134 requested a review from matthiasdiener May 6, 2026 20:49
@matthiasdiener matthiasdiener added the ci-level 1 CI test level 1 label May 7, 2026
Comment thread tests/cpp/operator/CMakeLists.txt Outdated
test_dequantize_mxfp8.cu
test_dequantize_nvfp4.cu
test_cast_nvfp4_transpose.cu
test_ck_grouped_mxfp8.cu
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be for non CUDA only

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3db2e5a

// Currently only support cutlass group gemm on Hopper Arch
if (!(is_hopper && use_cutlass)) {
// if (!(is_hopper && use_cutlass)) {
if (!use_cutlass) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is CUDA path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted in 3db2e5a

@aris134 aris134 requested a review from ipanfilo May 11, 2026 13:11
Comment thread tests/pytorch/test_numerics.py Outdated
delay_wgrad_compute,
):
os.environ["NVTE_USE_CUTLASS_GROUPED_GEMM"] = "1"
os.environ["NVTE_ROCM_ENABLE_MXFP8"] = "1"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should only be set when the recipe we are testing is mxfp8.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Looking at the parametrization, MXFP8BlockScaling is only added to fp8_recipes when NVTE_ROCM_ENABLE_MXFP8=1 is already set before test collection. So setting it inside this test is redundant and also broader than intended. Removed in 746afea


// Treat TE tensors as generalized 2D matrices by flattening:
// (D1, D2, ..., Dn) -> (D1*...*D(n-1), Dn), consistent with TE Tensor::flat_*_dim.
static inline bool get_flat_2d_dims(const transformer_engine::Tensor& t,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-use get_flat_2d_dims from ck_grouped_gemm_common.h

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some portion of the code is already present in ck_grouped_gemm_common.h inside ck_grouped_gemm folder. What was the reasoning behind having a separate directory for ck_mx_grouped_gemm?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there really was not a good reason for this. I agree that it makes more sense to keep it all under the same directory, and re-use the common functions already defined in the shared header. I have made these changes in 175855d

@aris134 aris134 requested a review from sudhu2k May 20, 2026 00:49
Comment on lines +14 to +16
#ifndef CK_TILE_USE_OCP_FP8
#define CK_TILE_USE_OCP_FP8 1
#endif
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, where is this macro used?

Comment on lines +103 to +104
static float to_float(const bf16_t& x) { return static_cast<float>(x); }
static float to_float(const ck_tile::bfloat16_t& x) { return static_cast<float>(x); }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is ck_tile::bfloat16_t same as our bf16_t?

setenv("NVTE_ROCM_ENABLE_MXFP8", "1", 0);
}

static float to_float(float x) { return x; }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a float to float?

static float to_float(const bf16_t& x) { return static_cast<float>(x); }
static float to_float(const ck_tile::bfloat16_t& x) { return static_cast<float>(x); }

__device__ __host__ __forceinline__ float ref_gelu_unused(float x) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused? or unfused?

size_t a_idx = 0;
size_t b_idx = 0;

if (use_mxfp8) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on your test name I presume you wanted to test mxfp8 but here it looks like you wanted to cover non-mxfp8 as well?


cudaDeviceProp prop;
NVTE_CHECK_CUDA(cudaGetDeviceProperties(&prop, 0));
#ifdef __HIP_PLATFORM_AMD__
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not needed since NV upstream do not have this file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-level 1 CI test level 1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants