Skip to content

Installers: new cu130 homes take torch 2.14 (2.14.1+cu130) instead of 2.13 - #19762

Closed
danielhanchen wants to merge 1 commit into
mainfrom
g99-cu130-torch214
Closed

danielhanchen wants to merge 1 commit into
mainfrom
g99-cu130-torch214

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Status: closed as no gain for now

Moving new cu130 homes off torch 2.13.0 currently costs more than it returns. The details are below. The rest of this body is the original change and its evidence, kept for when this is revisited.

Studio engine reuse

An opt-in engine reuses Studio's torch only when the torch build matches exactly. install_plan sets shared only if _same_build(studio torch, locked torch) holds and every torch runtime package (nvidia-*, cuda-toolkit, triton) fits the lock. Otherwise the engine gets an isolated env with its own torch stack.

lock engine torch
vllm-linux-cu130-torch213 vLLM 0.30.0 torch==2.13.0
vllm-linux-cu130 vLLM 0.26.0 torch==2.11.0
sglang-linux-cu130-torch213 SGLang 0.5.20 torch==2.13.0
sglang-linux-cu130 SGLang 0.5.17 torch==2.11.0

No lock carries a 2.14 build. So 2.13.0 is the only cu130 spec that keeps both engines shared, and every 2.14.x spec isolates both.

New locks would not fix this either. The newest upstream releases pin different 2.14 patches:

  • vLLM 0.33.0 and 0.34.0 pin torch==2.14.0.
  • SGLang 0.5.22 and 0.5.23 pin torch==2.14.1.

Any single 2.14 pick would therefore share with at most one of the two engines. Today, 2.13.0 shares with both.

Cost of isolation

The torch runtime in the vLLM 2.13 lock is about 2.5 GiB of wheels (cp313 manylinux x86_64). It is re-downloaded once per isolated engine env; the uv cache dedupes a second engine on the same torch. The largest pieces:

package size
torch 502 MiB
cublas 404 MiB
cudnn 349 MiB
cufft 204 MiB
nccl 196 MiB
cusolver 192 MiB
triton 189 MiB
cusparselt 162 MiB
cusparse 139 MiB

The unpacked copy in the engine env adds several GB of disk on top.

Benefit of 2.14 for training

Measured: no difference. On a Colab L4, 35 steps, ABBAAB order, 3 runs per arm, unsloth 2026.11.12:

workload 2.13.0 s/step 2.14.1 s/step
Qwen3-4B QLoRA 4.931 4.922
Llama-3.2-3B LoRA 3.596 3.597
Qwen3-0.6B full FT 1.233 1.237
  • Every difference is inside the A/A spread (0.2% to 0.7%).
  • Peak memory is identical, and loss is at parity.

The 2.14-only items in the code are mostly bugs that Unsloth already works around on 2.13:

  • the Inductor reduction readback race is backported (fix_inductor_reduction_readback_race);
  • the masked SDPA bias alignment is padded (attention_dispatch.py);
  • the efficient-attention bias guard is kept (_block_compile.py);
  • FP8 rowwise _scaled_mm with fp16 output dequantizes instead (kernels/fp8.py).

The items that are really 2.14-only are narrow:

  • Exact-size pinned blocks for gradient-checkpoint offload (unsloth_zoo/gradient_checkpointing.py): a host-RAM saving on long-context offload.
  • Flex decoding with a dynamic batch (_utils.py): an inference path, not training.
  • cuDNN head_dim 256 on sm100 (_utils.py): Blackwell only.
  • The block-compile C++ wrapper (_block_compile.py, _CPP_WRAPPER_MIN_TORCH = "2.14.0"):
    • It is not in the released 2026.11.12.
    • Auto mode turns on only on NVIDIA L4, for packed or padding-free runs past 2000 steps.
    • The figures in the code comments (-11.6% / -14.3% s/step) were not re-measured here.

2.14 also adds hazards that need gates: cuDNN 9.24 NaN dQ for masked head_dim 256 on sm90 / sm100 (fix_cudnn_sdpa_d256_masked_backward), and the context-parallel efficient backward giving wrong dq / dk in fp16 / bf16.

When to revisit

Revisit together with the engine-lock update. vLLM 0.33+ pins 2.14.0 and SGLang 0.5.22+ pins 2.14.1, so that update has to choose which engine keeps sharing. Pin new homes to exactly that torch (for example torch==2.14.0 for vLLM, which is on whl/cu130). The C++-wrapper release is the other trigger, if it shows a measured win beyond A/A on the default route.


Summary

New installs on the cu130 route now get torch 2.14 instead of 2.13. This covers install.sh on Linux / WSL x86_64 and aarch64, and install.ps1 on Windows x64. The route needs a driver that reports CUDA 13+, Python 3.13, a GIL build, and glibc 2.35+ on Linux.

before after
torch spec torch>=2.13.0,<2.14.0 torch>=2.14.0,<2.15.0
torchvision spec torchvision>=0.28.0,<0.29.0 torchvision>=0.29.0,<0.30.0
resolves from whl/cu130 (cp313, x86_64 / aarch64 / win_amd64) 2.13.0+cu130, torchvision 0.28.0, torchaudio 2.11.0, triton 3.7.1 2.14.1+cu130, torchvision 0.29.1, torchaudio 2.11.0, triton 3.8.0
PyPI gate (_pypi_unsloth_admits_torch / Test-PypiUnslothAdmitsTorch) asks for 2.13.0 asks for 2.14.0 (the spec floor, now one variable)

Unchanged:

  • Existing homes keep their resident torch. The preserve window is still torch>=2.4,<2.15.0, so a resident 2.13.0 stays 2.13.0. UNSLOTH_TORCH_UPGRADE=1 still opts in and now moves to 2.14.
  • Every other route keeps the default <2.12.0 window: cu128, cu126, cu124 / cu118, Python 3.12, free-threaded builds, glibc < 2.35, CPU, ROCm, XPU and macOS.
  • studio/setup.ps1 needs no change. Its CUDA spec is unbounded, so a run without an installer handoff already resolves the newest release on whl/cu130, which is 2.14.1.
  • studio/install_python_stack.py needs only a comment change. Its cu130 repair already keeps a resident 2.9-2.14. The studio update torch freeze already covers torch >= 2.13 on Linux and Windows x64.

Why 2.14 is safe here

  • The published unsloth wheel caps torch<2.15.0, so 2.14.x is inside the release metadata. The gate now checks for exactly that.
  • prebuilt-wheels-cu13 already publishes torch 2.14 cells for flash-attn, causal-conv1d and mamba-ssm (cp313, linux_x86_64, linux_aarch64, win_amd64). _UNSLOTH_PREBUILT_TORCH_MM already lists 2.14.
  • xFormers 0.0.35 (stable ABI) already serves every torch above 2.10.0 on cu130, in both wheel_utils.py and install.ps1. triton-windows already pairs 3.8 with torch 2.14.

vLLM / SGLang

No installer route puts vLLM into the Studio venv, so the vLLM torch==2.14.0 exact pin never meets this spec. The opt-in Studio engines (engine_install.py) share Studio's torch only on an exact build match. Today that means vLLM 0.30.0 or SGLang 0.5.20 on torch 2.13.0. A new cu130 home on 2.14.1 therefore gets those engines in their own isolated environment, which is the same path every existing 2.14 home and every cu128 / cu126 home already takes. It works, but it costs one extra torch download. The engine locks are not touched here.

Default _TORCH_CEILING (cu128 / cu126) left at 2.12.0

  • cu128: whl/cu128 stops at 2.11.0, so raising the ceiling changes nothing there.
  • cu126: this index serves pre-Turing GPUs, unknown drivers and 12.6 drivers. Moving it to 2.13+ would drop the causal-conv1d / mamba-ssm CUDA wheels. Upstream assets stop at torch 2.12 (PINNED_SOURCE_BUILD_MAX_TORCH), and our prebuilt cells are CUDA 13 only. The same ceiling also drives the CPU route and the repair specs.

Tests

Extended so that the new spec fails on base and passes on head:

  • tests/sh/test_cu130_torch213_route.sh: the specs now come from install.sh rather than literals in the test. Added cases:
    • fresh home gets the 2.14 torch and torchvision specs;
    • a release capped <2.14 keeps the default;
    • resident 2.14.1 and 2.13.0 are kept;
    • UNSLOTH_TORCH_UPGRADE=1 moves a resident 2.13 to 2.14.
  • tests/studio/test_cu130_torch213_route.ps1: the same cases for install.ps1.
  • studio/backend/tests/test_cu130_repair_torch_specs.py: both installers' new-install specs are the top minor that the repair window keeps, and a resident 2.14.1 repairs to itself.

Head test file against base vs head:

test base head
test_cu130_torch213_route.sh 89 passed, 31 failed 119 passed
test_cu130_torch213_route.ps1 fails (no spec floor assignment) all checks passed
test_cu130_repair_torch_specs.py 2 failed, 63 passed 65 passed

Whole-suite parity:

  • All 101 tests/sh/test_*.sh give the same exit codes on base and head.
  • All 45 tests/studio/*.ps1 give the same exit codes on base and head. test_early_python_path_resolver.ps1 fails on both.
  • The 69 installer-related pytest files fail the same 7 tests on base and head (pre-existing ROCm / mask tests); head adds 7 passes.

GPU check (Colab RTX PRO 6000 Blackwell, driver 580.82.07 / CUDA 13.0)

The L4 could not be allocated, so this ran on a G4. Both arms ran on one VM, each in a fresh Python 3.13 venv with the cu130 trio. Then the PyPI unsloth==2026.11.12 was installed, followed by 10 steps of Unsloth LoRA SFT on unsloth/Qwen3-0.6B (seed 3407). The unsloth install did not move torch in either arm.

arm resolved step 10 loss steady step peak
base spec torch 2.13.0+cu130, torchvision 0.28.0, torchaudio 2.11.0, triton 3.7.1 0.95000 71.6 ms 1.38 GB
head spec torch 2.14.1+cu130, torchvision 0.29.1, torchaudio 2.11.0, triton 3.8.0 0.94924 66.2 ms 1.38 GB
  • jobs/compare.py: NO_REGRESSION. All 10 steps are within atol 1e-3 / rtol 5%, there are 0 graph breaks in both arms, and the only version difference is torch, which is expected.
  • A 10-step smoke run cannot resolve the step-time difference; that is not a benchmark claim.
  • On the same VM, the head install.sh in a fresh Studio home picked 2.14.1+cu130 from whl/cu130. The Studio stack then added torchao 0.18.0 and torchcodec 0.12+ for it.

Staging CI

leg result
ubuntu-latest test_cu130_repair_torch_specs.py: 65 passed
windows-latest test_cu130_repair_torch_specs.py: 65 passed
macos-15 / macos-26 64 passed, 1 failed

The macOS failure is test_core_update_freezes_only_torch_past_the_released_ceiling[darwin-2.13.0-False]. It predates this PR and also fails on main:

  • The case patches sys.platform but not platform.machine().
  • _FreezeNewTorchForCoreUpdate freezes every Apple Silicon release.
  • So the case fails on any arm64 Mac.

Reproduced on base and head by forcing platform.machine() to arm64: the same single failure on both. It is left for a separate fix.

New Linux and Windows x64 installs on the cu130 route (driver CUDA 13+, Python 3.13, GIL build,
glibc 2.35+) now get torch>=2.14.0,<2.15.0 with torchvision 0.29 from whl/cu130, which resolves
2.14.1+cu130. The PyPI gate asks the released unsloth metadata for 2.14 instead of 2.13. Existing
homes keep their resident release exactly as before; UNSLOTH_TORCH_UPGRADE=1 still opts in.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T13:24:56.017294Z d71fc43 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: d71fc43e7c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member Author

The macos-26 failure in the cross-platform staging run (test_core_update_freezes_only_torch_past_the_released_ceiling[darwin-2.13.0-False], assert True is False) is not caused by this PR. The test reads the real platform.machine(), and on an Apple Silicon runner the freeze added in #18659 engages for the darwin row, which stands for Intel macOS. It fails the same way on main under a simulated arm64 host. #19772 pins the machine in that test.

danielhanchen added a commit that referenced this pull request Nov 26, 2026
…19772)

## Problem

On Apple Silicon macOS runners,
`studio/backend/tests/test_cu130_repair_torch_specs.py::test_core_update_freezes_only_torch_past_the_released_ceiling[darwin-2.13.0-False]`
fails. For example, the macos-26 leg of the cross-platform staging run
for #19762:

```
    assert mod._TORCH_FREEZE_ACTIVE is pinned
E   AssertionError: assert True is False
```

The test passes on Linux, which is why the normal CI shards never show
it.

## Cause

- #18659 made `_FreezeNewTorchForCoreUpdate` keep an Apple Silicon
install's torch at any release: `sys.platform == "darwin" and
platform.machine() == "arm64"`.
- This test fakes `sys.platform` per row but read the real
`platform.machine()`. Its darwin row expects no freeze, so the row
really means Intel macOS.
- On an x64 Linux runner the machine is `x86_64` and the row passes. On
an arm64 macOS runner it is `arm64`, the freeze engages, and the row
fails.

The code is correct, and Apple Silicon's freeze is already covered by
`test_macos_core_update_torch_freeze.py`. The test is host-dependent.

## Fix

Pin `platform.machine()` to `x86_64` in this test, so every row
describes an x64 host and the darwin row is Intel macOS on any runner.
No product code changes.

## Verification

To reproduce an Apple Silicon host on Linux, a small plugin sets
`platform.machine = lambda: "arm64"` before the session:

| Arm | Simulated arm64 host | Native x86_64 host |
|---|---|---|
| main 6a3a230 | `1 failed, 57 passed`: the same
`darwin-2.13.0-False` row as the macos-26 job | `58 passed` |
| this branch | `58 passed` | `58 passed` |

Sabotage: making the freeze apply to every macOS machine (dropping the
`platform.machine() == "arm64"` check in
`studio/install_python_stack.py`) fails the darwin row on this branch.
The row therefore still guards that Intel macOS is not frozen.

#19762 edits the same parametrize list. Its own macOS failure is this
one, so it will pass once this lands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant