Skip to content

hip.py: clean the process environment before the HIP runtime is loaded - #97

Merged
phantoslayer21 merged 1 commit into
mainfrom
model-l/hip-env
Nov 13, 2026
Merged

phantoslayer21 merged 1 commit into
mainfrom
model-l/hip-env

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

The runner's HIP wrapper now cleans its own process environment before amdhip64 is loaded. Refs #89

  • Every variable whose name contains HIP, LLVM, ROCM or HSA is removed, except HIP_PLATFORM and HIP_PATH_72, and ROCM_PATH is set to the HIP SDK (the rocm_dir given, else C:\Program Files\AMD\ROCm\7.2).
  • Applied in Hip.__init__, so the runtime and every child process of the runner see the cleaned environment. Per process only: the user's and the machine's environment are not changed.
  • hip_child_environment() gives the same cleaned copy for callers that start HIP or clang processes themselves.

Why: a stray inherited variable can point the vendor runtime at an unrelated folder (an LLVM_PATH outside the SDK made hipModuleLoadData crash; the existing warning in _check_environment described this).

No change for Model M: hip.py is a Python runner module and is not part of any build output.

Tested

  • python -m unittest clean.tests.test_hip_env (new, CPU): removal, kept names, ROCM_PATH, in-place process cleanup.
  • RX 9070 XT, clean/runner/selftest.py on the same probe.co (built from clean/kernels/probe.hip), in one GPU session: main (started with the same cleaned environment by a wrapper) and this branch print byte-identical reports (1464 bytes, every probe passing). This branch started from an uncleaned environment that holds a stray LLVM_PATH prints the same bytes and no warning.
  • python tools/ci/check_line_endings.py: 0 problems.

Not tested

  • Linux (the cleanup is platform-neutral; the default SDK path only matters when no rocm_dir is given).

Every variable whose name contains HIP, LLVM, ROCM or HSA is removed, except
HIP_PLATFORM and HIP_PATH_72, and ROCM_PATH is set to the HIP SDK (the
rocm_dir given, else C:\Program Files\AMD\ROCm\7.2). Applied in Hip.__init__
before amdhip64 is loaded, so the runtime and every child process of the
runner see the cleaned environment. Per process only: the user's and the
machine's environment are not changed.

A stray inherited variable can point the vendor runtime at an unrelated
folder; an LLVM_PATH outside the SDK made hipModuleLoadData crash.
hip_child_environment() gives the same cleaned copy for callers that start
HIP or clang processes themselves.

No change for Model M: hip.py is a Python runner module only and is not part
of any build output.

Refs #89

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 13, 2026 22:25
@phantoslayer21
phantoslayer21 merged commit 86b185f into main Nov 13, 2026
2 checks passed
@phantoslayer21
phantoslayer21 deleted the model-l/hip-env branch November 13, 2026 22:27
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