Skip to content

[ROCm] Enable TF32 TunableOp tests for all ROCm architectures - #183474

Closed
geozhai wants to merge 1 commit into
pytorch:mainfrom
geozhai:gezhai_fix_168760
Closed

geozhai wants to merge 1 commit into
pytorch:mainfrom
geozhai:gezhai_fix_168760

Conversation

@geozhai

@geozhai geozhai commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

FIXES #168760
FIXES #168761

Investigation summary

Command to reproduce

As seen an on MI300X machine,

$ PYTORCH_TEST_WITH_ROCM=1 pytest test/test_linalg.py -k "test_tf32_tunableop or test_tf32_offline_tunableop" -v -s 2>/dev/null
========================================================================== test session starts ===========================================================================
platform linux -- Python 3.12.13, pytest-7.3.2, pluggy-1.6.0 -- /opt/conda/envs/py_3.12/bin/python3.12
cachedir: .pytest_cache
hypothesis profile 'dev' -> database=None, max_examples=10, suppress_health_check=[HealthCheck.too_slow]
rootdir: /var/lib/jenkins/pytorch
configfile: pytest.ini
plugins: rerunfailures-14.0, cpp-2.3.0, xdoctest-1.3.0, flakefinder-1.1.0, hypothesis-6.56.4, xdist-3.3.1, subtests-0.13.1
collected 3018 items / 3014 deselected / 4 selected
Running 4 items in this shard

test/test_linalg.py::TestLinalgCPU::test_tf32_offline_tunableop_cpu_float32 SKIPPED [0.0043s] (Only runs on cuda)
test/test_linalg.py::TestLinalgCPU::test_tf32_tunableop_cpu_float32 SKIPPED [0.0007s] (Only runs on cuda)
test/test_linalg.py::TestLinalgCUDA::test_tf32_offline_tunableop_cuda_float32 PASSED [7.7702s]
test/test_linalg.py::TestLinalgCUDA::test_tf32_tunableop_cuda_float32 PASSED [1.2038s]

============================================================= 2 passed, 2 skipped, 3014 deselected in 10.02s =============================================================

The fix

-- In test/test_linalg.py, remove @runOnRocmArch(MI300_ARCH) decorator, enable TF32 TunableOp tests to run on all ROCm architectures
-- Remove unused runOnRocmArch import from test_linalg.py.

Behaviour BEFORE fix

The test_tf32_offline_tunableop and test_tf32_tunableop tests pass on MI300 series GPUs, but is skipped for MI200 and MI350 series GPUs.

Behaviour AFTER fix

The test_tf32_offline_tunableop and test_tf32_tunableop tests pass on MI200, MI300 and MI350 series GPUs.

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

@pytorch-bot

pytorch-bot Bot commented May 12, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 Unclassified Failure

As of commit 1e62d8d with merge base 5eacd08 (image):

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

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

@pytorch-bot pytorch-bot Bot added module: rocm AMD GPU support for Pytorch release notes: linalg_frontend release notes category labels May 12, 2026

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

I'm hoping we can just remove @runOnRocmArch(MI300_ARCH) entirely without changing the gated skip. I believe hipblaslt on MI200 just ignores the request for TF32 dtypes and defaults to full fp32 precision. It's only on MI300 that actual HW is used for TF32. MI350 also doesn't have TF32 HW. There's no real point in gating this at all. The test should run on all ROCm platforms. You'd need to verify that by running these tests on more platforms.

As for the CDNA2OrLater() change, adding gfx950 makes complete sense, but it seems orthogonal to this PR's intent. There are a number of places where CDNA2OrLater is used on other tests that would need their own CI signal for. But definitely worth doing because it means we have a test gap here on MI350 not being part of CDNA2OrLater. I think these ones:

  • test/test_linalg.py:8084 (test__int4_mm)
  • test/test_linalg.py:8153 (test_compile_int4_mm)
  • test/inductor/test_aot_inductor.py:7664 (test__weight_int4pack_mm)
  • test/inductor/test_aot_inductor.py:7701 (test__weight_int4pack_mm_with_scales_and_zeros)

I'd like 2 separate PRs, one for the CDNA2OrLater change and one for the test skip decorator removal. You can repurpose this current PR for the test skip removal, then create a new PR for the CDNA2OrLater change.

@geozhai
geozhai force-pushed the gezhai_fix_168760 branch 2 times, most recently from 206dc72 to eb45f5c Compare May 13, 2026 16:05
@geozhai
geozhai force-pushed the gezhai_fix_168760 branch from eb45f5c to 1e62d8d Compare May 13, 2026 16:16
@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label May 13, 2026
@geozhai geozhai changed the title [ROCm] Expand TF32 TunableOp tests to include all AMD GPUs from CDNA2 on; add gfx950 to CDNA2OrLater() [ROCm] Enable TF32 TunableOp tests for all ROCm architectures May 13, 2026

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

approved, pending CI

@jeffdaily jeffdaily added ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/rocm-navi31 Trigger "default" config CI on ROCm Navi31 ciflow/rocm-mi200 Trigger "default" config CI on ROCm MI200 labels May 13, 2026
@geozhai

geozhai commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

I'm hoping we can just remove @runOnRocmArch(MI300_ARCH) entirely without changing the gated skip. I believe hipblaslt on MI200 just ignores the request for TF32 dtypes and defaults to full fp32 precision. It's only on MI300 that actual HW is used for TF32. MI350 also doesn't have TF32 HW. There's no real point in gating this at all. The test should run on all ROCm platforms. You'd need to verify that by running these tests on more platforms.

As for the CDNA2OrLater() change, adding gfx950 makes complete sense, but it seems orthogonal to this PR's intent. There are a number of places where CDNA2OrLater is used on other tests that would need their own CI signal for. But definitely worth doing because it means we have a test gap here on MI350 not being part of CDNA2OrLater. I think these ones:

  • test/test_linalg.py:8084 (test__int4_mm)
  • test/test_linalg.py:8153 (test_compile_int4_mm)
  • test/inductor/test_aot_inductor.py:7664 (test__weight_int4pack_mm)
  • test/inductor/test_aot_inductor.py:7701 (test__weight_int4pack_mm_with_scales_and_zeros)

I'd like 2 separate PRs, one for the CDNA2OrLater change and one for the test skip decorator removal. You can repurpose this current PR for the test skip removal, then create a new PR for the CDNA2OrLater change.

Thanks for the suggestions @jeffdaily . I have actioned them, the new PR for adding gfx950 to CDNA2OrLater() is here: #183599

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 13, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 1 checks: pull / linux-jammy-py3.10-clang18 / test (crossref, 2, 2, linux.2xlarge)

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 pushed a commit that referenced this pull request May 14, 2026
See [this comment in this PR](#183474 (review)) for detailed info.

gfx950, or the MI350 series GPUs, belongs to CDNA4: https://www.amd.com/en/products/accelerators/instinct/mi350/mi350x.html

The function CDNA2OrLater() in `torch/testing/_internal/common_cuda.py` was missing it, added in this PR.

### ADDITIONAL Investigative Summary

The following 2 tickets are about `int4_mm` that was previously gated on MI355X due to the aforementioned issue:
FIXES #168764
FIXES #168765

```
$ grep -rn "CDNA2\|gfx90a\|gfx942" aten/src/ATen/native/cuda/int4mm.cu 2>/dev/null | head -10
143:static bool isCDNA2orLater(int index) {
144:    return at::detail::getCUDAHooks().isGPUArch({"gfx90a", "gfx942", "gfx950"}, index);
629:    printf("__builtin_amdgcn_mfma_f32_16x16x16bf16_1k is only supported on AMD gpu arch greater than or equal to CDNA2\n");
1112:  if (!isCDNA2orLater(A.device().index())) {
1113:    TORCH_CHECK(false, "_weight_int4pack_mm_cuda is only supported on AMD gpu arch greater than or equal to CDNA2");
1307:  if (!isCDNA2orLater(in.device().index())) {
1308:    TORCH_CHECK(false, "_convert_weight_to_int4pack_cuda is only supported on AMD gpu arch greater than or equal to CDNA2");
```

This indicates int4mm is already supported on gfx950.

### Testing BEFORE fix
on an MI355X / gfx950 machine,
```
$ PYTORCH_TEST_WITH_ROCM=1 pytest test/test_linalg.py -k "test__int4_mm or test_compile_int4_mm" -v -s 2>/dev/null
=================================================================================== test session starts ====================================================================================
platform linux -- Python 3.12.13, pytest-7.3.2, pluggy-1.6.0 -- /opt/conda/envs/py_3.12/bin/python3.12 cachedir:
.pytest_cache hypothesis profile 'dev' -> database=None, max_examples=10, suppress_health_check=
[HealthCheck.too_slow] rootdir: /var/lib/jenkins/pytorch configfile: pytest.ini plugins: xdoctest-1.3.0, hypothesis-6.56.4,
subtests-0.13.1, flakefinder-1.1.0, rerunfailures-14.0, cpp-2.3.0, xdist-3.3.1 collected 3018 items / 2986 deselected / 32
selected Running 32 items in this shard

...
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_32_n_48_cuda SKIPPED [0.0007s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_32_n_64_cuda SKIPPED [0.0005s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_64_n_48_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_64_n_64_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_32_n_48_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_32_n_64_cuda SKIPPED [0.0005s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_64_n_48_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_64_n_64_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_32_n_48_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_32_n_64_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_64_n_48_cuda SKIPPED [0.0003s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_64_n_64_cuda SKIPPED [0.0005s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_32_n_48_cuda SKIPPED [0.0003s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_32_n_64_cuda SKIPPED [0.0003s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_64_n_48_cuda SKIPPED [0.0003s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_64_n_64_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
===================================================================== 16 passed, 16 skipped, 2986 deselected in 2.47s ======================================================================
```

### Testing AFTER fix and re-compiling:
on an MI355X / gfx950 machine,
```
$ PYTORCH_TEST_WITH_ROCM=1 pytest test/test_linalg.py -k "test__int4_mm or test_compile_int4_mm" -v -s 2>/dev/null
============================================================================================= test session starts ==============================================================================================
platform linux -- Python 3.12.13, pytest-7.3.2, pluggy-1.6.0 -- /opt/conda/envs/py_3.12/bin/python3.12
cachedir: .pytest_cache
hypothesis profile 'dev' -> database=None, max_examples=10, suppress_health_check=[HealthCheck.too_slow]
rootdir: /var/lib/jenkins/pytorch
configfile: pytest.ini
plugins: xdoctest-1.3.0, hypothesis-6.56.4, subtests-0.13.1, flakefinder-1.1.0, rerunfailures-14.0, cpp-2.3.0, xdist-3.3.1
collected 3018 items / 2986 deselected / 32 selected
Running 32 items in this shard

...
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_32_n_48_cuda PASSED [3.1637s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_32_n_64_cuda PASSED [0.0160s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_64_n_48_cuda PASSED [0.0136s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_64_n_64_cuda PASSED [0.0031s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_32_n_48_cuda PASSED [0.0029s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_32_n_64_cuda PASSED [0.0028s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_64_n_48_cuda PASSED [0.0028s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_64_n_64_cuda PASSED [0.0027s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_32_n_48_cuda PASSED [0.1767s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_32_n_64_cuda PASSED [0.0508s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_64_n_48_cuda PASSED [0.1332s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_64_n_64_cuda PASSED [0.0040s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_32_n_48_cuda PASSED [0.0544s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_32_n_64_cuda PASSED [0.0041s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_64_n_48_cuda PASSED [0.0565s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_64_n_64_cuda PASSED [0.0042s]
===================================================================================== 32 passed, 2986 deselected in 6.53s ======================================================================================
```

Pull Request resolved: #183599
Approved by: https://github.com/jeffdaily
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / macos-py3-arm64 / test (mps, 1, 1, macos-m2-15)

Details for Dev Infra team Raised by workflow job

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -f "unrelated mac failure"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

jeffdaily added a commit that referenced this pull request May 14, 2026
Conflict resolution:
- docs/source/notes/numerical_accuracy.rst was deleted by upstream (#183341)
  and replaced with numerical_accuracy.md (MyST conversion). Reapplied the
  TF32-on-MI300 section as MyST and appended it to the .md file. Kept the
  tf32_on_mi300 anchor name so :ref: from hip.rst still resolves.
- test/test_linalg.py: kept with_ieee_matmul_precision (used at line 797);
  dropped runOnRocmArch (upstream PR #183474 removed both
  @runOnRocmArch(MI300_ARCH) decorators). lintrunner -a then removed the
  newly-unused MI300_ARCH import.

Authored by Claude.
@geozhai
geozhai deleted the gezhai_fix_168760 branch June 2, 2026 16:21
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
See [this comment in this PR](pytorch#183474 (review)) for detailed info.

gfx950, or the MI350 series GPUs, belongs to CDNA4: https://www.amd.com/en/products/accelerators/instinct/mi350/mi350x.html

The function CDNA2OrLater() in `torch/testing/_internal/common_cuda.py` was missing it, added in this PR.

### ADDITIONAL Investigative Summary

The following 2 tickets are about `int4_mm` that was previously gated on MI355X due to the aforementioned issue:
FIXES pytorch#168764
FIXES pytorch#168765

```
$ grep -rn "CDNA2\|gfx90a\|gfx942" aten/src/ATen/native/cuda/int4mm.cu 2>/dev/null | head -10
143:static bool isCDNA2orLater(int index) {
144:    return at::detail::getCUDAHooks().isGPUArch({"gfx90a", "gfx942", "gfx950"}, index);
629:    printf("__builtin_amdgcn_mfma_f32_16x16x16bf16_1k is only supported on AMD gpu arch greater than or equal to CDNA2\n");
1112:  if (!isCDNA2orLater(A.device().index())) {
1113:    TORCH_CHECK(false, "_weight_int4pack_mm_cuda is only supported on AMD gpu arch greater than or equal to CDNA2");
1307:  if (!isCDNA2orLater(in.device().index())) {
1308:    TORCH_CHECK(false, "_convert_weight_to_int4pack_cuda is only supported on AMD gpu arch greater than or equal to CDNA2");
```

This indicates int4mm is already supported on gfx950.

### Testing BEFORE fix
on an MI355X / gfx950 machine,
```
$ PYTORCH_TEST_WITH_ROCM=1 pytest test/test_linalg.py -k "test__int4_mm or test_compile_int4_mm" -v -s 2>/dev/null
=================================================================================== test session starts ====================================================================================
platform linux -- Python 3.12.13, pytest-7.3.2, pluggy-1.6.0 -- /opt/conda/envs/py_3.12/bin/python3.12 cachedir:
.pytest_cache hypothesis profile 'dev' -> database=None, max_examples=10, suppress_health_check=
[HealthCheck.too_slow] rootdir: /var/lib/jenkins/pytorch configfile: pytest.ini plugins: xdoctest-1.3.0, hypothesis-6.56.4,
subtests-0.13.1, flakefinder-1.1.0, rerunfailures-14.0, cpp-2.3.0, xdist-3.3.1 collected 3018 items / 2986 deselected / 32
selected Running 32 items in this shard

...
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_32_n_48_cuda SKIPPED [0.0007s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_32_n_64_cuda SKIPPED [0.0005s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_64_n_48_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_64_n_64_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_32_n_48_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_32_n_64_cuda SKIPPED [0.0005s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_64_n_48_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_64_n_64_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_32_n_48_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_32_n_64_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_64_n_48_cuda SKIPPED [0.0003s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_64_n_64_cuda SKIPPED [0.0005s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_32_n_48_cuda SKIPPED [0.0003s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_32_n_64_cuda SKIPPED [0.0003s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_64_n_48_cuda SKIPPED [0.0003s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_64_n_64_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
===================================================================== 16 passed, 16 skipped, 2986 deselected in 2.47s ======================================================================
```

### Testing AFTER fix and re-compiling:
on an MI355X / gfx950 machine,
```
$ PYTORCH_TEST_WITH_ROCM=1 pytest test/test_linalg.py -k "test__int4_mm or test_compile_int4_mm" -v -s 2>/dev/null
============================================================================================= test session starts ==============================================================================================
platform linux -- Python 3.12.13, pytest-7.3.2, pluggy-1.6.0 -- /opt/conda/envs/py_3.12/bin/python3.12
cachedir: .pytest_cache
hypothesis profile 'dev' -> database=None, max_examples=10, suppress_health_check=[HealthCheck.too_slow]
rootdir: /var/lib/jenkins/pytorch
configfile: pytest.ini
plugins: xdoctest-1.3.0, hypothesis-6.56.4, subtests-0.13.1, flakefinder-1.1.0, rerunfailures-14.0, cpp-2.3.0, xdist-3.3.1
collected 3018 items / 2986 deselected / 32 selected
Running 32 items in this shard

...
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_32_n_48_cuda PASSED [3.1637s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_32_n_64_cuda PASSED [0.0160s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_64_n_48_cuda PASSED [0.0136s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_64_n_64_cuda PASSED [0.0031s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_32_n_48_cuda PASSED [0.0029s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_32_n_64_cuda PASSED [0.0028s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_64_n_48_cuda PASSED [0.0028s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_64_n_64_cuda PASSED [0.0027s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_32_n_48_cuda PASSED [0.1767s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_32_n_64_cuda PASSED [0.0508s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_64_n_48_cuda PASSED [0.1332s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_64_n_64_cuda PASSED [0.0040s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_32_n_48_cuda PASSED [0.0544s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_32_n_64_cuda PASSED [0.0041s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_64_n_48_cuda PASSED [0.0565s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_64_n_64_cuda PASSED [0.0042s]
===================================================================================== 32 passed, 2986 deselected in 6.53s ======================================================================================
```

Pull Request resolved: pytorch#183599
Approved by: https://github.com/jeffdaily
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…h#183474)

FIXES pytorch#168760
FIXES pytorch#168761

### Investigation summary

### Command to reproduce
As seen an on MI300X machine,
```
$ PYTORCH_TEST_WITH_ROCM=1 pytest test/test_linalg.py -k "test_tf32_tunableop or test_tf32_offline_tunableop" -v -s 2>/dev/null
========================================================================== test session starts ===========================================================================
platform linux -- Python 3.12.13, pytest-7.3.2, pluggy-1.6.0 -- /opt/conda/envs/py_3.12/bin/python3.12
cachedir: .pytest_cache
hypothesis profile 'dev' -> database=None, max_examples=10, suppress_health_check=[HealthCheck.too_slow]
rootdir: /var/lib/jenkins/pytorch
configfile: pytest.ini
plugins: rerunfailures-14.0, cpp-2.3.0, xdoctest-1.3.0, flakefinder-1.1.0, hypothesis-6.56.4, xdist-3.3.1, subtests-0.13.1
collected 3018 items / 3014 deselected / 4 selected
Running 4 items in this shard

test/test_linalg.py::TestLinalgCPU::test_tf32_offline_tunableop_cpu_float32 SKIPPED [0.0043s] (Only runs on cuda)
test/test_linalg.py::TestLinalgCPU::test_tf32_tunableop_cpu_float32 SKIPPED [0.0007s] (Only runs on cuda)
test/test_linalg.py::TestLinalgCUDA::test_tf32_offline_tunableop_cuda_float32 PASSED [7.7702s]
test/test_linalg.py::TestLinalgCUDA::test_tf32_tunableop_cuda_float32 PASSED [1.2038s]

============================================================= 2 passed, 2 skipped, 3014 deselected in 10.02s =============================================================
```

### The fix
-- In `test/test_linalg.py`, remove `@runOnRocmArch(MI300_ARCH)` decorator, enable TF32 TunableOp tests to run on all ROCm architectures
-- Remove unused `runOnRocmArch` import from `test_linalg.py`.

### Behaviour BEFORE fix
The `test_tf32_offline_tunableop` and `test_tf32_tunableop` tests pass on MI300 series GPUs, but is skipped for MI200 and MI350 series GPUs.

### Behaviour AFTER fix
The `test_tf32_offline_tunableop` and `test_tf32_tunableop` tests pass on MI200, MI300 and MI350 series GPUs.

Pull Request resolved: pytorch#183474
Approved by: https://github.com/jeffdaily
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
See [this comment in this PR](pytorch#183474 (review)) for detailed info.

gfx950, or the MI350 series GPUs, belongs to CDNA4: https://www.amd.com/en/products/accelerators/instinct/mi350/mi350x.html

The function CDNA2OrLater() in `torch/testing/_internal/common_cuda.py` was missing it, added in this PR.

### ADDITIONAL Investigative Summary

The following 2 tickets are about `int4_mm` that was previously gated on MI355X due to the aforementioned issue:
FIXES pytorch#168764
FIXES pytorch#168765

```
$ grep -rn "CDNA2\|gfx90a\|gfx942" aten/src/ATen/native/cuda/int4mm.cu 2>/dev/null | head -10
143:static bool isCDNA2orLater(int index) {
144:    return at::detail::getCUDAHooks().isGPUArch({"gfx90a", "gfx942", "gfx950"}, index);
629:    printf("__builtin_amdgcn_mfma_f32_16x16x16bf16_1k is only supported on AMD gpu arch greater than or equal to CDNA2\n");
1112:  if (!isCDNA2orLater(A.device().index())) {
1113:    TORCH_CHECK(false, "_weight_int4pack_mm_cuda is only supported on AMD gpu arch greater than or equal to CDNA2");
1307:  if (!isCDNA2orLater(in.device().index())) {
1308:    TORCH_CHECK(false, "_convert_weight_to_int4pack_cuda is only supported on AMD gpu arch greater than or equal to CDNA2");
```

This indicates int4mm is already supported on gfx950.

### Testing BEFORE fix
on an MI355X / gfx950 machine,
```
$ PYTORCH_TEST_WITH_ROCM=1 pytest test/test_linalg.py -k "test__int4_mm or test_compile_int4_mm" -v -s 2>/dev/null
=================================================================================== test session starts ====================================================================================
platform linux -- Python 3.12.13, pytest-7.3.2, pluggy-1.6.0 -- /opt/conda/envs/py_3.12/bin/python3.12 cachedir:
.pytest_cache hypothesis profile 'dev' -> database=None, max_examples=10, suppress_health_check=
[HealthCheck.too_slow] rootdir: /var/lib/jenkins/pytorch configfile: pytest.ini plugins: xdoctest-1.3.0, hypothesis-6.56.4,
subtests-0.13.1, flakefinder-1.1.0, rerunfailures-14.0, cpp-2.3.0, xdist-3.3.1 collected 3018 items / 2986 deselected / 32
selected Running 32 items in this shard

...
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_32_n_48_cuda SKIPPED [0.0007s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_32_n_64_cuda SKIPPED [0.0005s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_64_n_48_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_64_n_64_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_32_n_48_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_32_n_64_cuda SKIPPED [0.0005s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_64_n_48_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_64_n_64_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda is supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_32_n_48_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_32_n_64_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_64_n_48_cuda SKIPPED [0.0003s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_64_n_64_cuda SKIPPED [0.0005s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_32_n_48_cuda SKIPPED [0.0003s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_32_n_64_cuda SKIPPED [0.0003s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_64_n_48_cuda SKIPPED [0.0003s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_64_n_64_cuda SKIPPED [0.0004s] (_convert_weight_to_int4pack_cuda supported only for CDNA2 or later)
===================================================================== 16 passed, 16 skipped, 2986 deselected in 2.47s ======================================================================
```

### Testing AFTER fix and re-compiling:
on an MI355X / gfx950 machine,
```
$ PYTORCH_TEST_WITH_ROCM=1 pytest test/test_linalg.py -k "test__int4_mm or test_compile_int4_mm" -v -s 2>/dev/null
============================================================================================= test session starts ==============================================================================================
platform linux -- Python 3.12.13, pytest-7.3.2, pluggy-1.6.0 -- /opt/conda/envs/py_3.12/bin/python3.12
cachedir: .pytest_cache
hypothesis profile 'dev' -> database=None, max_examples=10, suppress_health_check=[HealthCheck.too_slow]
rootdir: /var/lib/jenkins/pytorch
configfile: pytest.ini
plugins: xdoctest-1.3.0, hypothesis-6.56.4, subtests-0.13.1, flakefinder-1.1.0, rerunfailures-14.0, cpp-2.3.0, xdist-3.3.1
collected 3018 items / 2986 deselected / 32 selected
Running 32 items in this shard

...
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_32_n_48_cuda PASSED [3.1637s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_32_n_64_cuda PASSED [0.0160s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_64_n_48_cuda PASSED [0.0136s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_32_k_64_n_64_cuda PASSED [0.0031s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_32_n_48_cuda PASSED [0.0029s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_32_n_64_cuda PASSED [0.0028s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_64_n_48_cuda PASSED [0.0028s]
test/test_linalg.py::TestLinalgCUDA::test__int4_mm_m_64_k_64_n_64_cuda PASSED [0.0027s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_32_n_48_cuda PASSED [0.1767s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_32_n_64_cuda PASSED [0.0508s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_64_n_48_cuda PASSED [0.1332s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_32_k_64_n_64_cuda PASSED [0.0040s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_32_n_48_cuda PASSED [0.0544s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_32_n_64_cuda PASSED [0.0041s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_64_n_48_cuda PASSED [0.0565s]
test/test_linalg.py::TestLinalgCUDA::test_compile_int4_mm_m_64_k_64_n_64_cuda PASSED [0.0042s]
===================================================================================== 32 passed, 2986 deselected in 6.53s ======================================================================================
```

Pull Request resolved: pytorch#183599
Approved by: https://github.com/jeffdaily
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…h#183474)

FIXES pytorch#168760
FIXES pytorch#168761

### Investigation summary

### Command to reproduce
As seen an on MI300X machine,
```
$ PYTORCH_TEST_WITH_ROCM=1 pytest test/test_linalg.py -k "test_tf32_tunableop or test_tf32_offline_tunableop" -v -s 2>/dev/null
========================================================================== test session starts ===========================================================================
platform linux -- Python 3.12.13, pytest-7.3.2, pluggy-1.6.0 -- /opt/conda/envs/py_3.12/bin/python3.12
cachedir: .pytest_cache
hypothesis profile 'dev' -> database=None, max_examples=10, suppress_health_check=[HealthCheck.too_slow]
rootdir: /var/lib/jenkins/pytorch
configfile: pytest.ini
plugins: rerunfailures-14.0, cpp-2.3.0, xdoctest-1.3.0, flakefinder-1.1.0, hypothesis-6.56.4, xdist-3.3.1, subtests-0.13.1
collected 3018 items / 3014 deselected / 4 selected
Running 4 items in this shard

test/test_linalg.py::TestLinalgCPU::test_tf32_offline_tunableop_cpu_float32 SKIPPED [0.0043s] (Only runs on cuda)
test/test_linalg.py::TestLinalgCPU::test_tf32_tunableop_cpu_float32 SKIPPED [0.0007s] (Only runs on cuda)
test/test_linalg.py::TestLinalgCUDA::test_tf32_offline_tunableop_cuda_float32 PASSED [7.7702s]
test/test_linalg.py::TestLinalgCUDA::test_tf32_tunableop_cuda_float32 PASSED [1.2038s]

============================================================= 2 passed, 2 skipped, 3014 deselected in 10.02s =============================================================
```

### The fix
-- In `test/test_linalg.py`, remove `@runOnRocmArch(MI300_ARCH)` decorator, enable TF32 TunableOp tests to run on all ROCm architectures
-- Remove unused `runOnRocmArch` import from `test_linalg.py`.

### Behaviour BEFORE fix
The `test_tf32_offline_tunableop` and `test_tf32_tunableop` tests pass on MI300 series GPUs, but is skipped for MI200 and MI350 series GPUs.

### Behaviour AFTER fix
The `test_tf32_offline_tunableop` and `test_tf32_tunableop` tests pass on MI200, MI300 and MI350 series GPUs.

Pull Request resolved: pytorch#183474
Approved by: https://github.com/jeffdaily
jeffdaily added a commit to lstojilj-amd/pytorch that referenced this pull request Sep 25, 2026
…l tests

runOnRocmArch is an allowlist: on ROCm the test runs only on the listed gfx
archs. Widening it to NAVI still leaves gfx90a/gfx950 (TF32 TunableOp) and
gfx942/gfx950 (subnormals) skipped, although nothing in these tests is
arch-specific: the TunableOp tests check that a TF32 GEMM entry is recorded and
rocBLAS did not win, and the subnormal test checks a numerical property that
should hold on every arch. pytorch#183474 removed the TunableOp decorators outright for
the same reason, which is what this PR's description says it restores.

Remove all three decorators so the tests run on every ROCm arch (CUDA is
unaffected; runOnRocmArch was a no-op there), and drop the runOnRocmArch and
MI300_ARCH imports that are now unused in test_linalg.py.

Test Plan:
On MI355X (gfx950, ROCm 10.0), an arch these tests previously skipped:

```
python -m pytest test/test_linalg.py test/test_matmul_cuda.py -k "test_tf32_tunableop or test_tf32_offline_tunableop or test_fp16_backward_preserves_subnormals_rocm"
lintrunner --take RUFF,FLAKE8,PYFMT test/test_linalg.py test/test_matmul_cuda.py
```

6 passed.

Authored with Claude.
pytorchmergebot pushed a commit that referenced this pull request Sep 28, 2026
## Summary

`test_tf32_tunableop` and `test_tf32_offline_tunableop` were enabled for all
ROCm architectures in #183474, which removed both `@runOnRocmArch(MI300_ARCH)`
decorators along with the now-unused import. #183586 re-added them while
extracting CUDA-only tests into `TestLinalgCUDA`. `git blame` attributes both
current decorators to that refactor rather than to any deliberate
re-restriction, so this appears to be an accidental regression. This PR
restores the state #183474 landed.

While in the same area, this also widens `@runOnRocmArch(MI200_ARCH)` on
`test_fp16_backward_preserves_subnormals_rocm`, added for MI200 in #183766.
RDNA is excluded there only by omission from the allowlist, and the test
passes on RDNA.

Part of #196583.

## Validation

Repeated runs on gfx1100 (Radeon PRO W7900), gfx1151 and gfx1200, HIP
`7.16.26320`, with identical results every time.

```
test/test_linalg.py::TestLinalgCudaOnlyCUDA::test_tf32_tunableop_cuda_float32 PASSED
test/test_linalg.py::TestLinalgCudaOnlyCUDA::test_tf32_offline_tunableop_cuda_float32 PASSED
test/test_matmul_cuda.py::TestMatmulCudaCUDA::test_fp16_backward_preserves_subnormals_rocm_batched_False_backend_cublas_cuda PASSED
test/test_matmul_cuda.py::TestMatmulCudaCUDA::test_fp16_backward_preserves_subnormals_rocm_batched_False_backend_cublaslt_cuda PASSED
test/test_matmul_cuda.py::TestMatmulCudaCUDA::test_fp16_backward_preserves_subnormals_rocm_batched_True_backend_cublas_cuda PASSED
test/test_matmul_cuda.py::TestMatmulCudaCUDA::test_fp16_backward_preserves_subnormals_rocm_batched_True_backend_cublaslt_cuda PASSED
```

Pull Request resolved: #197361
Approved by: https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rocm-mi200 Trigger "default" config CI on ROCm MI200 ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/rocm-navi31 Trigger "default" config CI on ROCm Navi31 ciflow/trunk Trigger trunk jobs on your pull request Merged module: rocm AMD GPU support for Pytorch open source release notes: linalg_frontend release notes category topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test: TestLinalg.test_tf32_offline_tunableop Test: TestLinalg.test_tf32_tunableop

4 participants