Skip to content

Studio diffusion: use an installed HIP SDK for the Windows ROCm sd.cpp build when its bin dir is not on PATH - #15853

Merged
danielhanchen merged 3 commits into
unslothai:mainfrom
oobabooga:sd-cpp-hip-sdk-path
Oct 29, 2026
Merged

danielhanchen merged 3 commits into
unslothai:mainfrom
oobabooga:sd-cpp-hip-sdk-path

Conversation

@oobabooga

Copy link
Copy Markdown
Member

Reported on Reddit: Anyone manage to get MOSS Image to load?. After #15371 moved Windows AMD hosts without the HIP runtime to Vulkan, the reporter asked what to install to use the HIP build instead.

Problem

On Windows AMD, image generation uses the Vulkan stable-diffusion.cpp build unless hipblas.dll is found on PATH. The upstream win-rocm bundle ships its own amdhip64_7.dll but imports hipblas.dll, which only the AMD HIP SDK provides. The SDK installer never puts that DLL's folder on PATH: HIP SDK 7.2.3's ROCm_SDK_Core.msi sets only HIP_PATH and HIP_PATH_72, and AMD's install guide tells users to add the bin folder to PATH themselves.

As a result, a user who installs the HIP SDK, as the existing log line suggests, still gets Vulkan. Detection (windows_hip_runtime_missing_dlls()), the installer's start probe (_probe_env()) and every sd-cli/sd-server launch (runtime_env()) look only at PATH.

Fix

  • New windows_hip_sdk_bin_dirs() in install_sd_cpp_prebuilt.py. It returns the HIP SDK bin folders from HIP_PATH, then ROCM_PATH, then C:\Program Files\AMD\ROCm\<ver> (newest first). It keeps only 7.x folders, meaning hipblas.dll sits next to amdhip64_7.dll.
  • Detection searches those folders in addition to PATH. For a ROCm bundle, _probe_env() and runtime_env() append them after the caller's PATH.
  • The log line, the fallback reason and the installer hint now say HIP SDK 7.x, mention the HIP_PATH lookup, and link AMD's download page.

Behavior boundaries

  • Without a HIP SDK, Windows AMD still starts at the Vulkan build, as on main.
  • A HIP SDK already on PATH keeps priority.
  • Non-ROCm bundles and non-Windows hosts get the same child environment as before.
  • A 6.x SDK folder is not used: its hipblas.dll binds amdhip64_6.dll, not the bundle's HIP 7 runtime.
  • A host with a saved ROCm failure, for example from an earlier forced attempt without the SDK, stays on Vulkan until the record is cleared with DELETE /api/settings/diffusion-accelerator-fallback. This is main's existing policy, the same as on Linux ROCm hosts.
  • No UI changes.

Verification

  • 7 new tests in test_sd_cpp_install_verify.py. Six of them fail on main, including preferred_accelerator("rocm") returning "vulkan" when the SDK is found only through HIP_PATH.
  • The sd.cpp, diffusion router, H3 and video suites pass: 2402 passed, 3 skipped.

Live A/B on Windows 11 with a Radeon 8060S (gfx1151):

  • The HIP SDK 7.2.3 files were extracted to the layout its MSIs install, and HIP_PATH was set the way the MSI sets it. PATH was left unchanged.
  • Each case used a fresh Studio home, ran Studio's own preferred_accelerator("rocm") and ensure_sd_cpp_binary(), then generated an SD-Turbo image through runtime_env().
Case Accelerator chosen Installed build Generation
main, SDK installed vulkan win-vulkan Vulkan0
main, SDK installed, UNSLOTH_SD_CPP_WINDOWS_ROCM=1 rocm ROCm refused with 0xC0000135, fell back to win-vulkan, ROCm recorded as failed Vulkan0
main, SDK bin added to PATH by hand rocm win-rocm-10.1.0 ROCm0, gfx1151
this PR, SDK installed rocm win-rocm-10.1.0, start probe passed ROCm0, gfx1151
this PR, no SDK vulkan win-vulkan not run

With this PR the result matches the manual PATH edit on main, down to an identical output image.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-28T20:43:18.751778Z 23e0dab PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@oobabooga

Copy link
Copy Markdown
Member Author

Reached Codex review convergence at oobabooga#428.

@danielhanchen
danielhanchen merged commit 35492de into unslothai:main Oct 29, 2026
79 of 82 checks passed
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.

2 participants