Repository navigation
Core: pip extras and auto-install support for torch 2.13 and 2.14 - #12151
Conversation
|
@codex review |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 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".
| 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' |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
| cu126onlytorch2130 = [ | ||
| "torch==2.13.0+cu126", | ||
| "torchvision==0.28.0+cu126", | ||
| "torchaudio==2.11.0+cu126", |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
@codex review |
There was a problem hiding this comment.
💡 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".
| 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' |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 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".
| 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!") |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 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".
| 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!") |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
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.
Adds Core pip extras for torch 2.13.0 and 2.14.0, and teaches the auto-install helper about them.
Changes
pyproject.toml:cu126onlytorch2130,cu130onlytorch2130,cu126onlytorch2140andcu130onlytorch2140, with theircuXXX-torch21X0andcuXXX-ampere-torch21X0wrappers, following the torch2120 / torch2121 rows.unsloth/_auto_install.py:tests/test_torch2110_cuda_extras.py: rows for both series, plus tests that run_auto_install.pyagainst 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 installof the extra plus its wrapper on Python 3.13, with the matching extra index: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.0from thepipbranch; a companion PR raises it to<2.15.0so these extras resolve against a release.