Repository navigation
[Bug] AMD: Unsloth Studio Images retries the ROCm sd.cpp build on hosts whose ROCm comes only from the torch wheel - #15430
Conversation
…nch as proven when it is absent
…lback-preflight # Conflicts: # studio/backend/core/inference/sd_cpp_backend.py
|
@codex review |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
danielhanchen
left a comment
There was a problem hiding this comment.
Review record: this PR was reviewed on its mirror, danielhanchen/unsloth-staging-review#575 (one squashed commit, 63d1102b4, onto upstream main 8222149ee).
- Automated review: "Didn't find any major issues" on
63d1102b47. - Security review: no security issues found on
63d1102b47.
The mirror's tree matches this PR's head 81ccf2c57 merged onto 8222149ee (sd_cpp_backend.py blob b9c228cb on both; the two test files are byte-identical), so the approval covers this head. Nothing from the mirror needs landing.
On a Linux AMD host whose ROCm userspace comes only from the pip torch wheel (no
/opt/rocm), an image load that wants sd.cpp fetches leejet's ROCm prebuilt (~295 MB), and that build cannot start: it importslibamdhip64.so.7,libhipblas.so.3andlibrocblas.so.5from the host and bundles none of them. Reported in the Discord help thread (CachyOS, RX 9070): on a slow connection the load spins while that bundle downloads (the 300 s timeout is per read, so a trickling fetch never trips it), and deleting the half-written zip "fixes" it only because the SHA check then fails and the load falls back to the Vulkan build already installed.#15371 already recovers once the fetch completes: the bundle fails its start check, the load steps down to Vulkan, and ROCm is recorded as unrunnable. Two gaps remain, and this PR closes both: the 295 MB fetch still happens first, and a fetch that stalls or is cut short records nothing, so every later load starts it again.
Cause
The runtime guard,
rocm_runtime_resolvable(), asksctypes.CDLLin the Unsloth Studio process. By then torch's ROCm wheel has loaded its own copies of those three sonames, so the lookup by soname succeeds and the guard reports a runtime that sd-cli, a separate process, can't see. Measured on Mint 22.1 withtorch 2.11.0+rocm7.13:import torchimport torchChange
rocm_runtime_resolvable/rocm_runtime_missing_sonamesask a freshpython -X utf8 -Iprocess (env fromutf8_child_env()), memoised per process.ensure_sd_cpp_binary/ensure_sd_server_binarycheck that answer before any fetch: a ROCm request on a host whose loader can't find the runtime installs the Vulkan rung instead and records ROCm as proven unrunnable.preferred_acceleratoris unchanged.note_unlaunchable_accelerator_buildmarks an exit-127 strike proven when the runtime is absent, so an already-installed ROCm build diverts after one failure, not two.ctypes.CDLL; the two ambiguous-launch tests pin "runtime loads" so they no longer follow the test machine.Testing
Mint 22.1, RX 9060 XT (gfx1200), no system ROCm, Unsloth Studio from source with
torch 2.11.0+rocm7.13.0(HIP 7.13.99004, the reporter's), Images > loadunsloth/MOSS-Image-SFT-GGUFUD-Q4_K_XL, clean~/.unsloth/stable-diffusion.cppand no recorded fallback before each run. "After" is this PR's diff applied to the same main commit.Before, main
a20b732:After, this PR:
Both runs end with MOSS loaded on the GPU; the difference is the 295 MB ROCm fetch, which this PR skips. Mint's link is fast (the fetch took ~8 s), so the reporter's stalled-download case was not reproduced live; it is covered by
test_an_unloadable_rocm_runtime_installs_vulkan_without_fetching_rocm.sd_cpp*,diffusion_engine_router,diffusion_routes,h3_native*test file, on Minte043dbf; since then onlyb3db89b(probe child env), withtest_chat_text_encoding+ the ROCm files at 378 passed