Skip to content

Deduplicate scaled_mm arch gate into ScaledBlasDeviceUtils - #190703

Closed
jagadish-amd wants to merge 7 commits into
pytorch:mainfrom
jagadish-amd:scaled_mm_allowed_device
Closed

jagadish-amd wants to merge 7 commits into
pytorch:mainfrom
jagadish-amd:scaled_mm_allowed_device

Conversation

@jagadish-amd

@jagadish-amd jagadish-amd commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Deduplicates the scaled_mm device arch gate, previously copy-pasted as a file-local _scaled_mm_allowed_device in both ScaledBlas.cpp and GroupedBlas.cpp, into a single scaled_mm_arch_allowed(bool sm90_only, bool sm100_only) in the new ATen/native/cuda/ScaledBlasDeviceUtils.{h,cpp}. The ROCm and CUDA implementations sit behind one signature selected by #ifdef USE_ROCM, so call sites need no preprocessor branches of their own; on ROCm the sm90_only/sm100_only arguments are ignored and the check is purely a gfx-arch allowlist.

The two copies had drifted: only the ScaledBlas.cpp one listed gfx1250 (ROCm >= 7.14). Unifying them intentionally extends that allowance to torch._scaled_grouped_mm's device gate (_scaled_grouped_mm_cuda and _scaled_grouped_mm_cuda_v2), aligning it with the gate already used by torch._scaled_mm. This is the only behavior change; every other call site keeps its existing semantics on both CUDA and ROCm.

Test Plan

No new tests; this is a deduplication of an existing device gate. Covered by the existing scaled-GEMM suites in CI:

python test/test_scaled_matmul_cuda.py
python test/test_matmul_cuda.py

Authored with the assistance of Claude.

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

@jagadish-amd

Copy link
Copy Markdown
Contributor Author

cc @jeffdaily @pruthvistony

@pytorch-bot

pytorch-bot Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/190703

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (2 Unrelated Failures)

As of commit d8117fb with merge base 240f31a (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following job failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added ciflow/b200 ciflow/h100 ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 labels Jul 21, 2026
@pytorch-bot

pytorch-bot Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@jagadish-amd

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Jul 21, 2026
@jithunnair-amd jithunnair-amd added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 21, 2026
@soulitzer soulitzer added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jul 21, 2026
Comment thread aten/src/ATen/native/ScaledBlasUtils.h Resolved
@jagadish-amd

Copy link
Copy Markdown
Contributor Author

@drisspg can u plz review / approve

@jagadish-amd

Copy link
Copy Markdown
Contributor Author

unrelated error, good to merge.

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

This is great - thanks for the changes!

@jagadish-amd

Copy link
Copy Markdown
Contributor Author

unrelated failures, can we plz try to merge.

@slayton58

Copy link
Copy Markdown
Contributor

unrelated failures, can we plz try to merge.

They look infra-y, re-running everything. If that fails, rebase from main and re-run CI

@jagadish-amd
jagadish-amd force-pushed the scaled_mm_allowed_device branch from 99c6296 to 763c2e8 Compare August 1, 2026 01:24
_scaled_mm_allowed_device was copy-pasted in cuda/ScaledBlas.cpp and
cuda/GroupedBlas.cpp with identical logic. That creates a maintenance
risk: a future device-capability change could be applied in one file
and missed in the other.
Move the helper to at::native::scaled as scaled_mm_allowed_device,
declared in ScaledBlasUtils.h and defined once in
cuda/ScaledBlasDeviceUtils.cpp. Update both call sites to use the
shared helper.

This intentionally extends gfx1250 support to torch._scaled_grouped_mm's
device gate (_scaled_grouped_mm_cuda, _scaled_grouped_mm_cuda_v2, and the
bf16 fast-path check in GroupedBlas.cpp), aligning it with the gate
already used by torch._scaled_mm. Confirmed as the intended behavior.

Signed-off-by: Jagadish Krishnamoorthy <[email protected]>
Signed-off-by: Jagadish Krishnamoorthy <[email protected]>
@jagadish-amd
jagadish-amd force-pushed the scaled_mm_allowed_device branch from 763c2e8 to f1b7987 Compare August 2, 2026 01:07
@jagadish-amd

Copy link
Copy Markdown
Contributor Author

CI is good, unrelated failure, good to merge.

unrelated failures, can we plz try to merge.

They look infra-y, re-running everything. If that fails, rebase from main and re-run CI

Drop the three call-site copies of the "sm90_only/sm100_only are ignored on ROCm" comment; the contract is documented on the declaration in ScaledBlasDeviceUtils.h and again at the ROCm definition. Add the <string> and <vector> includes ScaledBlasDeviceUtils.cpp was picking up transitively via CUDAHooksInterface.h, and drop a stray blank line in ScaledBlasUtils.h.

Comment, include and whitespace only; no functional change.

Test Plan:

```
lintrunner --skip CODESPELL aten/src/ATen/native/ScaledBlasUtils.h aten/src/ATen/native/cuda/GroupedBlas.cpp aten/src/ATen/native/cuda/ScaledBlas.cpp aten/src/ATen/native/cuda/ScaledBlasDeviceUtils.cpp aten/src/ATen/native/cuda/ScaledBlasDeviceUtils.h
```

Reports "ok No lint issues." Codespell is skipped because it cannot be fetched offline in this container; the change only deletes comment text and adds two include lines, so it cannot introduce a spelling regression. There is no behavior to exercise.

Authored with the assistance of Claude.
@jeffdaily
jeffdaily dismissed drisspg’s stale review August 4, 2026 19:59

Requested changes were applied.

@jeffdaily jeffdaily changed the title Deduplicate scaled_mm_allowed_device into ScaledBlasUtils [ROCm] Deduplicate scaled_mm arch gate into ScaledBlasDeviceUtils Aug 4, 2026
@pytorch-bot pytorch-bot Bot added the module: rocm AMD GPU support for Pytorch label Aug 4, 2026
@jeffdaily jeffdaily changed the title [ROCm] Deduplicate scaled_mm arch gate into ScaledBlasDeviceUtils Deduplicate scaled_mm arch gate into ScaledBlasDeviceUtils Aug 4, 2026
@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10-mi350 / test (default, 7, 8, linux.rocm.gpu.gfx950.1)

Details for Dev Infra team Raised by workflow job

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@jagadish-amd
jagadish-amd deleted the scaled_mm_allowed_device branch August 7, 2026 22:42
jithunnair-amd pushed a commit to ROCm/pytorch that referenced this pull request Aug 25, 2026
…l) (#3594)

## Summary

Carry-forward of ROCm-specific commits from `release/2.13` onto
`release/2.14` ? the 2.14 analog of the 2.13 "IFU dedup" ([PR
#3503](#3503)).

Analyzes the full IFU delta from [PR
#3591](#3591) at `release/2.13`'s
tip (`6596a0d`): **81 commits** in `release/2.13` not in `release/2.14`,
each either dropped (already in 2.14, or 2.13-only) or cherry-picked
here.

## Method

Same rules as the [release/2.13 cherry-pick
process](https://amd.atlassian.net/wiki/spaces/MLSE/pages/1819593560):

- **Drop ? already in 2.14**: patch-id equivalence (`git cherry`),
upstream PR already present, or content already relocated/absorbed into
2.14 (verified during cherry-pick).
- **Drop ? 2.13-only**: version bump, `related_commits`,
dependency/requirements pins, release-line CD/build changes.
- **Carry-forward**: ROCm-specific fixes not present in 2.14 in any
form.

## Commits carried forward (13)

| Source | Notes |
|--------|-------|
| Fix reentrant deadlock in `torch.cuda._lazy_call` (#3496) | clean |
| Skip ROCm-failing tests in test_cuda/test_nn (#3504) | **conflict
resolved** ? kept 2.14's `test_graph_capture_error...` cleanup + took
`@skipIfRocm`; kept 2.14's `test_allocator_backend` (already fixes
LD_LIBRARY_PATH via `subprocess_env()`) |
| skip test_hip_device_count (rocprofiler-sdk) | clean |
| skip flaky test_Embedding_discontiguous_cuda | clean |
| Skip profiler check for foreach tests on ROCm (#3262) | clean |
| Skip test_is_pinned_no_context on python 3.14+ | clean |
| Skip flaky test_reentrant_parent_error_on_cpu | clean |
| Filter out CK gemms for gfx1250-only arch (#3545) | clean |
| Fix hipify skipping sources under Windows subst drives (ROCM-29365)
(#3561) | clean |
| Fixed gfx1250_preferred_backend test (#3546) | clean |
| [ROCm] Optimize AMD normalization backward kernel (pytorch#189405) | clean |
| [release/2.13] Build rocSHMEM for the requested gfx target (#3582) |
clean |
| fix PicklingError handling for Python 3.14 | clean |

## Removed from this PR (per team)

- [RELEASE_ONLY] skip test_autoheuristic in-code (pytorch#180927) ? not needed
on 2.14. Upstream
[pytorch#180927](pytorch#180927)
is `RELEASE_ONLY`, merged to upstream `release/2.12` only (never on
`main` or upstream `release/2.14`).

## Reviewed and excluded (team decision: not needed for 2.14)

| Commit | Reason |
|--------|--------|
| Update composable_kernel submodule with gfx1033 support (#3499) |
2.14's CK pin already includes gfx1033; carrying would move the
submodule pointer **backward**. |
| Revert "Skip cudagraphs for kernel-free inductor graphs" (pytorch#187347) |
2.14 already has the fixed upstream **re-land** on top of the revert;
carrying = regressing 2.14. |
| Revert "[Reland] Port index_add fast path" (pytorch#188196) | 2.14 already
has the newer **re-land (pytorch#189506)** on top of the revert; carrying =
regressing 2.14. |

## Dropped as already in 2.14 (verified during cherry-pick)

- rocm-smi deprecation (#3434) ? 2.14 already has zero `rocm_smi` refs.
- Enable linalg via hipSOLVER, remove Magma (#3455) ? all 6 upstream PRs
already in 2.14.
- Stabilize ROCm 7.14 testing (#3525) ? 2.14 already carries the guards
+ skip messages.
- Add gfx1250 support in GroupedBlas (#3532) ? already in 2.14 via
upstream pytorch#190703 (`ScaledBlasDeviceUtils`).
- Fix uninitialized embedding indices `test_embedding_meta_indices`
(pytorch#188002) ? upstream already in 2.14.
- Unskip ROCSHMEM triton UTs on rocm 7.14 (#3578) ? targets a 2.13-only
7.14 module skip that 2.14 never had; tests already run on 2.14.

Remaining commits drop as 2.13-only (version/pins/related_commits/CD) or
as already-in-2.14 by patch-id/upstream.

## Test plan

- [x] TheRock full-stack dev build (torch + torchaudio + torchvision +
triton) on gfx94X-dcgpu for Python 3.10-3.14, all **Build** jobs green
(ROCm `10.1.0a20260822`, on the `aws-linux-scale-rocm-prod` pool), after
bringing the branch up to its base so `related_commits` resolves
torchaudio/torchvision:
  - py3.10  https://github.com/ROCm/TheRock/actions/runs/32863299013
  - py3.11  https://github.com/ROCm/TheRock/actions/runs/32863305363
  - py3.12  https://github.com/ROCm/TheRock/actions/runs/32863311391
  - py3.13  https://github.com/ROCm/TheRock/actions/runs/32863318109
  - py3.14  https://github.com/ROCm/TheRock/actions/runs/32863325370
- [x] TheRock CI wheel build on gfx94X-dcgpu for Python 3.10-3.14 all
green (ROCm `10.1.0a20260822`, torch-only, on the
`aws-linux-scale-rocm-prod` pool, ~1h40m each):
  - py3.10  https://github.com/ROCm/TheRock/actions/runs/32818564344
  - py3.11  https://github.com/ROCm/TheRock/actions/runs/32818568751
  - py3.12  https://github.com/ROCm/TheRock/actions/runs/32818572249
  - py3.13  https://github.com/ROCm/TheRock/actions/runs/32818576288
  - py3.14  https://github.com/ROCm/TheRock/actions/runs/32818580229



## Processed Commits List
Spreasheet with each commit evaluated for cherry-pick & resolution
(drop/include) with reasoning:


[pr3594-commit-outcomes.xlsx](https://github.com/user-attachments/files/31390971/pr3594-commit-outcomes.xlsx)

---------

Signed-off-by: pablo-garay <[email protected]>
Co-authored-by: Iurii Paikov <[email protected]>
Co-authored-by: Chinmay Dattanand Kuchinad <[email protected]>
Co-authored-by: rocm-repo-management-api-6[bot] <212817015+rocm-repo-management-api-6[bot]@users.noreply.github.com>
Co-authored-by: Dmitry Nikolaev <[email protected]>
Co-authored-by: srinivamd <[email protected]>
Co-authored-by: Subramanian <[email protected]>
Co-authored-by: zjliu-amd <[email protected]>
Co-authored-by: Andres Lugo <[email protected]>
Co-authored-by: pablo-garay <[email protected]>
Co-authored-by: Bo Li <[email protected]>
Co-authored-by: Anatoliy Litvinenko <[email protected]>
Co-authored-by: Jeff Daily <[email protected]>
Co-authored-by: Luca Bruni <[email protected]>
Co-authored-by: albmalamd <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/b200 ciflow/h100 ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/trunk Trigger trunk jobs on your pull request Merged module: rocm AMD GPU support for Pytorch open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants