Repository navigation
feat: run Windows ROCm builds without the SDK on PATH or ROCM_PATH - #2604
Merged
Merged
Conversation
After #2601 a Windows `--features rocm` binary only started with the SDK `bin` on PATH and only JIT-compiled with ROCM_PATH set. It also ran the display driver's System32 amdhip64_7.dll rather than the SDK's, and a same-named DLL in the working directory won over PATH. - Both build scripts emit /DELAYLOAD for the five imported ROCm DLLs (selected by `windows_rocm::select_delayload_dlls`) and /INCLUDE the notify hook. The new overlay `delayload.cpp` loads each DLL by full path from the build-time SDK `bin` with LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | DEFAULT_DIRS, and first preloads amd_comgr*.dll and hiprtc-builtins*.dll from there, because amdhip64 and hiprtc load them by plain name. Without the preload the SDK amdhip64 picked up the driver's older System32 amd_comgr.dll and found no device. A missing DLL prints the expected path and raises the delay-load exception instead of falling back to the default search. - hiprtc include resolution falls back to the build-time `<ROCM_PATH>/include` after ROCM_HOME, ROCM_PATH and HIP_PATH, through a pure chooser. - On Windows the integrated-GPU allocator limit is 80% of the reported device memory: a chunked hipMalloc probe stopped at 105 of 107.87 GiB. - The memory estimate gains a GlobalMemoryStatusEx probe for Windows. Linux paths are unchanged. Verified on gfx1151 with ROCm 10.1.0 from a plain cmd.exe with decoy DLLs in the working directory: generate (cold JIT), mlxcel-server chat completions (streaming and not) and messages. Closes #2602
4 of 5 tasks
Member
Author
Implementation Review SummaryIntent
Findings AddressedNo CRITICAL, HIGH or MEDIUM findings, so no fixes were committed. Remaining Items
Review notes
Verification
|
The Windows ROCm binaries now load their DLLs and hiprtc headers only from the SDK directory recorded at build time, so that directory is the trust root. The documented example, C:\rocm, inherits Modify access for Authenticated Users from the drive root (checked with icacls on the validation host), so any local account could replace amdhip64_7.dll there and run code in every mlxcel process. The installation guide now says the directory must be admin-only and gives an icacls command (tested on a scratch tree) that removes the inherited access, notes that run-time ROCM_HOME/ROCM_PATH/HIP_PATH take precedence for headers and need the same protection, and records the three optional DLLs the HIP runtime names but that no SDK or driver directory ships. Refs #2602
Member
Author
Security and Performance ReviewFindings addressed
Remaining items (LOW, not fixed)
Checked, no finding
Verification
|
…ime DLL A relative ROCM_PATH or HIP_PATH made CMake record a relative bin or include directory that resolves against the working directory at run time. The Windows ROCm build now panics when the resolved root is not absolute, naming the value. An empty value still counts as unset. emit_delayload_link_args now panics, naming the bin directory, when no amdhip64_*.dll is found there. Before, it emitted no /DELAYLOAD for the runtime and the binary imported it eagerly by name, searched from the current directory first. The CUDA helper is unchanged. Both decisions live in pure functions (require_absolute_root, require_delayload_dlls) with unit tests in windows_rocm_tests.rs. docs/installation.md states both requirements. Validation: - cargo test -p mlxcel-mlx-pin --lib: 49 passed - cargo fmt --all --check and cargo clippy -p mlxcel-core --release --features rocm -- -D warnings: clean Refs #2602
This was referenced Oct 26, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A Windows
--features rocmbinary now starts and JIT-compiles from a plaincmd.exewith neither the ROCmbinon PATH norROCM_PATH/HIP_PATH/ROCM_HOMEset, loads every ROCm DLL from the SDK it was built against, and ignores same-named DLLs in the working directory.mlxcel-serveris validated on this configuration. Linux paths are unchanged; there is no Linux ROCm machine or CI job (#1811) to re-check them, so the Linux side was kept byte-identical in behavior by construction (every change is under_WIN32,if(WIN32)or a Windows-onlylayout_from_env()).What changed
windows_rocm::select_delayload_dlls/emit_delayload_link_argsmirror the CUDA helpers;mlxcel-core/build.rs(link_rocm, which also linksdelayimp) and the rootbuild.rsboth call it. Excluded from/DELAYLOAD:hiprtc-builtins*andhipfftw(no import library names them, LNK4199 otherwise; the build log has 0 LNK4199). New overlaydelayload.cpploads each DLL by full path fromMLXCEL_ROCM_BIN_DIRwithLOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS.LoadLibraryofamd_comgr.dll/hiprtc-builtins0716.dll. Mechanism: before the first ROCm DLL loads, the hook callsAddDllDirectory(<bin>)and preloadsamd_comgr*.dllandhiprtc-builtins*.dllfrom<bin>by full path. A later plain-nameLoadLibraryfrom amdhip64 or hiprtc then resolves from the loaded-module list, which Windows checks before the application directory, System32, the current directory and PATH.SetDefaultDllDirectorieswas rejected because it is process-wide and changes the display driver's own loads too. This is also a correctness fix: the Adrenalin driver installs olderamdhip64_7.dllandamd_comgr.dllin System32, and the SDK'samdhip64_7.dllnext to the driver'samd_comgr.dllreports zero devices (probe). Before this PR the binaries ran the driver's System32amdhip64_7.dll. A DLL missing from<bin>prints the expected path and raises the delay-load helper's own exception; returning null (as the issue suggested) would make the helper retry with a plainLoadLibrarythat searches CWD and PATH.jit_module.cppresolves through a purechoose_rocm_include_dir():ROCM_HOME,ROCM_PATH,HIP_PATH(empty = unset), thenMLXCEL_ROCM_INCLUDE_DIRif it exists (defined inmlxcelverse/CMakeLists.txton Windows), then/opt/rocm(Linux).hipMalloc+hipMemsetchunks stopped at 105 GiB with 107.87 GiB reported (31.65 GiB OS RAM), sohipMallocdoes not exceedhipMemGetInfototal. Under_WIN32the integrated limit istotal * 0.8. Rust adds aGlobalMemoryStatusExstep-4 probe with tests.installation.mdandenvironment-variables.md;LOCAL_FIXES.mditem 57.Changes during review
C:\rocm\10.1.0) inherits write access for every authenticated user.installation.mdrequires an admin-only directory and gives a testedicaclscommand; it andenvironment-variables.mdalso state that run-timeROCM_HOME/ROCM_PATH/HIP_PATHstill take precedence over the baked include dir (as on Linux and CUDA) and need the same protection, and name the optional plain-name DLLs (hsa-amd-aqlprofile64,hsa-ext-finalize64,dtif64a) the hook cannot cover without a process-wide search change.ROCM_PATH/HIP_PATHand an SDKbinwithoutamdhip64_*.dllnow panic in the build script instead of baking a relative directory or silently emitting no/DELAYLOAD. Three new tests.Test plan
Host: Radeon 8060S
gfx1151, ROCm 10.1.0 atC:\rocm\10.1.0, VS 18.cargo test -p mlxcel-mlx-pin --lib: 49 pass (5 new).cargo test --release --features rocm --lib execution::memory_estimate: 64 pass (3 new, one of them a liveGlobalMemoryStatusExcall undercfg(windows)).cargo fmt --all --check,cargo clippy -p mlxcel-core --release --features rocm -- -D warnings,rocm_overlay.py recordsanddrift(110 backend files, 57 entries),check_env_var_docs.py.cargo build --release --features rocm(both binaries).llvm-readobj --coff-imports:amdhip64_7.dll,rocblas.dll,hiprtc0716.dll,libhipblaslt.dll,hipfft.dllare allDelayImportinmlxcel.exeandmlxcel-server.exe; onlylibopenblas.dllandcombase.dllremain eager among the non-system imports.env -u ROCM_PATH -u HIP_PATH -u ROCM_HOME PATH=/usr/bin:/c/Windows/System32:/c/Windows, and acmd.exebatch withPATH=C:\Windows\System32;C:\Windows):generatewith a freshMLX_HSACO_CACHE_DIRruns on the GPU, including the JIT compile that the old binary failed with "ROCM_HOME or ROCM_PATH is not set". Qwen3-0.6B-4bit 121 tok/s, Qwen3-1.7B-bf16 28.6 tok/s, correct text ("France's capital is Paris").amdhip64_7.dll,amd_comgr.dll,hiprtc0716.dll,hiprtc-builtins0716.dllandrocblas.dll(each a renamedSystem32\version.dll). New binary: generate succeeds (117 tok/s). Old binary from feat: build and run mlxcel natively on Windows with ROCm (gfx1151) #2601 with the samerocblas.dlldecoy and the SDK on PATH: exit 127 at start.mlxcel-serverfrom thatcmd.exebatch in the decoy directory. Loaded modules: every ROCm DLL fromC:\rocm\10.1.0\bin(amdhip64_7,amd_comgr,hiprtc-builtins0716,hiprtc0716,rocblas,libhipblaslt,rocm_kpack,origami), none from the decoy directory or System32. Greedy/no_thinkprompt "What is the capital of France?":/v1/chat/completions:"The capital of France is **Paris**.",finish_reason: stop, 13 tokens./v1/chat/completionswithstream: true: deltas reassemble to the same text, then[DONE]./v1/messages:"The capital of France is **Paris**.",stop_reason: end_turn.generate --estimate-memory(Qwen3-1.7B-bf16, clean env): Available 86.29 GiB (= 0.8 x 107.87), FITS.Not verified: the missing-DLL error path (needs the SDK moved away), the Windows CUDA build (no NVIDIA GPU; its build-script call is unchanged), and Linux ROCm.
Closes #2602