Skip to content

[ukernels] Add missing specializations on gfx942/gfx950 and associated e2e tests - #22446

Merged
sebvince merged 9 commits into
iree-org:mainfrom
sebvince:dynamic_shape_tests
Oct 29, 2025
Merged

sebvince merged 9 commits into
iree-org:mainfrom
sebvince:dynamic_shape_tests

Conversation

@sebvince

@sebvince sebvince commented Oct 28, 2025 •

Copy link
Copy Markdown
Contributor

The primary purpose of this PR is to add missing e2e tests to cover all combinations of ukernels. We have different ukernels for static and dynamic shapes, so this PR introduces an option to generate_e2e_matmul_tests.py that allows specifying the dynamicity of m, n, and k.

Since ukernels require specialization to be enabled (see PR #22425), this PR also adds the following missing specializations :

  • bf16 on gf942
  • f16, bf16, f8 on gfx950.

This will positively affect performance on dynamic shape matmuls without compile-time bounds information. For example :

  !A_size = tensor<?x4096xbf16>
  !B_size = tensor<4096x4096xbf16>
  !C_size = tensor<?x4096xf32>
  
  func.func @matmul(
  %A : !A_size, %B : !B_size) -> !C_size {
  %c0 = arith.constant 0 : index
  %cst = arith.constant 0.000000e+00 : f32
  %m = tensor.dim %A, %c0 : tensor<?x4096xbf16>
  %empty = tensor.empty(%m) : !C_size
  %C = linalg.fill ins(%cst : f32) outs(%empty : !C_size) -> !C_size
  %0 = linalg.matmul 
     indexing_maps = [affine_map<(m, n, k) -> (m, k)>, 
                     affine_map<(m, n, k) -> (n, k)>,// transpose
                     affine_map<(m, n, k) -> (m, n)>]
                     ins(%A, %B : !A_size, !B_size)
                     outs(%C : !C_size) -> !C_size
  return %0 : !C_size
  }

Before PR: Time (ms): 30.831274
After PR: Time (ms): 0.284123

@sebvince sebvince changed the title [ukernels] Add e2e tests to cover all combinaison of ukernels [ukernels] Add e2e tests to cover all combinations of ukernels Oct 28, 2025
@sebvince
sebvince marked this pull request as ready for review October 28, 2025 17:11
@sebvince
sebvince requested a review from kuhar as a code owner October 28, 2025 17:11
@sebvince
sebvince requested review from bjacob and jtuyls October 28, 2025 17:11

@bjacob bjacob left a comment

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.

There is a discrepancy between the PR title which suggests it's a test-only PR, and the PR contents that add new specialization patterns. I'm not competent to review those, so please get another reviewer for that.

@sebvince sebvince changed the title [ukernels] Add e2e tests to cover all combinations of ukernels [ukernels] Add missing specializations on gfx942/gfx950 and associated e2e tests Oct 29, 2025

@jtuyls jtuyls left a comment

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.

LGTM. The specialization patterns make sense to me as they are the same as the existing ones, just for different types. If you have any, it would be useful to list experimental result with and without these specialization patterns for the new gfx950 patterns in the PR description.

@sebvince

Copy link
Copy Markdown
Contributor Author

LGTM. The specialization patterns make sense to me as they are the same as the existing ones, just for different types. If you have any, it would be useful to list experimental result with and without these specialization patterns for the new gfx950 patterns in the PR description.

After some testing, I found that some f16 & bf16 configurations of pingpong are slower that the default path (independent from this PR). This is due to the fact that current pingpong uses MFMA_F32_16x16x16_F16 instead of MFMA_F32_16x16x32_F16. To keep in mind if we want to enable ukernels by default.
I've created a separate task to fix this : #22457

@sebvince
sebvince requested a review from bjacob October 29, 2025 14:09
@sebvince
sebvince merged commit b572d6f into iree-org:main Oct 29, 2025
bangtianliu pushed a commit to bangtianliu/iree that referenced this pull request Oct 30, 2025
…d e2e tests (iree-org#22446)

The primary purpose of this PR is to add missing e2e tests to cover all
combinations of ukernels. We have different ukernels for static and
dynamic shapes, so this PR introduces an option to
generate_e2e_matmul_tests.py that allows specifying the dynamicity of m,
n, and k.

Since ukernels require specialization to be enabled ([see PR
iree-org#22425](iree-org#22425)), this PR also adds
the following missing specializations :
- bf16 on gf942 
- f16, bf16, f8 on gfx950.

This will positively affect performance on dynamic shape matmuls without
compile-time bounds information. For example :

```
  !A_size = tensor<?x4096xbf16>
  !B_size = tensor<4096x4096xbf16>
  !C_size = tensor<?x4096xf32>
  
  func.func @Matmul(
  %A : !A_size, %B : !B_size) -> !C_size {
  %c0 = arith.constant 0 : index
  %cst = arith.constant 0.000000e+00 : f32
  %m = tensor.dim %A, %c0 : tensor<?x4096xbf16>
  %empty = tensor.empty(%m) : !C_size
  %C = linalg.fill ins(%cst : f32) outs(%empty : !C_size) -> !C_size
  %0 = linalg.matmul 
     indexing_maps = [affine_map<(m, n, k) -> (m, k)>, 
                     affine_map<(m, n, k) -> (n, k)>,// transpose
                     affine_map<(m, n, k) -> (m, n)>]
                     ins(%A, %B : !A_size, !B_size)
                     outs(%C : !C_size) -> !C_size
  return %0 : !C_size
  }
  ```
Before PR: Time (ms): 30.831274
After PR: Time (ms): 0.284123
bangtianliu pushed a commit to bangtianliu/iree that referenced this pull request Nov 19, 2025
…d e2e tests (iree-org#22446)

The primary purpose of this PR is to add missing e2e tests to cover all
combinations of ukernels. We have different ukernels for static and
dynamic shapes, so this PR introduces an option to
generate_e2e_matmul_tests.py that allows specifying the dynamicity of m,
n, and k.

Since ukernels require specialization to be enabled ([see PR
iree-org#22425](iree-org#22425)), this PR also adds
the following missing specializations :
- bf16 on gf942 
- f16, bf16, f8 on gfx950.

This will positively affect performance on dynamic shape matmuls without
compile-time bounds information. For example :

```
  !A_size = tensor<?x4096xbf16>
  !B_size = tensor<4096x4096xbf16>
  !C_size = tensor<?x4096xf32>
  
  func.func @Matmul(
  %A : !A_size, %B : !B_size) -> !C_size {
  %c0 = arith.constant 0 : index
  %cst = arith.constant 0.000000e+00 : f32
  %m = tensor.dim %A, %c0 : tensor<?x4096xbf16>
  %empty = tensor.empty(%m) : !C_size
  %C = linalg.fill ins(%cst : f32) outs(%empty : !C_size) -> !C_size
  %0 = linalg.matmul 
     indexing_maps = [affine_map<(m, n, k) -> (m, k)>, 
                     affine_map<(m, n, k) -> (n, k)>,// transpose
                     affine_map<(m, n, k) -> (m, n)>]
                     ins(%A, %B : !A_size, !B_size)
                     outs(%C : !C_size) -> !C_size
  return %0 : !C_size
  }
  ```
Before PR: Time (ms): 30.831274
After PR: Time (ms): 0.284123
pstarkcdpr pushed a commit to pstarkcdpr/iree that referenced this pull request Nov 28, 2025
…d e2e tests (iree-org#22446)

The primary purpose of this PR is to add missing e2e tests to cover all
combinations of ukernels. We have different ukernels for static and
dynamic shapes, so this PR introduces an option to
generate_e2e_matmul_tests.py that allows specifying the dynamicity of m,
n, and k.

Since ukernels require specialization to be enabled ([see PR
iree-org#22425](iree-org#22425)), this PR also adds
the following missing specializations :
- bf16 on gf942 
- f16, bf16, f8 on gfx950.

This will positively affect performance on dynamic shape matmuls without
compile-time bounds information. For example :

```
  !A_size = tensor<?x4096xbf16>
  !B_size = tensor<4096x4096xbf16>
  !C_size = tensor<?x4096xf32>
  
  func.func @Matmul(
  %A : !A_size, %B : !B_size) -> !C_size {
  %c0 = arith.constant 0 : index
  %cst = arith.constant 0.000000e+00 : f32
  %m = tensor.dim %A, %c0 : tensor<?x4096xbf16>
  %empty = tensor.empty(%m) : !C_size
  %C = linalg.fill ins(%cst : f32) outs(%empty : !C_size) -> !C_size
  %0 = linalg.matmul 
     indexing_maps = [affine_map<(m, n, k) -> (m, k)>, 
                     affine_map<(m, n, k) -> (n, k)>,// transpose
                     affine_map<(m, n, k) -> (m, n)>]
                     ins(%A, %B : !A_size, !B_size)
                     outs(%C : !C_size) -> !C_size
  return %0 : !C_size
  }
  ```
Before PR: Time (ms): 30.831274
After PR: Time (ms): 0.284123
Yu-Zhewen added a commit that referenced this pull request Dec 5, 2025
These matmul ukernel tests were originally introduced in #21383, but
they were unintentionally placed under the following condition:


https://github.com/iree-org/iree/blob/b973deabd2e4872c3127702b5c5b4b2b9c6d2992/tests/e2e/matmul/CMakeLists.txt#L2159

This condition conflicts with the test label `requires-gpu-cdna3`,
making the tests never run in any configuration.

Later, #22446 added new tests that correctly cover the f16/bf16 cases,
so the original ones are now redundant.

Signed-off-by: Yu-Zhewen <[email protected]>
keshavvinayak01 pushed a commit that referenced this pull request Jan 27, 2026
These matmul ukernel tests were originally introduced in #21383, but
they were unintentionally placed under the following condition:

https://github.com/iree-org/iree/blob/b973deabd2e4872c3127702b5c5b4b2b9c6d2992/tests/e2e/matmul/CMakeLists.txt#L2159

This condition conflicts with the test label `requires-gpu-cdna3`,
making the tests never run in any configuration.

Later, #22446 added new tests that correctly cover the f16/bf16 cases,
so the original ones are now redundant.

Signed-off-by: Yu-Zhewen <[email protected]>
Signed-off-by: Keshav Vinayak Jha <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants