Skip to content

[release/2.9] add torch.version.rocm, distinct from torch.version.hip #2983

Draft
amd-sriram wants to merge 1 commit intorelease/2.9from
cherry-pick-168097-release-2.9
Draft

[release/2.9] add torch.version.rocm, distinct from torch.version.hip #2983
amd-sriram wants to merge 1 commit intorelease/2.9from
cherry-pick-168097-release-2.9

Conversation

@amd-sriram
Copy link

Historically, HIP and ROCm versions were interchangeable, but moving forward these versions are allowed to diverge. ROCm version represents the full ROCm software stack, while HIP is a component of the ROCm stack.

Issue pytorch#166068 was fixed by switching from using HIP_VERSION to ROCM_VERSION_DEV. However, this broke the build of ROCm apex because the hip version from hipcc --version no longer matched torch.version.hip. This highlights the need for both versions to be exposed.

Bitsandbytes has also been impacted by the change in behavior of torch.version.hip: bitsandbytes-foundation/bitsandbytes#1799 (comment)

The solution is to fix the torch.version.hip so that it uses the hipcc header values and removes the trailing hash code. In addition, torch.version.rocm variable is created to store the ROCm version.

HIP_VERSION variable is computed in https://github.com/ROCm/hip/blob/develop/cmake/FindHIP.cmake. This runs hipcc –version and extracts the output of HIP version line, e.g.,

hipcc --version
HIP version: 7.1.25421-32f9fa6ca5

The HIP_VERSION variable may contain a hash code at the end. This trailing hashcode is removed from the HIP_VERSION variable so that the torch.version.hip can be parsed by packaging version parse method, e.g.,

import torch
from packaging import version
print(version.parse(torch.version.hip))

Code changes:

  • Add rocm variable to torch/version.py.tpl
  • Add code to write rocm variable in tools/generate_torch_version.py
  • Write rocm version in installation process - torch/CMakeLists.txt

Tested on a preview of ROCm 7.2. Successfully built pytorch and apex. Tested above parsing torch.version.hip code.

>>> import torch
>>> torch.version.hip
'7.1.25421'
>>> torch.version.rocm
'7.2.0'

Pull Request resolved: pytorch#168097

…rch#168097)

Historically, HIP and ROCm versions were interchangeable, but moving forward these versions are allowed to diverge.  ROCm version represents the full ROCm software stack, while HIP is a component of the ROCm stack.

Issue pytorch#166068 was fixed by [switching from using HIP_VERSION to ROCM_VERSION_DEV](pytorch#166336).  However, this broke the build of ROCm apex because the hip version from `hipcc --version` no longer matched `torch.version.hip`.  This highlights the need for both versions to be exposed.

Bitsandbytes has also been impacted by the change in behavior of `torch.version.hip`: bitsandbytes-foundation/bitsandbytes#1799 (comment)

The solution is to fix the `torch.version.hip` so that it uses the hipcc header values and removes the trailing hash code. In addition, `torch.version.rocm` variable is created to store the ROCm version.

HIP_VERSION variable is computed in https://github.com/ROCm/hip/blob/develop/cmake/FindHIP.cmake. This runs hipcc –version and extracts the output of HIP version line, e.g.,
```
hipcc --version
HIP version: 7.1.25421-32f9fa6ca5
```

The HIP_VERSION variable may contain a hash code at the end.  This trailing hashcode is removed from the HIP_VERSION variable so that the torch.version.hip can be parsed by packaging version parse method, e.g.,
```
import torch
from packaging import version
print(version.parse(torch.version.hip))
```

Code changes:
- Add rocm variable to torch/version.py.tpl
- Add code to write rocm variable in tools/generate_torch_version.py
- Write rocm version in installation process - torch/CMakeLists.txt

Tested on a preview of ROCm 7.2.  Successfully built pytorch and apex. Tested above parsing torch.version.hip code.

```
>>> import torch
>>> torch.version.hip
'7.1.25421'
>>> torch.version.rocm
'7.2.0'
```

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

Co-authored-by: Jeff Daily <jeff.daily@amd.com>
@rocm-repo-management-api
Copy link

rocm-repo-management-api bot commented Feb 17, 2026

Jenkins build for 98626a13591ceee88653aaf450d74e82fd0485ad commit finished as FAILURE
Links: Pipeline Overview / Build artifacts / Test Results

@jithunnair-amd jithunnair-amd changed the title [Release/2.9] add torch.version.rocm, distinct from torch.version.hip [release/2.9] add torch.version.rocm, distinct from torch.version.hip Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant