From bc9cf314786041648a547722660379eb92e6c871 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Wed, 25 Mar 2026 07:20:55 -0700 Subject: [PATCH] Pin torch>=2.4,<2.11.0 in Studio installers (#4595) torch 2.11.0 has a torch.compile/dynamo bug that causes a StopIteration crash in dict_keys_getitem when compiling MoE router functions (e.g. GptOssTopKRouter_forward). Pin to <2.11.0 until the upstream fix lands. Applies to both install.sh (Linux/macOS) and install.ps1 (Windows) fresh install paths. --- install.ps1 | 2 +- install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install.ps1 b/install.ps1 index 83576d9c75..a4ed2658c9 100644 --- a/install.ps1 +++ b/install.ps1 @@ -583,7 +583,7 @@ shell.Run cmd, 0, False uv pip install --python $VenvPython --reinstall-package unsloth --reinstall-package unsloth-zoo "unsloth>=2026.3.11" unsloth-zoo } elseif ($TorchIndexUrl) { Write-Host "==> Installing PyTorch ($TorchIndexUrl)..." - uv pip install --python $VenvPython torch torchvision torchaudio --index-url $TorchIndexUrl + uv pip install --python $VenvPython "torch>=2.4,<2.11.0" torchvision torchaudio --index-url $TorchIndexUrl if ($LASTEXITCODE -ne 0) { Write-Host "[ERROR] Failed to install PyTorch (exit code $LASTEXITCODE)" -ForegroundColor Red return diff --git a/install.sh b/install.sh index ec5008af12..6f60c23d27 100755 --- a/install.sh +++ b/install.sh @@ -775,7 +775,7 @@ if [ "$_MIGRATED" = true ]; then elif [ -n "$TORCH_INDEX_URL" ]; then # Fresh: Step 1 - install torch from explicit index echo "==> Installing PyTorch ($TORCH_INDEX_URL)..." - uv pip install --python "$_VENV_PY" torch torchvision torchaudio \ + uv pip install --python "$_VENV_PY" "torch>=2.4,<2.11.0" torchvision torchaudio \ --index-url "$TORCH_INDEX_URL" # Fresh: Step 2 - install unsloth, preserving pre-installed torch echo "==> Installing unsloth (this may take a few minutes)..."