Skip to content

feat: Compatible K when not a multiple of 8 - #11537

Merged
illsilin merged 6 commits into
developfrom
users/fjimenez/ck/meta_gfx1250_K_dimension
Sep 21, 2026
Merged

illsilin merged 6 commits into
developfrom
users/fjimenez/ck/meta_gfx1250_K_dimension

Conversation

@JP-Fernando

@JP-Fernando JP-Fernando commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

When the K dimension is not aligned with the vector size of 8 (which is the case on gfx1250 for 16-bit datatypes), IsSupportedArgument is false, so the shape is rejected.

This is an unnecessary restriction, since the final partial K tile can be zero-padded safely. This PR allows supported GEMM configurations to process K%8 != 0 correctly.

Technical Details

This PR is currently scoped to gfx1250 architecture; RCR layouts; and the non-preshuffled ComputeV3 pipeline.

Update: We added the vector sizes of A/B/C as parameters to GemmConfig, as well as a FixedVectorSize switch.
Should K be a multiple of the operand's vector size, the existing GEMM configuration and loading mechanism are kept unchanged; otherwise, the call is re-dispatched through GemmConfigFixedVectorSize<>.

Test Plan

We extracted the provided shapes that satisfy N%128==0; K%8!=0 and tested them through tile_example_gemm_universal. We also built and ran test_ck_tile_gemm_pipeline_compv3_wmma to check for regressions.

Test Result

The tests were numerically validated on the Conductor a07-1 machine, which has gfx1250 architecture.

  • tile_example_gemm_universal: 13/13 passed
  • test_ck_tile_gemm_pipeline_compv3_wmma: 252 passed, 70 skipped, 0 failed

Submission Checklist

Closes #11537

@therock-pr-bot

therock-pr-bot Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass —
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —
🤖 therock-pr-bot ✅ Pass —

🎉 All checks passed! This PR is ready for review.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

therock-pr-bot Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

@JP-Fernando JP-Fernando changed the title feat: [gfx1250 Meta] Compatible K when not a multiple of 8 feat: Compatible K when not a multiple of 8 Sep 3, 2026
@JP-Fernando
JP-Fernando force-pushed the users/fjimenez/ck/meta_gfx1250_K_dimension branch from 1268e6a to 3c6c293 Compare September 4, 2026 11:22

@chris-tsiaousis-hpc chris-tsiaousis-hpc 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.

I've added comments/suggestions but my biggest concern is that there are no tests for K%8!=0. Please add them.

@JP-Fernando

Copy link
Copy Markdown
Contributor Author

I've added comments/suggestions but my biggest concern is that there are no tests for K%8!=0. Please add them.

Added new tests.

@chris-tsiaousis-hpc
chris-tsiaousis-hpc marked this pull request as ready for review September 18, 2026 11:20
@chris-tsiaousis-hpc
chris-tsiaousis-hpc requested a review from a team as a code owner September 18, 2026 11:20
@illsilin
illsilin enabled auto-merge (squash) September 21, 2026 14:25
@illsilin
illsilin merged commit 4ed0a80 into develop Sep 21, 2026
292 of 298 checks passed
@illsilin
illsilin deleted the users/fjimenez/ck/meta_gfx1250_K_dimension branch September 21, 2026 14:32
assistant-librarian Bot pushed a commit to ROCm/composable_kernel that referenced this pull request Sep 21, 2026
feat: Compatible K when not a multiple of 8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

## Motivation

When the K dimension is not aligned with the vector size of 8 (which is
the case on `gfx1250` for 16-bit datatypes), `IsSupportedArgument` is
`false`, so the shape is rejected.

This is an unnecessary restriction, since the final partial `K` tile can
be zero-padded safely. This PR allows supported GEMM configurations to
process `K%8 != 0` correctly.

## Technical Details

This PR is currently scoped to `gfx1250` architecture; RCR layouts; and
the non-preshuffled ComputeV3 pipeline.

Update: We added the vector sizes of A/B/C as parameters to
`GemmConfig`, as well as a `FixedVectorSize` switch.
Should `K` be a multiple of the operand's vector size, the existing GEMM
configuration and loading mechanism are kept unchanged; otherwise, the
call is re-dispatched through `GemmConfigFixedVectorSize<>`.

## Test Plan

We extracted the provided shapes that satisfy `N%128==0; K%8!=0` and
tested them through `tile_example_gemm_universal`. We also built and ran
`test_ck_tile_gemm_pipeline_compv3_wmma` to check for regressions.

## Test Result

The tests were numerically validated on the Conductor `a07-1` machine,
which has `gfx1250` architecture.

- `tile_example_gemm_universal`: 13/13 passed
- `test_ck_tile_gemm_pipeline_compv3_wmma`: 252 passed, 70 skipped, 0
failed

## Submission Checklist

- [X] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.

Closes #11537
@assistant-librarian

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

illsilin added a commit that referenced this pull request Sep 22, 2026
## Motivation

When the inner inner matrix dimensin is not aligned with the vector
loading size, the shape is rejected by `IsSupportedArgument`. To run
these shapes, a switch to scalar loading is necessary in these cases.

This PR builds upon: [feat: Compatible K when not a multiple of
8](#11537 (comment))
## Technical Details

There are two GEMM families affected: `universal` and `batched`. 

`Universal` GEMM: `gemm_utils.hpp` already has a shared `GemmConfigBase`
which every config inherits from, with `kPadM/N/K, FixedVectorSize,
VectorSizeA/B/C` all defaulting to `false/1`. A new config got added
which inherits from whichever `GemmConfig` is passed as a template
parameter and overrides just the mentioned fields.
`run_gemm_example_with_layouts` contains a decision tree: it computes
what configuration to pick based on the vector load size and the passed
shape.

`Batched` GEMM: `batched_gemm.hpp` configs are standalone structs with
no shared base class, they never had
`kPadM/N/K/FixedVectorSize/VectorSizeA/B/C` fields at all. A new config
is added that has these values, but to let `batched_gemm()` run with
either the pre-existing configs (which lack them) or the new one, an
SFINAE wrapper with field detection (GemmConfigVectorSizeDefaults) was
added. This resolves to the config itself if the field is present, or to
an all-`false/1` defaults struct otherwise, with the same overriding
mechanism as in `Universal` GEMM.

Closes: #11776

## Test Plan

<!-- Explain any relevant testing done to verify this PR. -->

## Test Result

<!-- Briefly summarize test outcomes. -->

## Submission Checklist

- [ ] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.

---------

Co-authored-by: Fernando Jiménez <fernando.jimenez@streamhpc.com>
Co-authored-by: Illia Silin <98187287+illsilin@users.noreply.github.com>
assistant-librarian Bot pushed a commit to ROCm/composable_kernel that referenced this pull request Sep 22, 2026
feat: support dimension sizes less than 8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

## Motivation

When the inner inner matrix dimensin is not aligned with the vector
loading size, the shape is rejected by `IsSupportedArgument`. To run
these shapes, a switch to scalar loading is necessary in these cases.

This PR builds upon: [feat: Compatible K when not a multiple of
8](ROCm/rocm-libraries#11537 (comment))
## Technical Details

There are two GEMM families affected: `universal` and `batched`.

`Universal` GEMM: `gemm_utils.hpp` already has a shared `GemmConfigBase`
which every config inherits from, with `kPadM/N/K, FixedVectorSize,
VectorSizeA/B/C` all defaulting to `false/1`. A new config got added
which inherits from whichever `GemmConfig` is passed as a template
parameter and overrides just the mentioned fields.
`run_gemm_example_with_layouts` contains a decision tree: it computes
what configuration to pick based on the vector load size and the passed
shape.

`Batched` GEMM: `batched_gemm.hpp` configs are standalone structs with
no shared base class, they never had
`kPadM/N/K/FixedVectorSize/VectorSizeA/B/C` fields at all. A new config
is added that has these values, but to let `batched_gemm()` run with
either the pre-existing configs (which lack them) or the new one, an
SFINAE wrapper with field detection (GemmConfigVectorSizeDefaults) was
added. This resolves to the config itself if the field is present, or to
an all-`false/1` defaults struct otherwise, with the same overriding
mechanism as in `Universal` GEMM.

Closes: #11776

## Test Plan

<!-- Explain any relevant testing done to verify this PR. -->

## Test Result

<!-- Briefly summarize test outcomes. -->

## Submission Checklist

- [ ] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
illsilin pushed a commit that referenced this pull request Sep 22, 2026
## Motivation

Fix the pipeline failure of gfx90a caused by the use of C++20 feature
std::type_identity in PR #11537.

## Technical Details

<!-- Explain the changes along with any relevant GitHub links. -->

## Test Plan

<!-- Explain any relevant testing done to verify this PR. -->

## Test Result

<!-- Briefly summarize test outcomes. -->

## Submission Checklist

- [ ] Look over the contributing guidelines at
https://github.com/ROCm/TheRock/blob/main/GOVERNANCE.md#pull-requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants