Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/scripts/mac-torch-floor-upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.
# Helpers for studio-mac-torch-floor-upgrade.yml, run against $UNSLOTH_STUDIO_HOME's venv.
# probe print "PROBE <python> <torch> <torchvision> <torchaudio> mps <bool>", check MPS SDPA
# seed T TV TA put the existing home on that torch trio (an older home, as a user would have)
set -euo pipefail

VPY="$UNSLOTH_STUDIO_HOME/unsloth_studio/bin/python"

_probe() {
"$VPY" - <<'PY'
import sys
import torch, torchvision, torchaudio
mps = torch.backends.mps.is_available()
print("PROBE", sys.version.split()[0], torch.__version__, torchvision.__version__, torchaudio.__version__, "mps", mps)
if mps:
q = torch.randn(1, 8, 1024, 64, dtype = torch.bfloat16)
ref = torch.nn.functional.scaled_dot_product_attention(q.double(), q.double(), q.double())
out = torch.nn.functional.scaled_dot_product_attention(q.to("mps"), q.to("mps"), q.to("mps")).cpu().double()
cos = torch.nn.functional.cosine_similarity(ref.flatten(), out.flatten(), dim = 0).item()
print("PROBE sdpa_cos", round(cos, 6))
assert cos > 0.999, cos
try:
import torchcodec
print("PROBE torchcodec", torchcodec.__version__)
except Exception as e: # informational: Python 3.10 homes may have none
print("PROBE torchcodec_unavailable", type(e).__name__)
PY
}

_seed() {
# install.sh keeps its uv under the Studio home when UNSLOTH_STUDIO_HOME is set, so look there first.
_uv=""
for _c in "$UNSLOTH_STUDIO_HOME/uv/uv" "$(command -v uv || true)" "$HOME/.local/bin/uv"; do
if [ -n "$_c" ] && [ -x "$_c" ]; then _uv="$_c"; break; fi
done
[ -n "$_uv" ] || { echo "no uv found under $UNSLOTH_STUDIO_HOME/uv, PATH or ~/.local/bin" >&2; exit 1; }
"$_uv" pip install --python "$VPY" "torch==$1" "torchvision==$2" "torchaudio==$3" \
--default-index https://download.pytorch.org/whl/cpu
_probe
}

case "${1:-}" in
probe) _probe ;;
seed) shift; _seed "$@" ;;
*) echo "usage: $0 probe | seed TORCH TORCHVISION TORCHAUDIO" >&2; exit 2 ;;
esac
145 changes: 145 additions & 0 deletions .github/workflows/studio-mac-torch-floor-upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.
# An existing Apple Silicon home on torch 2.10, re-run with the merge base's install.sh (kept)
# and with this checkout's (moved to the 2.13 route); then opt-out, a 2.14 home, studio update.

name: Studio macOS torch floor upgrade

# Opt-in: never runs on unslothai/unsloth pull requests (the job is skipped there); runs on
# staging repos, which take inherited workflows on pull_request, and by dispatch anywhere.
on:
workflow_dispatch:
inputs:
base_ref:
description: 'Branch the A arm installs from (staging repos: upstream-main)'
required: false
default: 'upstream-main'
pull_request:
# ready_for_review: the job skips draft PRs, so marking ready must start the run.
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'install.sh'
- '.github/workflows/studio-mac-torch-floor-upgrade.yml'
- '.github/scripts/mac-torch-floor-upgrade.sh'
- '.github/actions/uv-cache-restore/**'
- '.github/actions/uv-cache-save/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
contents: read

jobs:
floor-upgrade:
if: >-
(github.event_name == 'workflow_dispatch' || github.repository != 'unslothai/unsloth')
&& (github.event_name != 'pull_request' || !github.event.pull_request.draft)
name: "existing torch 2.10 home (py${{ matrix.python }})"
runs-on: macos-15
timeout-minutes: 150
strategy:
fail-fast: false
matrix:
python: ['3.13', '3.10']
env:
UNSLOTH_STUDIO_HOME: ${{ github.workspace }}/../studio-home
UNSLOTH_PYTHON: ${{ matrix.python }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HELPER: ${{ github.workspace }}/.github/scripts/mac-torch-floor-upgrade.sh
LOGS: ${{ github.workspace }}/logs
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ matrix.python }}

- name: Restore the uv download cache
id: uv-cache
uses: ./.github/actions/uv-cache-restore

- name: Base worktree at the merge base
env:
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
BASE_REF: ${{ inputs.base_ref }}
run: |
base="${PR_BASE_SHA:-$(git rev-parse "origin/${BASE_REF:-upstream-main}")}"
git worktree add --detach "$RUNNER_TEMP/base" "$base"
echo "base $base head $(git rev-parse HEAD)"
mkdir -p "$LOGS"
- name: Seed a home with the merge base installer, then put it on torch 2.10.0
working-directory: ${{ runner.temp }}/base
run: |
set -o pipefail
bash install.sh --local 2>&1 | tee "$LOGS/0_seed_install.log"
bash "$HELPER" seed 2.10.0 0.25.0 2.10.0 | tee "$LOGS/0_seed.log"
grep -q "^PROBE [0-9.]* 2\.10\.0 " "$LOGS/0_seed.log"
- name: "A (merge base): a re-run keeps 2.10"
working-directory: ${{ runner.temp }}/base
run: |
set -o pipefail
bash install.sh --local 2>&1 | tee "$LOGS/A_base_rerun.log"
bash "$HELPER" probe | tee "$LOGS/A_probe.log"
grep -q "existing install has torch 2.10.0 -- keeping it" "$LOGS/A_base_rerun.log"
grep -q "^PROBE [0-9.]* 2\.10\.0 " "$LOGS/A_probe.log"
- name: "B (head): a re-run moves 2.10 to the 2.13 route"
run: |
set -o pipefail
bash install.sh --local 2>&1 | tee "$LOGS/B_head_rerun.log"
bash "$HELPER" probe | tee "$LOGS/B_probe.log"
grep -q "existing install has torch 2.10.0 -- moving to torch>=2.13.0,<2.14.0" "$LOGS/B_head_rerun.log"
# Hosted macos-15 runners expose a paravirtual Metal device without MPS: the versions are checked always,
# MPS (and the helper's SDPA check) only where it is available.
grep -Eq "^PROBE [0-9.]+ 2\.13\.[0-9]+ 0\.28\.[0-9]+ 2\.11\.[0-9]+ mps (True|False)" "$LOGS/B_probe.log"
- name: "B2 (head): a second re-run and studio update keep 2.13"
env:
STUDIO_LOCAL_REPO: ${{ github.workspace }}
run: |
set -o pipefail
bash install.sh --local 2>&1 | tee "$LOGS/B2_head_rerun.log"
grep -Eq "existing install has torch 2\.13\.[0-9]+ -- keeping it" "$LOGS/B2_head_rerun.log"
"$UNSLOTH_STUDIO_HOME/unsloth_studio/bin/unsloth" studio update --local 2>&1 | tee "$LOGS/B2_update.log"
bash "$HELPER" probe | tee "$LOGS/B2_probe.log"
grep -Eq "^PROBE [0-9.]+ 2\.13\.[0-9]+ 0\.28\.[0-9]+ " "$LOGS/B2_probe.log"
- name: "C (head): UNSLOTH_TORCH_UPGRADE=0 keeps a 2.10 home"
run: |
set -o pipefail
bash "$HELPER" seed 2.10.0 0.25.0 2.10.0 | tee "$LOGS/C_seed.log"
UNSLOTH_TORCH_UPGRADE=0 bash install.sh --local 2>&1 | tee "$LOGS/C_optout.log"
bash "$HELPER" probe | tee "$LOGS/C_probe.log"
grep -q "existing install has torch 2.10.0 -- keeping it" "$LOGS/C_optout.log"
grep -q "^PROBE [0-9.]* 2\.10\.0 " "$LOGS/C_probe.log"
- name: "D (head): a 2.14.1 home is kept"
run: |
set -o pipefail
bash "$HELPER" seed 2.14.1 0.29.2 2.11.1 | tee "$LOGS/D_seed.log"
bash install.sh --local 2>&1 | tee "$LOGS/D_rerun.log"
bash "$HELPER" probe | tee "$LOGS/D_probe.log"
grep -q "existing install has torch 2.14.1 -- keeping it" "$LOGS/D_rerun.log"
grep -q "^PROBE [0-9.]* 2\.14\.1 " "$LOGS/D_probe.log"
- name: Declare this job a uv cache consumer, not a producer
uses: ./.github/actions/uv-cache-save
with:
cache-hit: ${{ steps.uv-cache.outputs.cache-hit }}
key: ${{ steps.uv-cache.outputs.key }}
save: 'false'

- name: Upload logs
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: mac-torch-floor-py${{ matrix.python }}
path: logs/
retention-days: 7
20 changes: 17 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4368,6 +4368,8 @@ _CU130_NEW_INSTALL_TORCH="torch>=2.13.0,<2.14.0"
# Apple Silicon: 2.13 is the first with fused MPS attention (mflux needs >=2.13); 2.15 lacks cp310/torchvision.
_MACOS_TORCH_CEILING="2.15.0"
_MACOS_NEW_INSTALL_TORCH="torch>=2.13.0,<2.14.0"
# An existing home below this moves to the new-install spec; fixed at Studio's fused-attention gate, not the pin.
_MACOS_TORCH_MOVE_FLOOR="2.13.0"

# ── Resolve repo root (for --local installs) ──
_REPO_ROOT="$(cd "$(dirname "$0" 2>/dev/null || echo ".")" && pwd)"
Expand Down Expand Up @@ -7035,6 +7037,7 @@ fi # _torch_index_pinned guard (Radeon + Strix reroute)
_PRESERVE_TORCH_CONSTRAINT="$TORCH_CONSTRAINT"
_CU130_NEW_INSTALL_ROUTE=false
_MACOS_NEW_INSTALL_ROUTE=false
_MACOS_FLOOR_MOVE=false
if [ "$SKIP_TORCH" = false ] && [ "$(_cu130_torch213_platform "$TORCH_INDEX_URL")" = "yes" ]; then
_PRESERVE_TORCH_CONSTRAINT="torch>=2.4,<${_CU130_TORCH_CEILING}"
# An existing home never takes 2.13 unasked, even when its torch could not be read or kept.
Expand All @@ -7046,20 +7049,31 @@ if [ "$SKIP_TORCH" = false ] && [ "$(_cu130_torch213_platform "$TORCH_INDEX_URL"
_CU130_NEW_INSTALL_ROUTE=true
fi
elif [ "$SKIP_TORCH" = false ] && [ "$(_macos_torch213_platform "$TORCH_INDEX_URL")" = "yes" ]; then
# Same policy as cu130: keep a resident 2.4-2.14, move only a fresh home (or an explicit upgrade).
# Same policy as cu130: keep a resident 2.4-2.14, move a fresh home (or an explicit upgrade).
# Except a resident release below _MACOS_TORCH_MOVE_FLOOR (no fused MPS attention): it moves too when the route is
# open, unless UNSLOTH_TORCH_UPGRADE is set (=0 keeps it).
_PRESERVE_TORCH_CONSTRAINT="${TORCH_CONSTRAINT%%,*},<${_MACOS_TORCH_CEILING}"
_macos_below_floor=false
if [ "$_EXISTING_INSTALL" = true ] && [ -z "${UNSLOTH_TORCH_UPGRADE:-}" ] \
&& [ -n "$(_previous_torch_pin "$_PREV_TORCH_VER" "${TORCH_CONSTRAINT%%,*},<${_MACOS_TORCH_MOVE_FLOOR}" keep)" ]; then
_macos_below_floor=true
fi
if [ "$(printf '%s' "$PACKAGE_NAME" | tr '[:upper:]' '[:lower:]')" = "unsloth" ] \
&& { [ "$_EXISTING_INSTALL" = false ] || [ "${UNSLOTH_TORCH_UPGRADE:-0}" = "1" ]; } \
&& { [ "$_EXISTING_INSTALL" = false ] || [ "${UNSLOTH_TORCH_UPGRADE:-0}" = "1" ] || [ "$_macos_below_floor" = true ]; } \
&& [ "${_torch_index_pinned:-false}" = false ] \
&& [ "$(_macos_torch213_host_ok)" = "yes" ] \
&& [ "$(_pypi_unsloth_admits_torch "2.13.0")" = "yes" ]; then
# an index set with UNSLOTH_TORCH_INDEX_URL (a mirror or snapshot) may not carry 2.13: only the chosen one moves
_MACOS_NEW_INSTALL_ROUTE=true
_MACOS_FLOOR_MOVE="$_macos_below_floor"
fi
fi
if [ "$_MACOS_FLOOR_MOVE" = true ]; then
substep "existing install has torch $_PREV_TORCH_VER -- moving to $_MACOS_NEW_INSTALL_TORCH for the fused MPS attention kernel (set UNSLOTH_TORCH_UPGRADE=0 to keep it)"
fi
_PREV_TORCH_PIN=""
_PREV_FALLBACK_CONSTRAINT="$TORCH_CONSTRAINT"
if [ "$SKIP_TORCH" = false ]; then
if [ "$SKIP_TORCH" = false ] && [ "$_MACOS_FLOOR_MOVE" = false ]; then
_prev_pin=$(_previous_torch_pin "$_PREV_TORCH_VER" "$_PRESERVE_TORCH_CONSTRAINT")
if [ -z "$_prev_pin" ] && [ "${UNSLOTH_TORCH_UPGRADE:-0}" = "1" ] \
&& [ "$_CU130_NEW_INSTALL_ROUTE" = false ] && [ "$_MACOS_NEW_INSTALL_ROUTE" = false ] \
Expand Down
89 changes: 84 additions & 5 deletions tests/sh/test_macos_torch213_route.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ assert_eq "install.sh new-install body matches the replayed one" "yes" \
"$(grep -A2 '^if \[ -z "\$_PREV_TORCH_PIN" \] && \[ "\$_MACOS_NEW_INSTALL_ROUTE" = true \]; then$' "$INSTALL_SH" | tail -2 \
| tr -d '\n' | grep -qF 'TORCH_CONSTRAINT="$_MACOS_NEW_INSTALL_TORCH" TORCHVISION_CONSTRAINT="torchvision>=0.28.0,<0.29.0"' && echo yes)"
substep() { :; }
eval "$(grep -E '^_(CU130|MACOS)_(TORCH_CEILING|NEW_INSTALL_TORCH)=' "$INSTALL_SH")"
eval "$(grep -E '^_(CU130|MACOS)_(TORCH_CEILING|NEW_INSTALL_TORCH|TORCH_MOVE_FLOOR)=' "$INSTALL_SH")"
assert_eq "macOS ceiling" "2.15.0" "$_MACOS_TORCH_CEILING"
assert_eq "macOS new-install spec" "torch>=2.13.0,<2.14.0" "$_MACOS_NEW_INSTALL_TORCH"
assert_eq "macOS move floor is the fused-attention gate" "2.13.0" "$_MACOS_TORCH_MOVE_FLOOR"
SKIP_TORCH=false; TORCH_INDEX_URL="$CPU"; PACKAGE_NAME="unsloth"
_run_block() { # $1 existing-install flag, $2 previous torch version, $3 default floor
_EXISTING_INSTALL="$1"; _PREV_TORCH_VER="$2"
Expand All @@ -107,10 +108,14 @@ for gate in unreachable capped open; do
assert_eq "PyPI $gate: existing 2.13 kept" "torch==2.13.0" "$TORCH_CONSTRAINT"
_run_block true "2.14.1"
assert_eq "PyPI $gate: existing 2.14 kept" "torch==2.14.1" "$TORCH_CONSTRAINT"
_run_block true "2.11.0"
assert_eq "PyPI $gate: existing 2.11 kept" "torch==2.11.0" "$TORCH_CONSTRAINT"
assert_eq "PyPI $gate: kept 2.11 keeps its torchvision window" "torchvision>=0.19,<0.27.0" "$TORCHVISION_CONSTRAINT"
assert_eq "PyPI $gate: kept pin falls back to the old default" "torch>=2.6,<2.12.0" "$_PREV_FALLBACK_CONSTRAINT"
if [ "$gate" != open ]; then
_run_block true "2.11.0"
assert_eq "PyPI $gate: existing 2.11 kept" "torch==2.11.0" "$TORCH_CONSTRAINT"
assert_eq "PyPI $gate: kept 2.11 keeps its torchvision window" "torchvision>=0.19,<0.27.0" "$TORCHVISION_CONSTRAINT"
assert_eq "PyPI $gate: kept pin falls back to the old default" "torch>=2.6,<2.12.0" "$_PREV_FALLBACK_CONSTRAINT"
_run_block true "2.10.0"
assert_eq "PyPI $gate: existing 2.10 kept (no 2.13 to move to)" "torch==2.10.0" "$TORCH_CONSTRAINT"
fi
_run_block true ""
assert_eq "PyPI $gate: existing home with unreadable torch stays on the old default" "torch>=2.6,<2.12.0" "$TORCH_CONSTRAINT"
_run_block false ""
Expand Down Expand Up @@ -140,6 +145,80 @@ SKIP_TORCH=true; _run_block false ""; SKIP_TORCH=false
assert_eq "--no-torch never takes the route" "torch>=2.6,<2.12.0" "$TORCH_CONSTRAINT"
_stub_python 3.9; _run_block false "" 2.4; _stub_python 3.13
assert_eq "Python 3.9 keeps the old window" "torch>=2.4,<2.12.0" "$_PRESERVE_TORCH_CONSTRAINT"

echo "=== an existing home below the 2.13 floor moves to 2.13 when the route is open ==="
_pypi_fixture "torch<2.15.0,>=2.4.0"
_SUBSTEP_LOG=$(mktemp)
substep() { printf '%s\n' "$1" >> "$_SUBSTEP_LOG"; }
for prev in 2.10.0 2.11.0 2.12.1 2.6.0; do
: > "$_SUBSTEP_LOG"
_run_block true "$prev"
assert_eq "existing $prev moves to the new-install spec" "torch>=2.13.0,<2.14.0" "$TORCH_CONSTRAINT"
assert_eq "existing $prev moves torchvision with it" "torchvision>=0.28.0,<0.29.0" "$TORCHVISION_CONSTRAINT"
assert_eq "existing $prev is not a kept pin" "" "$_PREV_TORCH_PIN"
assert_contains "existing $prev: the move is announced with its opt-out" "$(cat "$_SUBSTEP_LOG")" "UNSLOTH_TORCH_UPGRADE=0"
assert_not_contains "existing $prev: no 'keeping it' line" "$(cat "$_SUBSTEP_LOG")" "keeping it"
done
_run_block true "2.10.0+cpu"
assert_eq "a local-tagged 2.10.0+cpu moves too" "torch>=2.13.0,<2.14.0" "$TORCH_CONSTRAINT"
for prev in 2.13.0 2.13.1 2.14.0 2.14.1; do
: > "$_SUBSTEP_LOG"
_run_block true "$prev"
assert_eq "existing $prev (at or above the floor) kept" "torch==$prev" "$TORCH_CONSTRAINT"
assert_contains "existing $prev: 'keeping it' line" "$(cat "$_SUBSTEP_LOG")" "keeping it"
done
for v in 0 false no; do
UNSLOTH_TORCH_UPGRADE=$v; _run_block true "2.10.0"; unset UNSLOTH_TORCH_UPGRADE
assert_eq "UNSLOTH_TORCH_UPGRADE=$v keeps an existing 2.10" "torch==2.10.0" "$TORCH_CONSTRAINT"
assert_eq "UNSLOTH_TORCH_UPGRADE=$v keeps the 2.10 torchvision window" "torchvision>=0.19,<0.27.0" "$TORCHVISION_CONSTRAINT"
done
UNSLOTH_TORCH_UPGRADE=""; _run_block true "2.10.0"; unset UNSLOTH_TORCH_UPGRADE
assert_eq "an empty UNSLOTH_TORCH_UPGRADE is the default (moves)" "torch>=2.13.0,<2.14.0" "$TORCH_CONSTRAINT"
UNSLOTH_TORCH_UPGRADE=1; _run_block true "2.10.0"; unset UNSLOTH_TORCH_UPGRADE
assert_eq "UNSLOTH_TORCH_UPGRADE=1 still moves an existing 2.10" "torch>=2.13.0,<2.14.0" "$TORCH_CONSTRAINT"
_torch_index_pinned=true; _run_block true "2.10.0"; _torch_index_pinned=false
assert_eq "a pinned index keeps an existing 2.10" "torch==2.10.0" "$TORCH_CONSTRAINT"
MACOS_MAJOR=13; _run_block true "2.10.0"; MACOS_MAJOR=15
assert_eq "macOS 13 keeps an existing 2.10 (no macosx_14_0 wheel)" "torch==2.10.0" "$TORCH_CONSTRAINT"
_stub_python 3.13 gil-disabled; _run_block true "2.10.0"; _stub_python 3.13
assert_eq "free-threaded Python keeps an existing 2.10" "torch==2.10.0" "$TORCH_CONSTRAINT"
PACKAGE_NAME="unsloth-fork"; _run_block true "2.10.0"; PACKAGE_NAME="unsloth"
assert_eq "--package other than unsloth keeps an existing 2.10" "torch==2.10.0" "$TORCH_CONSTRAINT"
_run_block true "2.12.0.dev20261001"
assert_eq "a nightly below the floor is unchanged (old default, never 2.13)" "torch>=2.6,<2.12.0" "$TORCH_CONSTRAINT"
_run_block true "2.3.1" 2.4
assert_eq "a release under the window floor is unchanged (old default)" "torch>=2.4,<2.12.0" "$TORCH_CONSTRAINT"
_stub_python 3.9; _run_block true "2.10.0" 2.4; _stub_python 3.13
assert_eq "Python 3.9 keeps an existing 2.10" "torch==2.10.0" "$TORCH_CONSTRAINT"
SKIP_TORCH=true; _run_block true "2.10.0"; SKIP_TORCH=false
assert_eq "--no-torch never moves an existing home" "torch>=2.6,<2.12.0" "$TORCH_CONSTRAINT"
_ARCH=x86_64; _run_block true "2.2.2" 2.2; _ARCH=arm64
assert_eq "Intel macOS keeps its torch (2.2.2)" "torch==2.2.2" "$TORCH_CONSTRAINT"
_ARCH=x86_64; _run_block true "2.2.2" 2.2; _ARCH=arm64
assert_eq "Intel macOS window untouched" "torch>=2.2,<2.12.0" "$_PRESERVE_TORCH_CONSTRAINT"
for os in linux wsl windows; do
OS=$os
_run_block true "2.10.0"
assert_eq "$os cpu: existing 2.10 kept" "torch==2.10.0" "$TORCH_CONSTRAINT"
assert_eq "$os cpu: window untouched" "torch>=2.6,<2.12.0" "$_PRESERVE_TORCH_CONSTRAINT"
TORCH_INDEX_URL="https://download.pytorch.org/whl/cu128"
_run_block true "2.10.0+cu128"
assert_eq "$os cu128: existing 2.10 kept" "torch==2.10.0" "$TORCH_CONSTRAINT"
TORCH_INDEX_URL="$CPU"
done
OS=macos
# A later pin bump (here to 2.14) must not move a 2.13 home: the floor is its own literal.
_pin_saved="$_MACOS_NEW_INSTALL_TORCH"; _MACOS_NEW_INSTALL_TORCH="torch>=2.14.0,<2.15.0"
_run_block true "2.13.0"
assert_eq "pin bumped to 2.14: an existing 2.13 home is kept" "torch==2.13.0" "$TORCH_CONSTRAINT"
_run_block true "2.13.1"
assert_eq "pin bumped to 2.14: an existing 2.13.1 home is kept" "torch==2.13.1" "$TORCH_CONSTRAINT"
_run_block true "2.10.0"
assert_eq "pin bumped to 2.14: an existing 2.10 home moves to the bumped pin" "torch>=2.14.0,<2.15.0" "$TORCH_CONSTRAINT"
_MACOS_NEW_INSTALL_TORCH="$_pin_saved"
rm -f "$_SUBSTEP_LOG"
substep() { :; }

OS=linux; TORCH_INDEX_URL="https://download.pytorch.org/whl/cu128"; _run_block false "" 2.4
assert_eq "Linux cu128 is untouched" "torch>=2.4,<2.12.0" "$TORCH_CONSTRAINT"
assert_eq "Linux cu128 window untouched" "torch>=2.4,<2.12.0" "$_PRESERVE_TORCH_CONSTRAINT"
Expand Down
Loading