Skip to content

fix(hiptensor): reject batched contraction with a shared A/B/D mode as NOT_SUPPORTED - #10826

Merged
harkgill-amd merged 6 commits into
developfrom
users/harkgill/hiptensor-reject-batched-contraction
Aug 20, 2026
Merged

fix(hiptensor): reject batched contraction with a shared A/B/D mode as NOT_SUPPORTED#10826
harkgill-amd merged 6 commits into
developfrom
users/harkgill/hiptensor-reject-batched-contraction

Conversation

@harkgill-amd

Copy link
Copy Markdown
Contributor

Motivation

Resolves ROCm/legacy-rocm-build#6559.

Technical Details

On hipTensor 2.3.0, a conventional batched contraction

D[b,m,n] = sum_k A[b,m,k] * B[b,k,n]

accepts valid descriptors and returns HIPTENSOR_STATUS_SUCCESS from every hipTensor call, but produces numerically incorrect output.

Check for batched contraction (see below) and return HIPTENSOR_STATUS_NOT_SUPPORTED until further support is added.

  std::set<int32_t> setB(modeBV.cbegin(), modeBV.cend());
  std::set<int32_t> setD(modeDV.cbegin(), modeDV.cend());
  for(int32_t m : modeAV)
      if(setB.count(m) && setD.count(m)) 

Test Plan

Build patched libhiptensor from source (develop @ 2.4.0, against nightly CK) on an MI300A (gfx942) node, then run two cases on real hardware:

  1. Batched contraction -> expect NOT_SUPPORTED after patch.
  2. Non-batched GEMM -> expect unchanged SUCCESS.

Test Result

  • With patch applied, batched contraction correctly returns as not supported meanwhile, non batched GEMMs see no change as expected.

Submission Checklist

@harkgill-amd
harkgill-amd requested a review from a team as a code owner August 14, 2026 20:22
@harkgill-amd
harkgill-amd requested a review from Ryker0627 August 14, 2026 20:23
@therock-pr-bot

therock-pr-bot Bot commented Aug 14, 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

Copy link
Copy Markdown

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

Comment thread projects/hiptensor/library/src/contraction/hiptensor_contraction.cpp Outdated
Comment thread projects/hiptensor/library/src/contraction/hiptensor_contraction.cpp Outdated
@harkgill-amd
harkgill-amd requested a review from Ryker0627 August 19, 2026 14:14

@evedovelli evedovelli 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.

@harkgill-amd Would it be possible adding a couple of unit tests to verify that the batched contraction properly returns NOT_SUPPORTED for binary and trinary contractions?

@harkgill-amd

Copy link
Copy Markdown
Contributor Author

@harkgill-amd Would it be possible adding a couple of unit tests to verify that the batched contraction properly returns NOT_SUPPORTED for binary and trinary contractions?

Added the following three test cases,

  1. BinaryBatchedReturnsNotSupported
  2. BinaryNonBatchedIsSupported
  3. TrinaryBatchedReturnsNotSupported

All are self-explanatory and pass various inputs to trigger either the HIPTENSOR_STATUS_NOT_SUPPORTED paths added in this PR or the existing/valid HIPTENSOR_STATUS_SUCCESS paths.

Tested all of these on a gfx942/MI300A system w/ the latest TheRock nightlies + hipTensor build from source. All tests pass as expected.

@evedovelli evedovelli 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.

Thank you so much for adding the tests! I've left one last ask, if you have the time to work on it. The changes look good for me but I'll leave to @Ryker0627 for approving.

Comment thread projects/hiptensor/test/00_unit/CMakeLists.txt
Comment thread projects/hiptensor/test/00_unit/batched_contraction_test.cpp Outdated

@Ryker0627 Ryker0627 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.

It looks good to me. Thank you for the time and effort you put into this!

@harkgill-amd
harkgill-amd merged commit d784d6e into develop Aug 20, 2026
108 of 114 checks passed
@harkgill-amd
harkgill-amd deleted the users/harkgill/hiptensor-reject-batched-contraction branch August 20, 2026 17:23
assistant-librarian Bot pushed a commit to ROCm/hipTensor that referenced this pull request Aug 20, 2026
fix(hiptensor): reject batched contraction with a shared
 A/B/D mode as NOT_SUPPORTED (#10826)

## Motivation

Resolves ROCm/legacy-rocm-build#6559.

## Technical Details

On hipTensor 2.3.0, a conventional batched contraction
```
D[b,m,n] = sum_k A[b,m,k] * B[b,k,n]
```
accepts valid descriptors and returns `HIPTENSOR_STATUS_SUCCESS` from
every hipTensor call, but produces numerically incorrect output.

Check for batched contraction (see below) and return
HIPTENSOR_STATUS_NOT_SUPPORTED until further support is added.
```
  std::set<int32_t> setB(modeBV.cbegin(), modeBV.cend());
  std::set<int32_t> setD(modeDV.cbegin(), modeDV.cend());
  for(int32_t m : modeAV)
      if(setB.count(m) && setD.count(m))
```
## Test Plan

Build patched libhiptensor from source (develop @ 2.4.0, against nightly
CK) on an MI300A (gfx942) node, then run two cases on real hardware:
  1. Batched contraction -> expect NOT_SUPPORTED after patch.
  2. Non-batched GEMM ->  expect unchanged SUCCESS.

## Test Result

- With patch applied, batched contraction correctly returns as not
supported meanwhile, non batched GEMMs see no change as expected.

## Submission Checklist

- [X] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
bghimireamd pushed a commit that referenced this pull request Aug 20, 2026
…s NOT_SUPPORTED (#10826)

## Motivation

Resolves ROCm/legacy-rocm-build#6559.

## Technical Details

On hipTensor 2.3.0, a conventional batched contraction
```
D[b,m,n] = sum_k A[b,m,k] * B[b,k,n]
```
accepts valid descriptors and returns `HIPTENSOR_STATUS_SUCCESS` from
every hipTensor call, but produces numerically incorrect output.

Check for batched contraction (see below) and return
HIPTENSOR_STATUS_NOT_SUPPORTED until further support is added.
```
  std::set<int32_t> setB(modeBV.cbegin(), modeBV.cend());
  std::set<int32_t> setD(modeDV.cbegin(), modeDV.cend());
  for(int32_t m : modeAV)
      if(setB.count(m) && setD.count(m)) 
```
## Test Plan

Build patched libhiptensor from source (develop @ 2.4.0, against nightly
CK) on an MI300A (gfx942) node, then run two cases on real hardware:
  1. Batched contraction -> expect NOT_SUPPORTED after patch.
  2. Non-batched GEMM ->  expect unchanged SUCCESS.

## Test Result

- With patch applied, batched contraction correctly returns as not
supported meanwhile, non batched GEMMs see no change as expected.

## Submission Checklist

- [X] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.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.

[hipTensor 2.3.0] Batched contraction with a shared output mode returns success but produces incorrect results

3 participants