unsloth/studio/backend
Willow Lopez 77971d0deb
fix(rocm): prefer system LLVM runtime on native Linux (#7448)
* fix(rocm): prefer system LLVM runtime on native Linux

* Fix/adjust the nested LLVM probe for PR #7448: lib64 hosts and non-directories

Two gaps found while simulating the fix against real ROCm layouts.

1. lib64 hosts got no LLVM dir. The candidate was built from the HSA dir, so a
   host with libhsa-runtime64 under lib64 probed <root>/lib64/llvm/lib. ROCm
   installs LLVM under <root>/lib/llvm regardless, so that host kept binding
   system libamd_comgr to the bundle's libLLVM: exactly the bug #7446 reports.
   Probe both spellings, the HSA dir's own first so a genuine lib64 layout still
   wins. When lib_sub is already "lib" the seen set collapses them.

2. os.path.exists accepted a non-directory. The serve-time caller joins these
   straight into LD_LIBRARY_PATH with no is-dir filter, so a file named
   llvm/lib reached the loader. os.path.isdir instead.

Verified on a 27-case matrix built from real directory trees (not mocks), run on
both Windows and Linux against three revisions: main, this PR as-is, and this
commit. Zero regressions and zero reorderings of the pre-existing entries in
every case, and the installer and launcher copies never disagree. The lib64 case
goes [lib64] -> [lib64, lib/llvm/lib]; the file case drops the bogus entry; a
symlinked llvm/lib resolves correctly on Linux.

End-to-end loader check: built real ELF objects mirroring the shipped bundle
(RUNPATH=$ORIGIN, an incomplete libLLVM.so.23.0git next to llama-server, system
comgr from /opt/rocm/lib) and reproduced the reported failure verbatim, then
confirmed the prepend clears it:
  before  undefined symbol: LLVMInitializeSPIRVTarget  ->  after  exit 0

Test helper now patches os.path.isdir alongside os.path.exists, else every fake
host reports its nested llvm dir as missing. New cases: lib64 finding llvm under
lib, lib64 preferring its own when both exist, and a real-filesystem check that a
non-directory is not prepended. Removing the lib fallback from one copy reddens
three tests including the two-copy parity guard.

tests/studio/install: 1361 passed on Linux, 4 pre-existing environmental
failures unchanged (3 managed-node-runtime under root, 1 the real /opt/rocm case
already covered by #7397). 30/30 on the helper suite on Windows and Linux.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Daniel Han <danielhanchen@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-07-28 06:19:29 -07:00
..
assets feat(studio): add DoRA support to studio (#7315) 2026-07-24 03:24:16 -07:00
auth Studio: tighten the comments added by the OpenAI model-admission work (#7501) 2026-07-27 05:59:03 -07:00
core fix(rocm): prefer system LLVM runtime on native Linux (#7448) 2026-07-28 06:19:29 -07:00
hub Studio: tighten the comments added by the OpenAI model-admission work (#7501) 2026-07-27 05:59:03 -07:00
loggers Studio: detect an interrupted dependency install instead of launching a backend that cannot import (#7492) 2026-07-28 10:57:20 +02:00
models Studio: match llama.cpp SWA cache sizing (#7530) 2026-07-28 05:18:15 -07:00
picker Studio: add configurable model download location (#7274) 2026-07-23 01:34:38 -07:00
plugins Let a decode failure degrade instead of escaping a fail-closed helper (#7487) 2026-07-27 03:26:08 -07:00
requirements unsloth start/run: tool-call flags, positional model, and grouped help (#7328) 2026-07-23 01:44:57 -07:00
routes Studio: match llama.cpp SWA cache sizing (#7530) 2026-07-28 05:18:15 -07:00
state feat(studio): run chats in parallel in the Chat tab (#7455) 2026-07-28 04:40:38 -07:00
storage Studio: add Deep Research (#7219) 2026-07-26 23:36:02 -07:00
tests Studio: improve Deep Research synthesis (#7393) 2026-07-28 05:59:15 -07:00
utils Installer: opt-in Vulkan llama.cpp backend (and fallback when no AMD card is HIP-supported) (#7373) 2026-07-27 06:57:19 -07:00
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00
_platform_compat.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
cloudflare_tunnel.py Studio: fix stuck composer prompt on first send and unreachable --secure Cloudflare links (#7340) 2026-07-23 00:39:14 -07:00
colab.py Let a decode failure degrade instead of escaping a fail-closed helper (#7487) 2026-07-27 03:26:08 -07:00
main.py Studio: detect an interrupted dependency install instead of launching a backend that cannot import (#7492) 2026-07-28 10:57:20 +02:00
mcp_server.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
run.py feat(studio): run chats in parallel in the Chat tab (#7455) 2026-07-28 04:40:38 -07:00
startup_banner.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00