Repository navigation
[JIT] Diagnose missing rocPRIM headers for the selected ROCm toolchain - #5166
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
|
@valarLip Ran into this bug a second time today. The core issue is
|
Query the build compiler instead of trusting a possibly unrelated global HIP version. Reject failed probes and unreadable headers, remove the redundant path check, and cover fallback behavior without GPU imports. Signed-off-by: Codex <[email protected]>
|
No activity for 15 days, so this is now labelled |
|
not stale |
ruff 0.16.0 I001 flagged tests/test_cpp_extension_rocm_headers.py: move `from contextlib import ExitStack` into the sorted `from`-import block after the plain stdlib imports.
|
@Qubitium thanks your PR to make aiter robust. Pls move [test_cpp_extension_rocm_headers.py] to op_tests directory; otherwise CI won't run it. |
|
Secondly, please use |
Review feedback from @amd-ruitang3 on ROCm#5166: - Move the header-discovery test to op_tests/. CI only shards and runs op_tests/test_*.py (see .github/scripts/split_tests.sh and .github/scripts/aiter_test.sh), so the test under tests/ never executed. The repo-root lookup in the test is unchanged because both directories sit one level below the checkout root. - Cache the `hipcc --version` probe. include_paths() runs several times per build, so the probe spawned a compiler each time just to read its version. The new _probe_hipcc_version() is memoized per hipcc path, which is what changes when ROCM_HOME selects a different ROCm tree; functools.cache is the unbounded form of functools.lru_cache and is what the pinned ruff (UP033) requires. Tests: two new cases cover the caching contract (repeated discovery probes once; a different hipcc path is probed again), and the existing cases clear the cache so each still observes its own mocked compiler output.
|
@amd-ruitang3 Please re-review. 1. Test moved to 2.
Two new tests pin that contract: repeated discovery probes once, and a different Local: |
Explain the static /opt/rocm/include fallback: hipcc from the Python ROCm SDK searches only its own venv-local include tree, while the rocPRIM dev headers are installed by the system packages under /opt/rocm. Kernels that include rocprim/rocprim.hpp (directly or through hipcub) otherwise fail with "'rocprim/rocprim.hpp' file not found". Also note the two guards that keep the fallback narrow: it applies only when the resolved include paths lack rocPRIM and the system headers' HIP version matches the selected hipcc. Comment-only change; no behavior change.
|
Hi @Qubitium , based on my understand, your PR will fetch the head files from |
Done. The prompt message should now output correct install pip commands as single |
|
@Qubitium Which ROCm version are you using? ROCm 10 or ROCm 7? |
Latest 10.x that was available in early Sept. |
|
@amd-ruitang3 I do not currently have access to a MI350/MI300X system right now to test. Please trigger CI and test on your end. This PR was first crated in early Sep when I had rented the single gpu vms. |
|
yes @Qubitium . Meanwhile, I’m reaching out to the ROCm installation team. The root cause might be that |
Correct. Both this and root issue botth needs to be fixed. But even if source is fixed, we still need to support |
|
Starting from ROCm 10, AMD intends ROCm to be installed via pyenv instead of apt. Hi @mgehre-amd @iassiour @zufayu , |
|
I don't think we should mix ROCm from different sources. Instead of doing this, could we just error out and tell people to install the rocm correctly (as described on https://rocm.docs.amd.com/en/latest/install/rocm.html?fam=ryzen&w=compute&gpu=amd-ryzen-ai-max-pro-495&os=ubuntu&ubuntu-ver=26.04.1&i=pip&gfx=gfx1151, including |
Even if both sources are from AMD directly? Both the |
|
@Qubitium, do you exec |
@amd-ruitang3 Thank you for finding the disconnect! The install I used is It is a valid path for rocm 10.x install and you are correct that I did not run The situation is pretty clear now but still unresolved. A) This PR: allow shared system (compatible) rocm paths to pyenv. Deduplication if you have many pyenvs. B) Make sure pyenv has complete copy of isolated rocm libs and make user aware of this. I personally prefer option A but it's up to AMD now. Also, is there a technical reason why the archive is not decompressed on pip setup.py? That would be even better solution? |
zufayu
left a comment
There was a problem hiding this comment.
Thanks for the detailed investigation and for clarifying that the reported environment was set up using the official apt-based ROCm installation instructions. The missing-header failure is real, and this PR has exposed a genuine gap in how AITER selects and diagnoses ROCm development files. The regression coverage added here is also valuable.
As the AITER maintainer, I want to clarify the support boundary. A JIT build should use a documented, coherent ROCm toolchain composition whose compiler, ROCm headers, and runtime libraries are known to be compatible. AITER should not independently create a new composition by combining a Python SDK hipcc with the full header tree discovered under /opt/rocm.
The HIP major/minor check is a useful safeguard, but we do not have an upstream compatibility contract stating that a matching HIP major/minor is sufficient for rocPRIM, hipCUB, rocThrust, HIP headers, and runtime components drawn from separate installations. AITER is therefore not in a position to certify or maintain that cross-install combination.
To be clear, this does not make the apt installation path invalid. A system installation should be usable as a coherent system toolchain, and a Python SDK installation should likewise be usable as a coherent SDK toolchain. If the coexistence of multiple installations causes AITER to select an unintended toolchain, we should make that selection explicit or improve the discovery logic to select one complete, supported toolchain composition—not merge components from both.
Could you please rework this PR along the following lines?
- Remove the automatic
/opt/rocm/includefallback. - Improve the failure path so that, when the selected compiler cannot resolve
rocprim/rocprim.hpp, the diagnostic reports the selectedROCM_HOME, thehipccpath, and the missing header, and directs the user to the appropriate official installation or initialization guidance. - Do not reject an otherwise valid environment solely because the header is absent directly under
ROCM_HOME; standard compiler mechanisms such asCPATH,CPLUS_INCLUDE_PATH, or explicit build flags may already make it resolvable. - Retain regression coverage for the diagnostic behavior and for valid explicitly configured include paths.
The request to share system development headers across Python environments is reasonable. However, if such a composition is intended to be officially supported, its compatibility and discovery contract should be defined by the ROCm SDK/installation layer through a supported sysroot, initialization process, or configuration mechanism. AITER can then consume that contract without independently maintaining cross-install compatibility rules.
The use case remains valid; this decision defines which layer should own and guarantee the compatibility of the resulting ROCm toolchain. Thank you again for identifying the gap and for the substantial work put into investigating and validating it. I would be glad to review a revision along the direction above.
@zufayu Will do! AMD just gave me some dev cloud credits so I am able to test the PRs again locally on a real vm (single MI300X). |
Signed-off-by: Qubitium <[email protected]>
Signed-off-by: Qubitium <[email protected]>
Signed-off-by: Qubitium <[email protected]>
The requested changes have been addressed in the current revision.
zufayu
left a comment
There was a problem hiding this comment.
The requested changes have been addressed. Thanks.
LGTM |




Problem
When the selected ROCm compiler cannot resolve
rocprim/rocprim.hpp, AITER's JIT build fails without identifying its toolchain or the matching development packages. Coexisting Python SDK and system installations require guidance tied to the selected compiler.Changes
ROCM_HOMEand the selectedhipcc, using the same compiler selection as Ninja.rocm[devel]pinned to the full installed version, including nightly/local suffixes, and initialization/root-selection commands using the current Python interpreter. Users supply the original package index because pip does not retain its URL..info/versionor.info/version-devand identify development packages to obtain from that release/build repository. Report unknown versions explicitly. Link to official prebuilt-installation and release-artifact documentation.Builds continue to use compiler-configured include paths such as
CPATH,CPLUS_INCLUDE_PATH,-I, and-isystem. No automatic cross-install header fallback or header-presence preflight is introduced. This follows the maintainer review.Validation
python -m pytest -q op_tests/test_cpp_extension_rocm_headers.py op_tests/test_jit_cache_transaction.py— 73 passed, 71 subtests passed.LC_ALL=C PYTHONCOERCECLOCALE=0 PYTHONUTF8=0._get_hipcc_path,_rocm_sdk_for_compiler,_rocm_devel_install_hint,_rocm_header_build_hint,_run_ninja_build): 74/74 executable statements and 28/28 branches. This is scoped coverage, not repository-wide or platform coverage.git diff --checkpass.Validation ran on Linux CPU. Include-resolution tests use real Ninja and a host C++ compiler with a small stand-in header. Native Windows, HIP kernel compilation, and GPU execution were not performed.