Skip to content

Core: pip extras and auto-install support for torch 2.13 and 2.14 - #12151

Merged
danielhanchen merged 5 commits into
mainfrom
core-torch-213-214-extras
Oct 2, 2026
Merged

danielhanchen merged 5 commits into
mainfrom
core-torch-213-214-extras

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Adds Core pip extras for torch 2.13.0 and 2.14.0, and teaches the auto-install helper about them.

Changes

  • pyproject.toml:
    • Base extras cu126onlytorch2130, cu130onlytorch2130, cu126onlytorch2140 and cu130onlytorch2140, with their cuXXX-torch21X0 and cuXXX-ampere-torch21X0 wrappers, following the torch2120 / torch2121 rows.
    • Pairings: torch 2.13.0 with torchvision 0.28.0 and torch 2.14.0 with torchvision 0.29.0, both with torchaudio 2.11.0. torchaudio 2.11.0 is its last release (stable ABI, no torch pin); vLLM 0.30 uses the same pairing. xFormers stays on the 0.0.35 stable-ABI wheel.
    • No cu128 rows: the cu128 index stops at torch 2.11.
  • unsloth/_auto_install.py:
    • 2.13.0 maps to torch2130 and 2.14.0 to torch2140. The existing CUDA 12.6 / 13.0 requirement for torch 2.12 and newer still applies.
    • Unlisted patch releases (2.12.2, 2.13.1) are refused, as 2.12.2 already is, because torchvision pins an exact torch and a wrong extra would downgrade it.
    • Anything from 2.14.1 upward still reports "too new".
  • tests/test_torch2110_cuda_extras.py: rows for both series, plus tests that run _auto_install.py against a stub torch and check the printed extra and index URL. 22 of the new tests fail on main's files; all 59 pass here.

Resolution check

Each case is a dry-run uv pip install of the extra plus its wrapper on Python 3.13, with the matching extra index:

Extra torch torchvision torchaudio xformers triton
cu126 torch2130 2.13.0+cu126 0.28.0+cu126 2.11.0+cu126 0.0.35 3.7.1
cu126 torch2140 2.14.0+cu126 0.29.0+cu126 2.11.0+cu126 0.0.35 3.8.0
cu130 torch2130 2.13.0+cu130 0.28.0+cu130 2.11.0+cu130 0.0.35 3.7.1
cu130 torch2140 2.14.0+cu130 0.29.0+cu130 2.11.0+cu130 0.0.35 3.8.0

All four resolve with no conflicts. Every pinned wheel exists on download.pytorch.org for cp312 and cp313, on both manylinux_2_28_x86_64 and win_amd64.

Related

The released package still caps torch at <2.13.0 from the pip branch; a companion PR raises it to <2.15.0 so these extras resolve against a release.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T14:10:33.609829Z 9539a27 Manual request
🔒 Security Review ✅ Completed 2026-09-28T08:44:14.946131Z 1d3b743 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 1d3b743338

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d3b743338

ℹ️ 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".

Comment thread unsloth/_auto_install.py
Comment on lines +42 to +44
elif v < V('2.13.1'): x = 'cu{}{}-torch2130'
elif v < V('2.14.0'): raise RuntimeError(f"Torch = {v} not supported!")
elif v < V('2.14.1'): x = 'cu{}{}-torch2140'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject cu126 builds on Blackwell before selecting the new extras

When torch 2.13/2.14 is installed from cu126 on an SM100/SM120 GPU, these branches now emit an install command even though the adjacent comment documents that cu126 stops at SM90 and Blackwell requires CUDA 13. The script already reads torch.cuda.get_device_capability() but never applies it, so the generated environment can install successfully and then fail when CUDA kernels run; reject this combination or require cuda == "13.0" when the capability is at least 10.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this here: the script only prints the extra matching the torch that is already installed, and torch 2.12 on main behaves the same way. A cu126 torch on a Blackwell card is already unusable before this runs, and the extra reinstalls that same build.

Comment thread pyproject.toml
cu126onlytorch2130 = [
"torch==2.13.0+cu126",
"torchvision==0.28.0+cu126",
"torchaudio==2.11.0+cu126",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Drop the incompatible torchaudio 2.11 pins

Every new torch 2.13/2.14 leaf pins torchaudio 2.11 even though torchaudio's native extension must match the torch release line; the repository's own install.ps1::Test-WoaWheelPairsWithTorch therefore explicitly rejects the 2.14/2.11 pairing. Because 2.11 no longer constrains torch in its metadata, dependency resolution succeeds but leaves audio operations with an ABI-mismatched extension, so these new extras should omit torchaudio unless a matching compatible build is available.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked on real wheels: torchaudio 2.11.0+cu130 ships abi3 (stable ABI) libraries, and on torch 2.13.0+cu130 and 2.14.0+cu130 its extension loads and forced_align, rnnt_loss and lfilter run on CPU and CUDA. The install.ps1 check is for the custom Windows on ARM builds, which are not abi3.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d3b743338

ℹ️ 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".

Comment thread unsloth/_auto_install.py
Comment on lines +42 to +44
elif v < V('2.13.1'): x = 'cu{}{}-torch2130'
elif v < V('2.14.0'): raise RuntimeError(f"Torch = {v} not supported!")
elif v < V('2.14.1'): x = 'cu{}{}-torch2140'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject prereleases before selecting stable extras

When an installed build reports a version such as 2.13.0rc1+cu130 or 2.13.0a0+cu130, the regex above truncates it to 2.13.0, so this new branch selects torch2130; the resulting extra exact-pins the stable torch==2.13.0+cu130 trio and replaces the prerelease/source build rather than refusing it. The same problem affects the new 2.14 branch, so inspect the full parsed version for prerelease/dev markers before mapping these stable-only extras.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same mapping every branch in this script uses: a 2.12.0rc1 build maps to torch2120 on main today. Prerelease handling would be a separate change across all the branches, not something these two lines introduce.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 071747a255

ℹ️ 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".

Comment thread unsloth/_auto_install.py Outdated
elif v < V('2.12.2'): x = 'cu{}{}-torch2121'
elif v < V('2.13.0'): raise RuntimeError(f"Torch = {v} not supported!")
# torch2130 / torch2140 pin the stable release, so a pre-release or source build would be replaced.
elif re.match(r"[0-9\.]{3,}(?:\+|$)", torch.__version__) is None: raise RuntimeError(f"Torch = {torch.__version__} is a pre-release; install a stable torch!")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject non-wheel local suffixes before selecting stable extras

When a custom or vendor build reports a stable public version with a different local suffix, such as 2.13.0+git1234 or 2.14.0+cu130.custom, this regex accepts it because it stops matching immediately after +. The generated extra then requires torch==2.13.0+cu130 or torch==2.14.0+cu130, so pip replaces the custom build the guard is intended to preserve. The fresh evidence is that the current revision added this guard specifically to prevent source-build replacement; validate the parsed version's local component against the expected cu126/cu130 tag instead of accepting arbitrary text after +.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9539a27: the version must now be a plain release or carry only a +cuNNN local tag, so +git and other custom local builds are refused.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9539a273e7

ℹ️ 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".

Comment thread unsloth/_auto_install.py
elif v < V('2.12.2'): x = 'cu{}{}-torch2121'
elif v < V('2.13.0'): raise RuntimeError(f"Torch = {v} not supported!")
# torch2130 / torch2140 pin the stable release, so a pre-release, source or custom build would be replaced.
elif re.fullmatch(r"[0-9\.]{3,}(?:\+cu[0-9]+)?", torch.__version__) is None: raise RuntimeError(f"Torch = {torch.__version__} is a pre-release or custom build; install a stable torch!")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require exact stable releases before selecting pinned extras

The new guard still accepts any sequence of digits and dots, so valid custom release versions such as 2.13.0.1+cu130 and 2.14.0.1+cu130 pass it; the subsequent range checks map them to torch2130 or torch2140, whose exact dependency pins replace the installed build with 2.13.0 or 2.14.0. Since this guard is intended to preserve source/custom builds, compare the parsed public release exactly against the supported releases rather than accepting arbitrary numeric components.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this: torch has never published a four-component release, so 2.13.0.1 is not a version a real install reports. Pre-releases, source builds and custom local tags, the cases that do occur, are already refused.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@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 them coming!

Reviewed commit: 9539a273e7

ℹ️ 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
danielhanchen merged commit 0eb7837 into main Oct 2, 2026
85 of 89 checks passed
@danielhanchen
danielhanchen deleted the core-torch-213-214-extras branch October 2, 2026 09:40
rhsCZ pushed a commit to rhsCZ/unsloth that referenced this pull request Nov 4, 2026
Fixes unslothai#16520

## Problem
`main` has carried the torch 2.13 and 2.14 extras since unslothai#12151, but this branch (what gets uploaded to PyPI) never got them. unslothai#12152 raised the base ceiling to `torch<2.15.0` here, and the extras themselves were left out. So on 2026.11.1:

```
$ uv pip compile <(echo "unsloth[cu130-torch2130]==2026.11.1") --extra-index-url https://download.pytorch.org/whl/cu130 --index-strategy unsafe-best-match
warning: The package `unsloth==2026.11.1` does not have an extra named `cu130-torch2130`
torch==2.14.1+cu130
```

The install does not fail. It just ignores the extra and resolves a different torch than the one asked for. `cu130-torch2140` behaves the same way.

## Changes
- `pyproject.toml`: adds the 12 extras from `main`, each placed after its 2.12.1 sibling: `cu126/cu130` x `onlytorch` / `-torch` / `-ampere-torch` x `2130` / `2140`. The xformers wheel URLs are written as `xformers==0.0.35` with the merged platform marker, exactly like the existing torch 2.12 extras on this branch, so there are no direct references for PyPI to reject. Nothing else changes: the base dependencies and all 167 existing extras are byte-identical.
- `tests/python/test_pyproject_pypi_installable.py`: a guard that every `cu*-torch<T>` extra `_auto_install.py` can print exists here, with `cu126` and `cu130` required for torch 2.12 and newer. It fails on the current `pip` head (missing `2130`, `2140`) and passes with this change, so the next torch bump on `main` cannot silently miss the release again.

## Verification
- Wheel metadata built from this branch: 179 extras (167 + 12), 0 direct URLs; the new `Requires-Dist` lines have the same shape as the published `cu130-torch2121` ones.
- With that metadata, `uv pip compile` (Python 3.12, Linux x86_64 and Windows x86_64) resolves each new extra with no warnings:

| extra | resolved torch |
|-------|----------------|
| `cu126-torch2130`, `cu126-ampere-torch2130` | `2.13.0+cu126` |
| `cu130-torch2130`, `cu130-ampere-torch2130` | `2.13.0+cu130` |
| `cu126-torch2140`, `cu126-ampere-torch2140` | `2.14.0+cu126` |
| `cu130-torch2140`, `cu130-ampere-torch2140` | `2.14.0+cu130` |
| `cu126-torch2121`, `cu130-torch2121` (control) | unchanged, `2.12.1+cu126` / `2.12.1+cu130` |

- `python -m pytest tests/python/test_pyproject_pypi_installable.py`: 9 passed (the new test fails on the current `pip` head).

## Effect on users
This only adds extra names. Plain `pip install unsloth`, every existing extra, Studio, Desktop and the notebooks resolve exactly as before. People who ask for `unsloth[cu126-torch2130]` / `unsloth[cu130-torch2140]` and so on now get the torch build they asked for instead of a warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants