Skip to content

[ROCm] Report SDK and HIP versions separately - #193602

Closed
ethanwee1 wants to merge 4 commits into
pytorch:mainfrom
ethanwee1:report-rocm-and-hip-versions
Closed

ethanwee1 wants to merge 4 commits into
pytorch:mainfrom
ethanwee1:report-rocm-and-hip-versions

Conversation

@ethanwee1

@ethanwee1 ethanwee1 commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

JIRA ID: AIPYTORCH-1074

Problem

ROCm SDK version and HIP runtime version are diverging. Test gates, collect_env, verify_dynamo, and extension cache keys still treated torch.version.hip as the SDK version, so patch thresholds and toolchain identity are wrong once SDK and HIP majors split.

Changes

Rebased onto main including Meta's #194985 reland (_derive_rocm_version, ROCM_VERSION as major.minor, getattr for missing torch.version.rocm). Dropped the overlapping hunks. This PR keeps the SDK vs HIP split that the reland does not cover.

  • getRocmVersion() returns the full _get_torch_rocm_version() tuple (tuple[int, ...]). ROCM_VERSION stays major.minor; the TEST_WITH_ROCM guard in _get_torch_rocm_version is unchanged.
  • Skip helpers (test_cuda, test_linalg, test_sparse) and inductor FP8 gating (mm_grouped) use the SDK parser. mm_grouped uses getattr(torch.version, "rocm", None) or torch.version.hip.
  • collect_env replaced ROCM used to build PyTorch: with separate ROCm SDK used to build PyTorch: and HIP used to build PyTorch: lines. Older wheels without torch.version.rocm print N/A. The old ROCM used to build PyTorch: string is gone on purpose: external bug-report tooling that greps for it will not match after this ships in nightlies. rocm_compiled_version is appended at the end of SystemEnv so positional construction of the original fields still lines up.
  • verify_dynamo compares SDK to SDK from rocm-core/rocm_version.h at major.minor (so 7.14.0 vs 7.14.1 does not warn), and falls back to HIP-to-HIP when the header or torch.version.rocm is missing.
  • cpp_extension default cache key includes both SDK and HIP identities, strips dots and -<gitsha>, and uses getattr when rocm is absent.
  • Tests: TestFrameworkUtils covers SDK vs HIP selection; TestVerifyDynamoRocm covers _parse_version, header parsing, SDK patch-ignore, minor mismatch, and HIP fallback.

Validation

python3 -m py_compile on the edited files passed. ruff check --select F821,F401,F811,S101 and ruff format --check passed on test/test_utils.py. Isolated verify_dynamo unit tests previously passed against a stubbed torch. Full lintrunner and device tests were not run locally (this worktree has no built torch).

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben

@pytorch-bot

pytorch-bot Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 New Failure, 1 Unrelated Failure

As of commit e218e63 with merge base d81cb17 (image):

NEW FAILURE - The following job has failed:

BROKEN TRUNK - The following job failed but were 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 the module: rocm AMD GPU support for Pytorch label Aug 14, 2026
@pytorch-bot pytorch-bot Bot added the release notes: linalg_frontend release notes category label Aug 14, 2026
Comment thread test/test_utils.py Resolved
jithunnair-amd
jithunnair-amd previously approved these changes Aug 18, 2026

@jithunnair-amd jithunnair-amd 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.

Agree with the general intent of this PR, we need to differentiate ROCm from HIP versions, and start using torch.version.rocm where applicable.

@pytorch-bot

pytorch-bot Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

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

@pytorch-bot

pytorch-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/inductor
  • ciflow/torchtitan

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

@jithunnair-amd jithunnair-amd added ciflow/trunk Trigger trunk jobs on your pull request keep-going Don't stop on first failure, keep running tests until the end ci-no-td Do not run TD on this PR labels Aug 18, 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.

The direction is right and matches where the toolchain is going; thanks for wiring it through everywhere rather than just collect_env. Main asks: fix the verify_dynamo comparison so both sides use the SDK version (inline comment), the collect_env "Could not collect" fallback for older wheels, and the TEST_WITH_ROCM narrowing in test_sparse. The rest are smaller: full-tuple getRocmVersion, test placement, and two behavior changes that should at least be documented in the PR description. Minor style: the str(...) wraps in mm_grouped.py and cpp_extension.py are redundant (both operands are already strings), and for in-tree modules torch.version.rocm always exists so plain torch.version.rocm or torch.version.hip reads better than the getattr form; getattr defensiveness is only needed in collect_env and verify_dynamo, which run against arbitrary installed torch versions.

Portions of this review were drafted with an AI assistant; findings verified by the author.

Comment thread tools/dynamo/verify_dynamo.py Resolved
Comment thread torch/utils/collect_env.py Resolved
Comment thread test/test_sparse.py Resolved
Comment thread torch/testing/_internal/common_cuda.py Outdated

def _get_torch_rocm_version():
if not TEST_WITH_ROCM or torch.version.hip is None:
rocm_version = getattr(torch.version, "rocm", None) or torch.version.hip

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.

Two behavior changes here are worth calling out in the PR description. First, dropping the TEST_WITH_ROCM guard means callers that gate only on torch.version.hip (e.g. test_matmul_cuda.py) now see the real version on local ROCm runs without PYTORCH_TEST_WITH_ROCM, where they previously saw (0, 0); probably the right direction, but note it points the opposite way from the test_sparse.py change in this PR, which adds a TEST_WITH_ROCM dependency. Second, switching to SDK versions makes existing 3-component thresholds meaningful: _get_torch_rocm_version() < (7, 2, 1) in test_matmul_cuda.py could never trigger on a 7.2 build before (the third component was a HIP build number in the tens of thousands), but ROCm SDK 7.2.0 will now trip it. Worth confirming the hipblas/hipblaslt fix that threshold references actually landed in 7.2.1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both behavior changes are called out in the PR description now. The contradiction you noted is also gone: the test_sparse.py hunk is back to ROCM_VERSION >= (6, 0) per your other comment, so nothing in this PR adds a TEST_WITH_ROCM dependency.

On confirming 7.2.1: the threshold came from #175868 (landed as 9f2c038), which unskipped these 64 cases on the basis that they pass on ROCm 7.2.1; #186098 later added the MI200 arm. So 7.2.1 is the validated-good version, but 7.2.0 was never validated either way.

Worth flagging which way this PR moves it. Under HIP comparison < (7, 2, 1) effectively meant < 7.2, since any 7.2.x HIP build number beat 1, so 7.2.0 builds ran these tests. Literal SDK comparison makes 7.2.0 skip them instead. No CI config is affected, since we build 7.14 and 10.1, and it errs toward skipping rather than failing. Happy to change it to < (7, 2, 0) to preserve the old coverage exactly if you prefer.

Comment thread test/test_testing.py Resolved
@ethanwee1
ethanwee1 requested a review from jeffdaily August 19, 2026 14:50
@ethanwee1
ethanwee1 marked this pull request as ready for review August 20, 2026 17:07
@janeyx99 janeyx99 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Aug 21, 2026
@ethanwee1
ethanwee1 force-pushed the report-rocm-and-hip-versions branch from 25392cc to 494868c Compare August 24, 2026 14:59
@ethanwee1

Copy link
Copy Markdown
Contributor Author

@pytorchbot label ciflow/trunk ciflow/inductor ciflow/torchtitan

@jithunnair-amd

Copy link
Copy Markdown
Collaborator

@ethanwee1 please address lint failure, looks legit

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 1 checks: torchtitan-test / torchtitan-x-pytorch-test / test (torchtitan_models_integration, 1, 1, mt-l-x86aavx2-189-704-a10g-8)

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

@huydhn

huydhn commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot revert -m 'Sorry for the churn, I need to revert this to cleanly revert #193927' -c weird

Please help rebase and reland this later

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

pytorchmergebot added a commit that referenced this pull request Sep 2, 2026
This reverts commit c9b4d84.

Reverted #193602 on behalf of https://github.com/huydhn due to Sorry for the churn, I need to revert this to cleanly revert #193927 ([comment](#193602 (comment)))
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@ethanwee1 your PR has been successfully reverted.

@pytorch-bot
pytorch-bot Bot dismissed stale reviews from jithunnair-amd and jeffdaily September 2, 2026 23:24

This PR was reopened (likely due to being reverted), so your approval was removed. Please request another review.

@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-cuda13.0-py3.10-gcc11 / test (distributed, 2, 10, mt-l-x86iavx512-45-172-t4-4)

Details for Dev Infra team Raised by workflow job

Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
JIRA ID: AIPYTORCH-1074

## Problem
ROCm SDK version and HIP runtime version are diverging. Test gates, `collect_env`, `verify_dynamo`, and extension cache keys still treated `torch.version.hip` as the SDK version, so patch thresholds and toolchain identity are wrong once SDK and HIP majors split.

## Changes
Rebased onto main including Meta's pytorch#194985 reland (`_derive_rocm_version`, `ROCM_VERSION` as major.minor, `getattr` for missing `torch.version.rocm`). Dropped the overlapping hunks. This PR keeps the SDK vs HIP split that the reland does not cover.

- `getRocmVersion()` returns the full `_get_torch_rocm_version()` tuple (`tuple[int, ...]`). `ROCM_VERSION` stays major.minor; the `TEST_WITH_ROCM` guard in `_get_torch_rocm_version` is unchanged.
- Skip helpers (`test_cuda`, `test_linalg`, `test_sparse`) and inductor FP8 gating (`mm_grouped`) use the SDK parser. `mm_grouped` uses `getattr(torch.version, "rocm", None) or torch.version.hip`.
- `collect_env` replaced `ROCM used to build PyTorch:` with separate `ROCm SDK used to build PyTorch:` and `HIP used to build PyTorch:` lines. Older wheels without `torch.version.rocm` print `N/A`. The old `ROCM used to build PyTorch:` string is gone on purpose: external bug-report tooling that greps for it will not match after this ships in nightlies. `rocm_compiled_version` is appended at the end of `SystemEnv` so positional construction of the original fields still lines up.
- `verify_dynamo` compares SDK to SDK from `rocm-core/rocm_version.h` at major.minor (so 7.14.0 vs 7.14.1 does not warn), and falls back to HIP-to-HIP when the header or `torch.version.rocm` is missing.
- `cpp_extension` default cache key includes both SDK and HIP identities, strips dots and `-<gitsha>`, and uses `getattr` when `rocm` is absent.
- Tests: `TestFrameworkUtils` covers SDK vs HIP selection; `TestVerifyDynamoRocm` covers `_parse_version`, header parsing, SDK patch-ignore, minor mismatch, and HIP fallback.

## Validation
`python3 -m py_compile` on the edited files passed. `ruff check --select F821,F401,F811,S101` and `ruff format --check` passed on `test/test_utils.py`. Isolated `verify_dynamo` unit tests previously passed against a stubbed `torch`. Full lintrunner and device tests were not run locally (this worktree has no built torch).

Pull Request resolved: pytorch#193602
Approved by: https://github.com/jithunnair-amd, https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

The two failures are unrelated: the Gloo test_collective_hang failure is a connectFullMesh network flake in a distributed test this PR does not touch, and the torchtitan qwen3_5_moe failure (No module named 'fla') is a broken dependency in the torchtitan environment that is also failing on trunk.

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 2 checks: torchtitan-test / torchtitan-x-pytorch-test / test (torchtitan_models_integration, 1, 1, mt-l-x86aavx2-189-704-a10g-8), trunk / linux-jammy-cuda13.0-py3.10-gcc11 / test (distributed, 2, 10, mt-l-x86iavx512-45-172-t4-4)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests ciflow/trunk Trigger trunk jobs on your pull request keep-going Don't stop on first failure, keep running tests until the end Merged module: inductor module: rocm AMD GPU support for Pytorch open source release notes: linalg_frontend release notes category Reverted 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.

7 participants