Skip to content

fix(rocprofiler-sdk): allow PYTHON_EXECUTABLES to be passed in from TheRock - #10198

Merged
amd-hsivasun merged 5 commits into
developfrom
users/yhui/use-passed-in-python-versions-from-therock
Sep 30, 2026
Merged

amd-hsivasun merged 5 commits into
developfrom
users/yhui/use-passed-in-python-versions-from-therock

Conversation

@yhuiYH

@yhuiYH yhuiYH commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

When adding Python 3.14 support for roctx and rocpd in TheRock, we need to allow them to pass in a hint to the python executable.

Technical Details

CMake 3.27 (used in the manylinux build container) was released in July 2023 — before Python 3.14 existed. Its FindPython3 module doesn't know to probe /opt/python/cp314-cp314/ on manylinux, so it falls back to the system /bin/python3 (wrong version) and fails. For 3.10–3.13, CMake already had those paths baked into its discovery logic.

rocprofiler_find_python3 now checks ROCPROFILER_PYTHON_EXECUTABLES after the cache reset. If a matching executable is found for the requested version, it pre-seeds Python3_EXECUTABLE in the CMake cache before calling find_package. CMake then uses the explicitly provided path instead of trying to auto-discover — bypassing the CMake version limitation entirely.

Needed in conjunction with this TheRock PR ROCm/TheRock#7350 to fix Python 3.14 support for roctx and rocpd in TheRock builds.

In TheRock multi-arch CI build, seeing error log like this, when adding Python 3.14:

[rocprofiler-sdk configure] CMake Warning (dev) at cmake/Modules/rocprofiler-sdk-utilities.cmake:43 (message):
[rocprofiler-sdk configure]   /__w/TheRock/TheRock/build/dist/rocm/bin/rocminfo returned 1
[rocprofiler-sdk configure] 
[rocprofiler-sdk configure]   stderr:
[rocprofiler-sdk configure] 
[rocprofiler-sdk configure] 
[rocprofiler-sdk configure] 
[rocprofiler-sdk configure]   stdout:
[rocprofiler-sdk configure] 
[rocprofiler-sdk configure]   ROCk module is NOT loaded, possibly no GPU devices
[rocprofiler-sdk configure] Call Stack (most recent call first):
[rocprofiler-sdk configure]   cmake/Modules/rocprofiler-sdk-utilities.cmake:120 (rocprofiler_sdk_get_gfx_architectures)
[rocprofiler-sdk configure]   source/lib/rocprofiler-sdk/thread_trace/tests/CMakeLists.txt:59 (rocprofiler_sdk_sqtt_triple_buffer_disabled)
[rocprofiler-sdk configure] This warning is for project developers.  Use -Wno-dev to suppress it.
[rocprofiler-sdk configure] 
[rocprofiler-sdk configure] -- Resolving super-project find_package(rocprofiler-register REQUIRED BYPASS_PROVIDER NO_DEFAULT_PATH PATHS /__w/TheRock/TheRock/build/base/rocprofiler-register/dist/lib/cmake/rocprofiler-register)
[rocprofiler-sdk configure] -- Resolving super-project find_package(rocprofiler-register REQUIRED BYPASS_PROVIDER NO_DEFAULT_PATH PATHS /__w/TheRock/TheRock/build/base/rocprofiler-register/dist/lib/cmake/rocprofiler-register)
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Building rocprofiler-sdk roctx python bindings for python 3.10
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_package(Python3) (not found in super-project ZLIB;zstd;NUMA;BZip2;liblzma;LibElf;libdw;AMDDeviceLibs;Clang;LLD;LLVM;amd_comgr;rocm-core;rocm-kpack;rocprofiler-register;hsakmt;hsa-runtime64;hip;HIP;hip-lang;hiprtc;rocprof-trace-decoder;yaml-cpp;SQLite3)
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_path(_Python3_INCLUDE_DIR NAMES Python.h;HINTS;/opt/python/cp310-cp310/include/python3.10;NO_SYSTEM_ENVIRONMENT_PATH;NO_CMAKE_SYSTEM_PATH ): /opt/python/cp310-cp310/include/python3.10
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_path(_Python3_INCLUDE_DIR NAMES Python.h ): /opt/python/cp310-cp310/include/python3.10
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Building rocprofiler-sdk roctx python bindings for python 3.11
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_package(Python3) (not found in super-project ZLIB;zstd;NUMA;BZip2;liblzma;LibElf;libdw;AMDDeviceLibs;Clang;LLD;LLVM;amd_comgr;rocm-core;rocm-kpack;rocprofiler-register;hsakmt;hsa-runtime64;hip;HIP;hip-lang;hiprtc;rocprof-trace-decoder;yaml-cpp;SQLite3)
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_path(_Python3_INCLUDE_DIR NAMES Python.h;HINTS;/opt/python/cp311-cp311/include/python3.11;NO_SYSTEM_ENVIRONMENT_PATH;NO_CMAKE_SYSTEM_PATH ): /opt/python/cp311-cp311/include/python3.11
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_path(_Python3_INCLUDE_DIR NAMES Python.h ): /opt/python/cp311-cp311/include/python3.11
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Building rocprofiler-sdk roctx python bindings for python 3.12
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_package(Python3) (not found in super-project ZLIB;zstd;NUMA;BZip2;liblzma;LibElf;libdw;AMDDeviceLibs;Clang;LLD;LLVM;amd_comgr;rocm-core;rocm-kpack;rocprofiler-register;hsakmt;hsa-runtime64;hip;HIP;hip-lang;hiprtc;rocprof-trace-decoder;yaml-cpp;SQLite3)
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_path(_Python3_INCLUDE_DIR NAMES Python.h;HINTS;/opt/python/cp312-cp312/include/python3.12;NO_SYSTEM_ENVIRONMENT_PATH;NO_CMAKE_SYSTEM_PATH ): /opt/python/cp312-cp312/include/python3.12
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_path(_Python3_INCLUDE_DIR NAMES Python.h ): /opt/python/cp312-cp312/include/python3.12
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Building rocprofiler-sdk roctx python bindings for python 3.13
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_package(Python3) (not found in super-project ZLIB;zstd;NUMA;BZip2;liblzma;LibElf;libdw;AMDDeviceLibs;Clang;LLD;LLVM;amd_comgr;rocm-core;rocm-kpack;rocprofiler-register;hsakmt;hsa-runtime64;hip;HIP;hip-lang;hiprtc;rocprof-trace-decoder;yaml-cpp;SQLite3)
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_path(_Python3_INCLUDE_DIR NAMES Python.h;HINTS;/opt/python/cp313-cp313/include/python3.13;NO_SYSTEM_ENVIRONMENT_PATH;NO_CMAKE_SYSTEM_PATH ): /opt/python/cp313-cp313/include/python3.13
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_path(_Python3_INCLUDE_DIR NAMES Python.h ): /opt/python/cp313-cp313/include/python3.13
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Building rocprofiler-sdk roctx python bindings for python 3.14
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_package(Python3) (not found in super-project ZLIB;zstd;NUMA;BZip2;liblzma;LibElf;libdw;AMDDeviceLibs;Clang;LLD;LLVM;amd_comgr;rocm-core;rocm-kpack;rocprofiler-register;hsakmt;hsa-runtime64;hip;HIP;hip-lang;hiprtc;rocprof-trace-decoder;yaml-cpp;SQLite3)
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_path(_Python3_INCLUDE_DIR NAMES Python.h;HINTS;ENV;Python3_ROOT_DIR;PATHS;PATH_SUFFIXES;NO_SYSTEM_ENVIRONMENT_PATH;NO_CMAKE_SYSTEM_PATH ): _Python3_INCLUDE_DIR-NOTFOUND
[rocprofiler-sdk configure] -- [rocprofiler-sdk][python] Resolving system find_path(_Python3_INCLUDE_DIR NAMES Python.h ): _Python3_INCLUDE_DIR-NOTFOUND
[rocprofiler-sdk configure] CMake Error at /usr/local/therock-tools/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
[rocprofiler-sdk configure]   Could NOT find Python3 (missing: Python3_EXECUTABLE Python3_INCLUDE_DIRS
[rocprofiler-sdk configure]   Interpreter Development.Module) (Required is version range
[rocprofiler-sdk configure]   "3.14.0...3.14.999")
[rocprofiler-sdk configure] 
[rocprofiler-sdk configure]       Reason given by package: 
[rocprofiler-sdk configure]           Interpreter: Wrong version for the interpreter "/bin/python3"
[rocprofiler-sdk configure] 
[rocprofiler-sdk configure] Call Stack (most recent call first):
[rocprofiler-sdk configure]   /usr/local/therock-tools/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
[rocprofiler-sdk configure]   /usr/local/therock-tools/share/cmake-3.27/Modules/FindPython/Support.cmake:3824 (find_package_handle_standard_args)
[rocprofiler-sdk configure]   /usr/local/therock-tools/share/cmake-3.27/Modules/FindPython3.cmake:545 (include)
[rocprofiler-sdk configure]   /__w/TheRock/TheRock/cmake/therock_subproject_dep_provider.cmake:73 (find_package)
[rocprofiler-sdk configure]   source/lib/python/utilities.cmake:49 (find_package)
[rocprofiler-sdk configure]   source/lib/python/utilities.cmake:101 (rocprofiler_find_python3)
[rocprofiler-sdk configure]   source/lib/python/roctx/CMakeLists.txt:6 (rocprofiler_roctx_python_bindings)
[rocprofiler-sdk configure] 
[rocprofiler-sdk configure] 

Issue Tracking

ISSUE ID ROCm/TheRock#7398

Test Plan

N/A, this is just an optional ENV var passed in

Test Result

N/A

Submission Checklist

@therock-pr-bot

therock-pr-bot Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass PR does not contain code files — Unit Test auto-passed
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

🎉 All policy checks passed!

📖 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

🚫 Please fix the failed policies before requesting reviews.

The following policy checks failed:

  • ❌ PR Description

The Not ready to Review label has been added to this PR.
Once all policies pass, the label will be removed automatically.

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage Report

Code Coverage Report

Tests Only

code coverage tests.png

Samples Only

code coverage samples.png

Tests + Samples

code coverage all.png

@yhuiYH
yhuiYH marked this pull request as ready for review August 18, 2026 00:29
Copilot AI lite review requested due to automatic review settings August 18, 2026 00:29
@yhuiYH
yhuiYH requested review from a team as code owners August 18, 2026 00:29

Copilot AI 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.

Pull request overview

This PR updates rocprofiler-sdk’s CMake Python discovery so TheRock can provide explicit Python interpreter paths (via ROCPROFILER_PYTHON_EXECUTABLES) and reliably build Python bindings for versions that older CMake FindPython3 can’t auto-discover (notably Python 3.14 on manylinux).

Changes:

  • Adds support for pre-seeding Python3_EXECUTABLE from a caller-provided list of candidate Python executables before invoking find_package(Python3).
  • Uses execute_process() to probe each candidate interpreter’s major/minor version to select the matching one for the requested Python version.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@yhuiYH
yhuiYH force-pushed the users/yhui/use-passed-in-python-versions-from-therock branch from 0c2a054 to bc91b38 Compare September 16, 2026 15:09

@srihari-uttanur srihari-uttanur 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.

Major: TheRock variable is not forwarded, CI sets THEROCK_DIST_PYTHON_EXECUTABLES
THEROCK_SHARED_PYTHON_EXECUTABLES in rocm-systems/.github/scripts/therock_configure_ci.py but the sdk reads ROCPROFILER_PYTHON_EXECUTABLES. TheRock must translate and forward the value. Without that step, rocprofiler-sdk never receives the executable paths, so the patch has no effect in TheRock CI.

@srihari-uttanur srihari-uttanur 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.

2. Default version detection bypasses the new list (Medium)

source/lib/python/CMakeLists.txt L10-12:

if(NOT DEFINED ROCPROFILER_PYTHON_VERSIONS)
    get_default_python_versions(DEFAULT_PYTHON_VERSIONS)

get_default_python_versions() calls find_package(Python3 ...) directly and
never looks at ROCPROFILER_PYTHON_EXECUTABLES. So if CMake cannot auto-discover
3.14 (the exact motivating scenario), 3.14 never lands in the version list,
rocprofiler_find_python3(3.14) is never called, and the pre-seed never runs.

Passing the executables alone therefore does nothing. Either derive the
versions from the supplied executables, or document that
ROCPROFILER_PYTHON_VERSIONS is mandatory alongside it.

3. Exact MAJOR.MINOR.PATCH requests can select the wrong interpreter and hard-fail (Medium)

The candidate match compares only major/minor, but the macro still supports exact
3-component requests a few lines below.

Verified in FindPython/Support.cmake: when the public Python3_EXECUTABLE
is set to an absolute path, it is copied into the internal cache var with no
version validation
, and the whole search is guarded by
if (NOT _Python3_EXECUTABLE) — so discovery is skipped completely. The version
is only checked at the end by find_package_handle_standard_args(... VERSION_VAR Python3_VERSION ...).

So for rocprofiler_find_python3(3.11.9) with a list containing 3.11.8 before
3.11.9: the loop breaks on 3.11.8, discovery is bypassed, and configure dies
under REQUIRED — it does not fall back or try the remaining candidates,
even though a valid 3.11.9 exists both in the list and on the system.

Suggested direction — capture the full version and compare at the requested
precision:

# print 3 components
"import sys; print('.'.join(map(str, sys.version_info[:3])))"

if("${_VERSION}" MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$")
    set(_want "${_VERSION}")
    set(_got  "${_rocprofiler_candidate_ver}")
else()
    set(_want "${_rocprofiler_requested_major_minor}")
    string(REGEX MATCH "^[0-9]+\\.[0-9]+" _got "${_rocprofiler_candidate_ver}")
endif()

4. Non-absolute entries are silently ignored (Low)

FindPython only honours the pre-seed when IS_ABSOLUTE is true. A relative path
or bare name (python3.14) falls through to normal discovery with no warning.
Worth rejecting explicitly, or at least documenting that entries must be absolute.

@yhuiYH

yhuiYH commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Major: TheRock variable is not forwarded, CI sets THEROCK_DIST_PYTHON_EXECUTABLES THEROCK_SHARED_PYTHON_EXECUTABLES in rocm-systems/.github/scripts/therock_configure_ci.py but the sdk reads ROCPROFILER_PYTHON_EXECUTABLES. TheRock must translate and forward the value. Without that step, rocprofiler-sdk never receives the executable paths, so the patch has no effect in TheRock CI.

We need to merge this PR (#10198) first, then also merge TheRock PR (ROCm/TheRock#7350), where we change it so that TheRock DOES inject the ROCPROFILER_PYTHON_EXECUTABLES to the manylinux_config.py and Profilers/CMakeLists.txt.

Only then, can we safely add the python3.14 to therock_configure_ci.py. Doing it now, prematurely, before ROCm/TheRock#7350 is merged, will likely end up with failed CI tests, because TheRock is not setup to build python3.14 yet.

@yhuiYH

yhuiYH commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

2. Default version detection bypasses the new list (Medium)

Passing the executables alone therefore does nothing. Either derive the versions from the supplied executables, or document that ROCPROFILER_PYTHON_VERSIONS is mandatory alongside it.

For (2), you can see in TheRock, they always do pass in ROCPROFILER_PYTHON_VERSIONS (https://github.com/ROCm/TheRock/blob/main/profiler/CMakeLists.txt#L124 or you can check the pending PR ROCm/TheRock#7350), but, to be more safe, I added additional code into this PR so that if ROCPROFILER_PYTHON_EXECUTABLES is provided, then it will auto parse and add it to PYTHON_VERSIONS.

3. Exact MAJOR.MINOR.PATCH requests can select the wrong interpreter and hard-fail (Medium)

For (3), the goal of ROCPROFILER_PYTHON_EXECUTABLES is mainly about helping CMake discover the right interpreter path, and typically systems have one Python per minor version. It's not critical to exact match/care about the patch version.

We also can see, that in TheRock, when they detect their python versions, they only take major.minor (https://github.com/ROCm/TheRock/blob/main/cmake/therock_detect_python_versions.cmake#L90-L136). Similarly, in SDK, our ROCPROFILER_PYTHON_VERSION_CANDIDATES all list only major.minor too (https://github.com/ROCm/rocm-systems/blob/develop/projects/rocprofiler-sdk/source/lib/python/utilities.cmake#L60-L62).

So, I think we can safely ignore this comment.

@yhuiYH
yhuiYH requested a review from SrirakshaNag September 24, 2026 16:24
@bgopesh

bgopesh commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

@yhuiYH I am not too sure about this as we did similar fix in the past and need to recall why that was removed.

@amd-hsivasun
amd-hsivasun merged commit 0a82d46 into develop Sep 30, 2026
270 of 278 checks passed
@amd-hsivasun
amd-hsivasun deleted the users/yhui/use-passed-in-python-versions-from-therock branch September 30, 2026 15:32
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

yhuiYH added a commit to ROCm/TheRock that referenced this pull request Oct 6, 2026
…7350)

## Motivation

In ROCm 7.14 whl and tarballs, rocpd and roctx need to support multiple
python versions. Looks like it's been limited to 3.10-3.13. When users
installed onto Ubuntu 26.04 where the default python version is 3.14,
they get an error:

```rocpd --help
Traceback (most recent call last):
  File "/opt/venv/lib/python3.14/site-packages/_rocm_sdk_devel/bin/rocpd", line 74, in <module>
    main()
    ~~~~^^
  File "/opt/venv/lib/python3.14/site-packages/_rocm_sdk_devel/bin/rocpd", line 46, in main
    raise ImportError(
    ...<5 lines>...
    )
ImportError: rocpd not supported for Python version 3.14 (sys.executable='/opt/venv/bin/python3').
rocpd supported python versions: 3.10, 3.11, 3.12, 3.13
```

## Technical Details

Digging into TheRock build, it looks like the python versions used are
defined in `DIST_PYTHON_EXECUTABLES`. However, the manylinux image SHA
TheRock is using is slightly old, and only has up to 3.13 in
/opt/python.

To add 3.14, we would need to:
1) Update the manylinux image SHA to something newer, and then update
`DIST_PYTHON_EXECUTABLES` or
2) Just use the `/opt/python-shared/cp314-cp314/bin/python3` that rocgdb
is using

Opting for 2, to minimize changes. 
We may need an additional rocprofiler-sdk change to make the python 3.14
discoverable since CMake is old in manylinux image.
ROCm/rocm-systems#10198

Update 10/6: we don't need to update the SHA after all. So this PR just
includes 3.14 builds for roctx & rocpd.

Addresses ISSUE ID #7398

## Test Plan

Check the build artifacts to see if python3.14 is now usable with rocpd.
There was discussion to add rocpd tests to TheRock, but there are
additional issues that need to be resolved, before those tests can be
added.

## Test Result

rocpd should be usable with python 3.14

## Submission Checklist

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

7 participants