Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Unsloth Studio installer (AMD/Linux): explain why a newer ROCm gets ROCm 7.2 PyTorch (#11651)

Leo Borcherding84e97f1ada75
diff --git a/install.sh b/install.sh
index 4aad9d3d408..aa40e0ff4f1 100755
--- a/install.sh
+++ b/install.sh
@@ -5723,20 +5723,27 @@ get_torch_index_url() {
echo "$_base/cpu"; return ;;
esac
# Normalise to major.minor; 6.5+ clips to rocm6.4, 7.3+ caps to rocm7.2.
- case "$_rocm_tag" in
- rocm6.0|rocm6.0.*) echo "$_base/rocm6.0" ;;
- rocm6.1|rocm6.1.*) echo "$_base/rocm6.1" ;;
- rocm6.2|rocm6.2.*) echo "$_base/rocm6.2" ;;
- rocm6.3|rocm6.3.*) echo "$_base/rocm6.3" ;;
- rocm6.4|rocm6.4.*) echo "$_base/rocm6.4" ;;
- rocm7.0|rocm7.0.*) echo "$_base/rocm7.0" ;;
- rocm7.1|rocm7.1.*) echo "$_base/rocm7.1" ;;
- rocm7.2|rocm7.2.*) echo "$_base/rocm7.2" ;;
- rocm6.*)
+ # Leading ( on every arm: bash 3.2 (macOS /bin/sh) ends $(...) at a bare pattern) and aborts the script.
+ _rocm_index=$(case "$_rocm_tag" in
+ (rocm6.0|rocm6.0.*) echo "$_base/rocm6.0" ;;
+ (rocm6.1|rocm6.1.*) echo "$_base/rocm6.1" ;;
+ (rocm6.2|rocm6.2.*) echo "$_base/rocm6.2" ;;
+ (rocm6.3|rocm6.3.*) echo "$_base/rocm6.3" ;;
+ (rocm6.4|rocm6.4.*) echo "$_base/rocm6.4" ;;
+ (rocm7.0|rocm7.0.*) echo "$_base/rocm7.0" ;;
+ (rocm7.1|rocm7.1.*) echo "$_base/rocm7.1" ;;
+ (rocm7.2|rocm7.2.*) echo "$_base/rocm7.2" ;;
+ (rocm6.*)
echo "$_base/rocm6.4" ;;
- *)
+ (*)
echo "$_base/rocm7.2" ;;
- esac
+ esac)
+ # No UNSLOTH_TORCH_INDEX_FAMILY hint: newer leaves have nothing inside _TORCH_CEILING (#10657).
+ _rocm_leaf=${_rocm_index##*/}
+ if [ "$_rocm_tag" != "$_rocm_leaf" ]; then
+ echo "[INFO] No validated PyTorch for ROCm ${_rocm_tag#rocm}; capping to the $_rocm_leaf index (its wheels bundle their own runtime, so this is expected)." >&2
+ fi
+ echo "$_rocm_index"
return
fi
# AMD GPU confirmed (rocminfo/amd-smi or the KFD topology fallback) but no ROCm/HIP install was found to read the version from. This is the common fresh-install case: the GPU is real, but with no ROCm userspace the correct PyTorch build cannot be selected, so warn with an actionable fix rather than silently installing CPU PyTorch. The version only picks between the generic rocmX.Y leaves, so an arch with its own repo.amd.com/rocm/whl/gfx* index does not need one (#8731).
@@ -6103,6 +6110,8 @@ get_radeon_wheel_url() {
_RADEON_LISTING=""
_RADEON_PYTAG=""
_RADEON_BASE_URL=""
+# true only while every attempt (X.Y.Z, then X.Y) returned 404/410; any transient failure pins "inconclusive".
+_RADEON_HOST_ANSWERED=false
_radeon_fetch_listing() {
_RADEON_BASE_URL="$1"
@@ -6110,11 +6119,26 @@ _radeon_fetch_listing() {
import sys
print('cp{}{}'.format(sys.version_info.major, sys.version_info.minor))
" 2>/dev/null) || return 1
+ _radeon_http=""
+ _radeon_rc=0
if command -v curl >/dev/null 2>&1; then
- _RADEON_LISTING=$(curl -fsSL --max-time 20 "$_RADEON_BASE_URL" 2>/dev/null)
+ _RADEON_LISTING=$(curl -fsSL --max-time 20 -w '\n%{http_code}' "$_RADEON_BASE_URL" 2>/dev/null) || _radeon_rc=$?
+ _radeon_nl='
+'
+ _radeon_http=${_RADEON_LISTING##*"$_radeon_nl"}
+ _RADEON_LISTING=${_RADEON_LISTING%"$_radeon_nl"*}
+ # Re-strip trailing newlines as a plain $(curl) did, so a newline-only body still fails over to X.Y.
+ _RADEON_LISTING=$(printf '%s' "$_RADEON_LISTING")
elif command -v wget >/dev/null 2>&1; then
- _RADEON_LISTING=$(wget -qO- --timeout=20 "$_RADEON_BASE_URL" 2>/dev/null)
- fi
+ _RADEON_LISTING=$(wget -qO- --timeout=20 "$_RADEON_BASE_URL" 2>/dev/null) || _radeon_rc=$?
+ fi
+ # A timeout or reset mid-body leaves a truncated listing that would pick an older wheel set.
+ [ "$_radeon_rc" -eq 0 ] || _RADEON_LISTING=""
+ # Only 404/410 mean "no such release": curl -f exits 22 on 429/5xx too, and wget's 8 is any error.
+ case "$_radeon_http" in
+ 404|410) [ "$_RADEON_HOST_ANSWERED" = inconclusive ] || _RADEON_HOST_ANSWERED=true ;;
+ *) [ -n "$_RADEON_LISTING" ] || _RADEON_HOST_ANSWERED=inconclusive ;;
+ esac
[ -n "$_RADEON_LISTING" ] || return 1
}
@@ -7822,8 +7846,13 @@ elif [ -n "$TORCH_INDEX_URL" ]; then
"$_torch_whl" "$_tv_whl" "$_ta_whl"
fi
fi
+ elif [ "$_RADEON_HOST_ANSWERED" = true ]; then
+ _radeon_rel=${_radeon_url%/}
+ _radeon_rel=${_radeon_rel##*/}
+ substep "repo.radeon.com has no $_radeon_rel wheels; using $(_strip_index_url_credentials "$TORCH_INDEX_URL")"
+ _install_torch_default_index
else
- substep "[WARN] Radeon repo unavailable; falling back to ROCm index ($(_strip_index_url_credentials "$TORCH_INDEX_URL"))" "$C_WARN"
+ substep "[WARN] Radeon repo unreachable; falling back to ROCm index ($(_strip_index_url_credentials "$TORCH_INDEX_URL"))" "$C_WARN"
_install_torch_default_index
fi
else
diff --git a/tests/sh/test_get_torch_index_url.sh b/tests/sh/test_get_torch_index_url.sh
index 8764bfa76be..ffd44426d60 100755
--- a/tests/sh/test_get_torch_index_url.sh
+++ b/tests/sh/test_get_torch_index_url.sh
@@ -204,6 +204,15 @@ run_func() {
fi
}
+run_func_stderr() {
+ _mock_dir="$1"
+ if [ "$_mock_dir" = "none" ]; then
+ PATH="$_TOOLS_DIR" bash -c "unset CUDA_VISIBLE_DEVICES; _ARCH=x86_64; . '$_FUNC_FILE'; get_torch_index_url" 2>&1 >/dev/null
+ else
+ PATH="$_mock_dir:$_TOOLS_DIR" bash -c "unset CUDA_VISIBLE_DEVICES; _ARCH=x86_64; . '$_FUNC_FILE'; get_torch_index_url" 2>&1 >/dev/null
+ fi
+}
+
echo "=== test_get_torch_index_url ==="
# 1) No nvidia-smi available -> cpu
@@ -698,6 +707,46 @@ assert_eq "url override path slash trimmed, query kept" "https://mirror.example.
_result=$(UNSLOTH_TORCH_INDEX_URL="https://mirror.example.com/whl/cu128#anchor/" run_func "none")
assert_eq "url override preserves fragment slash" "https://mirror.example.com/whl/cu128#anchor/" "$_result"
+# 51) A host newer than the newest leaf is told it was capped (#7264, #10657).
+_dir=$(make_mock_amd_smi "8.0")
+_result=$(run_func_stderr "$_dir")
+assert_contains "ROCm 8.0 cap is explained on stderr" "$_result" "No validated PyTorch for ROCm 8.0;"
+assert_contains "ROCm 8.0 cap names the leaf installed instead" "$_result" "capping to the rocm7.2 index"
+assert_contains "ROCm 8.0 cap says the wheels carry their own runtime" "$_result" "bundle their own runtime"
+rm -rf "$_dir"
+
+# 52) Two-digit minor: 7.14 is capped, not read as 7.1.
+_dir=$(make_mock_amd_smi "7.14")
+_result=$(run_func "$_dir")
+assert_eq "ROCm 7.14 -> rocm7.2 (capped)" "https://download.pytorch.org/whl/rocm7.2" "$_result"
+_result=$(run_func_stderr "$_dir")
+assert_contains "ROCm 7.14 cap is explained on stderr" "$_result" "No validated PyTorch for ROCm 7.14;"
+rm -rf "$_dir"
+
+_dir=$(make_mock_amd_smi "7.2")
+_result=$(run_func_stderr "$_dir")
+assert_not_contains "ROCm 7.2 prints no cap note" "$_result" "No validated PyTorch"
+rm -rf "$_dir"
+
+_dir=$(make_mock_amd_smi "6.3")
+_result=$(run_func_stderr "$_dir")
+assert_not_contains "ROCm 6.3 prints no cap note" "$_result" "No validated PyTorch"
+rm -rf "$_dir"
+
+_dir=$(make_mock_amd_smi "6.5")
+_result=$(run_func "$_dir")
+assert_eq "ROCm 6.5 -> rocm6.4 (clipped)" "https://download.pytorch.org/whl/rocm6.4" "$_result"
+_result=$(run_func_stderr "$_dir")
+assert_contains "ROCm 6.5 clip is explained on stderr" "$_result" "No validated PyTorch for ROCm 6.5;"
+rm -rf "$_dir"
+
+# bash 3.2 (macOS /bin/sh) ends $(...) at a bare `pattern)`.
+_bare_arms=$(sed -n '/_rocm_index=\$(case "\$_rocm_tag" in/,/^[[:space:]]*esac)/p' "$INSTALL_SH" \
+ | grep -v '^[[:space:]]*esac)' | grep -E '^[[:space:]]*[^([:space:]#][^[:space:]]*\)' || true)
+_n_arms=$(sed -n '/_rocm_index=\$(case "\$_rocm_tag" in/,/^[[:space:]]*esac)/p' "$INSTALL_SH" | grep -cE '^[[:space:]]*\(' || true)
+assert_eq "captured ROCm case has no bare pattern arms" "" "$_bare_arms"
+assert_eq "captured ROCm case arms found" "yes" "$([ "${_n_arms:-0}" -ge 10 ] && echo yes)"
+
rm -f "$_FUNC_FILE"
rm -rf "$_FAKE_SMI_DIR"
rm -rf "$_FAKE_ROCM_DIR"
diff --git a/tests/sh/test_radeon_repo_fallback.sh b/tests/sh/test_radeon_repo_fallback.sh
new file mode 100644
index 00000000000..73789b0acc2
--- /dev/null
+++ b/tests/sh/test_radeon_repo_fallback.sh
@@ -0,0 +1,179 @@
+#!/bin/bash
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+#
+# _radeon_fetch_listing separates "no such release" (HTTP 404/410) from "host unreachable" (#7264, #10657).
+set -e
+
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+. "$SCRIPT_DIR/_harness.sh"
+INSTALL_SH="$SCRIPT_DIR/../../install.sh"
+
+_FUNC_FILE=$(mktemp)
+sed -n '/^_radeon_fetch_listing()/,/^}/p' "$INSTALL_SH" > "$_FUNC_FILE"
+[ -s "$_FUNC_FILE" ] || { echo " FAIL: could not extract _radeon_fetch_listing"; exit 1; }
+
+_STUB_DIR=$(mktemp -d)
+cat > "$_STUB_DIR/fakepy" <<'STUB'
+#!/bin/sh
+echo cp312
+STUB
+chmod +x "$_STUB_DIR/fakepy"
+
+# $1 = stub curl exit code, $2 = the %{http_code} it writes out, as curl -w does even on failure, $3 = body sent first.
+run_fetch() {
+ _curl_dir=$(mktemp -d)
+ cat > "$_curl_dir/curl" <<STUB
+#!/bin/sh
+printf '%s\\n%s' '${3:-}' '$2'
+exit $1
+STUB
+ chmod +x "$_curl_dir/curl"
+ PATH="$_curl_dir:$PATH" bash -c "
+ . '$_FUNC_FILE'
+ _VENV_PY='$_STUB_DIR/fakepy'
+ _RADEON_LISTING=''
+ _RADEON_HOST_ANSWERED=false
+ if _radeon_fetch_listing 'https://repo.radeon.com/rocm/manylinux/rocm-rel-7.14/'; then
+ _rc=ok
+ else
+ _rc=fail
+ fi
+ echo \"\$_rc answered=\$_RADEON_HOST_ANSWERED\"
+ "
+ rm -rf "$_curl_dir"
+}
+
+echo "=== test_radeon_repo_fallback ==="
+
+# 1) curl -f exits 22 on HTTP >= 400; only 404/410 mean the release is absent.
+assert_eq "HTTP 404 -> fetch fails, host recorded as answering" \
+ "fail answered=true" "$(run_fetch 22 404)"
+assert_eq "HTTP 410 -> fetch fails, host recorded as answering" \
+ "fail answered=true" "$(run_fetch 22 410)"
+assert_eq "HTTP 503 -> outage, inconclusive" \
+ "fail answered=inconclusive" "$(run_fetch 22 503)"
+assert_eq "HTTP 429 -> rate limit, inconclusive" \
+ "fail answered=inconclusive" "$(run_fetch 22 429)"
+
+assert_eq "connection refused -> inconclusive" \
+ "fail answered=inconclusive" "$(run_fetch 7 000)"
+
+assert_eq "timeout -> inconclusive" \
+ "fail answered=inconclusive" "$(run_fetch 28 000)"
+
+_partial='<a href="torch-2.9.0%2Brocm7.2.4-cp312-cp312-linux_x86_64.whl">torch</a>'
+assert_eq "HTTP 200 truncated by a timeout -> fetch fails, inconclusive" \
+ "fail answered=inconclusive" "$(run_fetch 28 200 "$_partial")"
+assert_eq "HTTP 200 truncated by a reset -> fetch fails, inconclusive" \
+ "fail answered=inconclusive" "$(run_fetch 56 200 "$_partial")"
+
+_curl_dir=$(mktemp -d)
+cat > "$_curl_dir/curl" <<'STUB'
+#!/bin/sh
+printf '\n\n\n200'
+STUB
+chmod +x "$_curl_dir/curl"
+_result=$(PATH="$_curl_dir:$PATH" bash -c "
+ . '$_FUNC_FILE'
+ _VENV_PY='$_STUB_DIR/fakepy'
+ _RADEON_LISTING=''
+ _RADEON_HOST_ANSWERED=false
+ if _radeon_fetch_listing 'https://repo.radeon.com/rocm/manylinux/rocm-rel-7.14.0/'; then echo ok; else echo fail; fi
+")
+rm -rf "$_curl_dir"
+assert_eq "HTTP 200 with a newline-only body -> fetch fails" "fail" "$_result"
+
+_curl_dir=$(mktemp -d)
+cat > "$_curl_dir/curl" <<'STUB'
+#!/bin/sh
+echo '<a href="torch-2.11.0%2Brocm7.2.4-cp312-cp312-linux_x86_64.whl">torch</a>'
+printf '\n200'
+STUB
+chmod +x "$_curl_dir/curl"
+_result=$(PATH="$_curl_dir:$PATH" bash -c "
+ . '$_FUNC_FILE'
+ _VENV_PY='$_STUB_DIR/fakepy'
+ _RADEON_LISTING=''
+ _RADEON_HOST_ANSWERED=false
+ if _radeon_fetch_listing 'https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2.4/'; then
+ printf 'ok answered=%s pytag=%s\n' \"\$_RADEON_HOST_ANSWERED\" \"\$_RADEON_PYTAG\"
+ else
+ echo fail
+ fi
+")
+assert_eq "a served listing -> fetch succeeds" "ok answered=false pytag=cp312" "$_result"
+rm -rf "$_curl_dir"
+
+# 5) Two attempts (X.Y.Z, then X.Y): "no release" only if BOTH were 404/410.
+# $1/$2 = first call's rc/http, $3/$4 = second call's.
+run_two() {
+ _curl_dir=$(mktemp -d)
+ cat > "$_curl_dir/curl" <<STUB
+#!/bin/sh
+_n=\$(cat "$_curl_dir/calls" 2>/dev/null || echo 0)
+echo \$((_n + 1)) > "$_curl_dir/calls"
+[ "\$_n" = 0 ] && { printf '\\n%s' '$2'; exit $1; }
+printf '\\n%s' '$4'
+exit $3
+STUB
+ chmod +x "$_curl_dir/curl"
+ PATH="$_curl_dir:$PATH" bash -c "
+ . '$_FUNC_FILE'
+ _VENV_PY='$_STUB_DIR/fakepy'
+ _RADEON_LISTING=''
+ _RADEON_HOST_ANSWERED=false
+ _radeon_fetch_listing 'https://repo.radeon.com/rocm/manylinux/rocm-rel-7.14.60850/' || true
+ _RADEON_LISTING=''
+ _radeon_fetch_listing 'https://repo.radeon.com/rocm/manylinux/rocm-rel-7.14/' || true
+ printf '%s calls=%s\n' \"\$_RADEON_HOST_ANSWERED\" \"\$(cat '$_curl_dir/calls')\"
+ "
+ rm -rf "$_curl_dir"
+}
+assert_eq "404 then 404 -> release unpublished" "true calls=2" "$(run_two 22 404 22 404)"
+assert_eq "404 then 503 -> inconclusive" "inconclusive calls=2" "$(run_two 22 404 22 503)"
+assert_eq "404 then connection refused -> inconclusive" "inconclusive calls=2" "$(run_two 22 404 7 000)"
+assert_eq "timeout then 404 -> stays inconclusive" "inconclusive calls=2" "$(run_two 28 000 22 404)"
+
+# 6) wget (only reached without curl): its 8 covers every HTTP error, so it stays "unreachable".
+run_fetch_wget() {
+ _wget_dir=$(mktemp -d)
+ cat > "$_wget_dir/wget" <<STUB
+#!/bin/sh
+printf '%s' '${2:-}'
+exit $1
+STUB
+ chmod +x "$_wget_dir/wget"
+ PATH="$_wget_dir" "$(command -v bash)" -c "
+ . '$_FUNC_FILE'
+ _VENV_PY='$_STUB_DIR/fakepy'
+ _RADEON_LISTING=''
+ _RADEON_HOST_ANSWERED=false
+ if _radeon_fetch_listing 'https://repo.radeon.com/rocm/manylinux/rocm-rel-7.14/'; then
+ _rc=ok
+ else
+ _rc=fail
+ fi
+ echo \"\$_rc answered=\$_RADEON_HOST_ANSWERED\"
+ "
+ rm -rf "$_wget_dir"
+}
+assert_eq "no curl, wget HTTP error -> inconclusive" \
+ "fail answered=inconclusive" "$(run_fetch_wget 8)"
+assert_eq "no curl, wget network failure -> inconclusive" \
+ "fail answered=inconclusive" "$(run_fetch_wget 4)"
+assert_eq "no curl, wget timed out mid-body -> fetch fails, inconclusive" \
+ "fail answered=inconclusive" "$(run_fetch_wget 4 '<a href="torch-2.9.0%2Brocm7.2.4-cp312-cp312-linux_x86_64.whl">torch</a>')"
+
+_answered_line=$(grep -n 'elif \[ "\$_RADEON_HOST_ANSWERED" = true \]; then' "$INSTALL_SH" | head -1 | cut -d: -f1)
+_unreachable_line=$(grep -n 'Radeon repo unreachable' "$INSTALL_SH" | head -1 | cut -d: -f1)
+assert_eq "not-published arm precedes the unreachable arm" "yes" \
+ "$([ -n "$_answered_line" ] && [ -n "$_unreachable_line" ] && \
+ [ "$_answered_line" -lt "$_unreachable_line" ] && echo yes)"
+assert_eq "the not-published message names the release asked for" "yes" \
+ "$(grep -q 'repo.radeon.com has no \$_radeon_rel wheels' "$INSTALL_SH" && echo yes)"
+
+rm -f "$_FUNC_FILE"
+rm -rf "$_STUB_DIR"
+
+summary