Repository navigation
Studio: torch 2.13 for new Linux aarch64 cu130 Python 3.13 installs, existing installs keep their torch #13380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6135,18 +6135,27 @@ _torch_release_in_window() { | |
| echo "no" | ||
| } | ||
|
|
||
| # "yes" when $1 is the cu130 index on Linux/WSL x86_64 with a Python 3.13 venv: the only route the torch 2.13/2.14 prebuilt wheels cover. | ||
| # "yes" when $1 is the cu130 index on Linux/WSL x86_64 or aarch64 with a Python 3.13 venv: the only route the torch 2.13/2.14 prebuilt wheels cover. | ||
| _cu130_torch213_route() { | ||
| [ "$(_cu130_torch213_platform "$1")" = "yes" ] || { echo "no"; return; } | ||
| [ "$(_cu130_torch213_host_ok)" = "yes" ] || { echo "no"; return; } | ||
| _pypi_unsloth_admits_torch "2.13.0" | ||
| } | ||
|
|
||
| # New installs only: torch 2.13 has no cp313t wheel, and the kernel wheels need glibc 2.35. | ||
| _cu130_torch213_host_ok() { | ||
| _cth_gil=$("$VENV_DIR/bin/python" -c "import sysconfig; print('gil-disabled' if sysconfig.get_config_var('Py_GIL_DISABLED') else 'gil-enabled')" 2>/dev/null || echo "") | ||
| [ "$_cth_gil" = "gil-enabled" ] || { echo "no"; return; } | ||
| _cth_glibc=$(_uv_glibc_minor) || { echo "no"; return; } | ||
| [ "$_cth_glibc" -ge 35 ] 2>/dev/null && echo "yes" || echo "no" | ||
| } | ||
|
|
||
| # The local half of the route, with no network: it alone decides the preservation window, so a | ||
| # PyPI outage on a re-run can never shrink it and downgrade an existing 2.13/2.14 install. | ||
| _cu130_torch213_platform() { | ||
| [ "$(_torch_index_url_leaf "$1")" = "cu130" ] || { echo "no"; return; } | ||
| case "$OS" in linux|wsl) ;; *) echo "no"; return ;; esac | ||
| case "$_ARCH" in x86_64|amd64) ;; *) echo "no"; return ;; esac | ||
| case "$_ARCH" in x86_64|amd64|aarch64|arm64) ;; *) echo "no"; return ;; esac | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 22a760b. The new-install choice now probes Py_GIL_DISABLED and requires a GIL-enabled interpreter; torch 2.13 has no cp313t wheel on any platform, so a free-threaded 3.13 stays on the default range. |
||
| _ctr_py=$("$VENV_DIR/bin/python" -c "import sys; print('%d.%d' % sys.version_info[:2])" 2>/dev/null || echo "") | ||
| [ "$_ctr_py" = "3.13" ] && echo "yes" || echo "no" | ||
| } | ||
|
|
@@ -7263,6 +7272,7 @@ if [ "$SKIP_TORCH" = false ] && [ "$(_cu130_torch213_platform "$TORCH_INDEX_URL" | |
| # The PyPI check reads unsloth's metadata, so a --package other than unsloth keeps the default. | ||
| if [ "$(printf '%s' "$PACKAGE_NAME" | tr '[:upper:]' '[:lower:]')" = "unsloth" ] \ | ||
| && { [ "$_EXISTING_INSTALL" = false ] || [ "${UNSLOTH_TORCH_UPGRADE:-0}" = "1" ]; } \ | ||
| && [ "$(_cu130_torch213_host_ok)" = "yes" ] \ | ||
| && [ "$(_pypi_unsloth_admits_torch "2.13.0")" = "yes" ]; then | ||
| _CU130_NEW_INSTALL_ROUTE=true | ||
| fi | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -568,21 +568,29 @@ def _torch_index_leaf(url: str) -> str: | |
| _CU130_FIRST_TORCH_MINOR = 9 # download.pytorch.org/whl/cu130 starts at torch 2.9.0 | ||
|
|
||
|
|
||
| def _is_native_x86_64() -> bool: | ||
| """Linux x86_64, or Windows x64 on an x64 machine. An emulated x64 Python on Windows on ARM | ||
| is excluded: install.ps1 keys its torch 2.13 route on the machine as well as the interpreter.""" | ||
| if platform.machine().lower() not in ("x86_64", "amd64"): | ||
| return False | ||
| def _cu130_first_torch_minor() -> int: | ||
| """cu130 has no aarch64 torchvision 0.24 / torchaudio 2.9, so aarch64 starts at 2.10.""" | ||
| if sys.platform.startswith("linux") and platform.machine().lower() in ("aarch64", "arm64"): | ||
| return 10 | ||
| return _CU130_FIRST_TORCH_MINOR | ||
|
|
||
|
|
||
| def _is_cu130_route_machine() -> bool: | ||
| """Linux x86_64 or aarch64, or Windows x64 on an x64 machine. An emulated x64 Python on Windows | ||
| on ARM is excluded: install.ps1 keys its torch 2.13 route on the machine as well as the interpreter.""" | ||
| machine = platform.machine().lower() | ||
| if sys.platform.startswith("linux"): | ||
| return True | ||
| return machine in ("x86_64", "amd64", "aarch64", "arm64") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On a Linux aarch64 Python 3.13 environment with resident torch 2.9, this newly enables Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 22a760b. The cu130 index has aarch64 torch 2.9 but no torchvision 0.24 / torchaudio 2.9 for it, so on Linux aarch64 the repair only keeps a resident 2.10 or newer; 2.9 there falls back to the default range as before. x86_64 still keeps 2.9. Tests cover both. |
||
| if machine not in ("x86_64", "amd64"): | ||
| return False | ||
| return sys.platform == "win32" and not _is_windows_arm64() | ||
|
|
||
|
|
||
| def _is_cu130_torch213_route(index_url: str | None) -> bool: | ||
| return ( | ||
| bool(index_url) | ||
| and _torch_index_leaf(index_url) == "cu130" | ||
| and _is_native_x86_64() | ||
| and _is_cu130_route_machine() | ||
| and sys.version_info[:2] == (3, 13) | ||
| ) | ||
|
|
||
|
|
@@ -608,7 +616,7 @@ def _cuda_repair_torch_specs( | |
| release = _resident_torch_release() | ||
| if release is not None: | ||
| minor = int(release.split(".")[1]) | ||
| if _CU130_FIRST_TORCH_MINOR <= minor < _CU130_PRESERVE_TORCH_CEILING_MINOR: | ||
| if _cu130_first_torch_minor() <= minor < _CU130_PRESERVE_TORCH_CEILING_MINOR: | ||
| # torchaudio 2.11 is the last release (stable ABI), so newer minors pair with it. | ||
| audio_minor = min(minor, 11) | ||
| return ( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On supported aarch64 hosts with glibc 2.28–2.34, this enables torch 2.13 even though the linux_aarch64 kernel wheels are built on Ubuntu 22.04 with a documented practical glibc 2.35 floor (
.github/scripts/prebuilt_wheels.py:84-89) and are tagged generically enough for pip to accept them. Their import verification then rejects them; for a Mamba model the fallback source build lacks the workflow-only C++20 patch required by torch 2.13 andensure_ssm_runtimeraises, whereas the former torch 2.11 route could build that source. Either retain the old route below glibc 2.35 or publish wheels carrying a compatible manylinux floor.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 22a760b. The new-install choice now also needs glibc 2.35 or newer (read the same way as the uv installer check; musl or an unreadable libc answers no), on x86_64 and aarch64 alike since both builds share that floor. Below it a fresh install stays on the default range. The preservation window is unchanged, so an existing 2.13/2.14 is still kept.