Repository navigation
fix auto-install mapping torch 2.7.1 to torch271 extra - #18348
Conversation
LeoBorcherding
left a comment
There was a problem hiding this comment.
Tested at 36acd07d against base f95a5b1 on a Colab T4 (Python 3.12). Each row is a clean venv with torch==X from the cu126 index, then the printed command run as-is. That command installs unsloth from main, which is fine here because the PR only changes _auto_install.py, the script that picks the extra.
| torch before | side | extra | torch after | xformers |
|---|---|---|---|---|
| 2.7.0 | both (same extra, installed once) | cu126-torch270 |
2.7.0, kept | 0.0.30, works |
| 2.7.1 | base | cu126-torch270 |
2.7.0, downgraded (uninstalls 2.7.1, pulls 865 MB of torch 2.7.0) | 0.0.30 |
| 2.7.1 | this PR | cu126-torch271 |
2.7.1, kept | 0.0.31.post1, works, 10-step SFT 2.99 to 0.39 |
| 2.8.0 | both (same extra, installed once) | cu126-torch280 |
2.8.0, kept | 0.0.32.post2, works |
On base, the torch271 line could never be reached, because no torch release falls between 2.7.9 and 2.8.0 (_auto_install.py:30). The new test fails 4 of 9 cases against base's script (all four are 2.7.1) and passes 9 of 9 here. For every released torch version, the extra the script prints exists in pyproject.toml.
Outside this PR: cu126onlytorch280 points at the cu128 xformers wheel (pyproject.toml:455-457). It still ran fine on the T4.
Not tested: cu118/cu128 installs (same path, different tag; unit tests only), Windows, and Pythons other than 3.12.
There was a problem hiding this comment.
Re-checked at d8f257b8 on a MacBook Pro M5 (macOS 26, Python 3.12). This is a logic test: _auto_install.py runs against a stand-in torch module and nothing gets installed. The real installs on the Colab T4 are in the first review.
I ran it for every torch and CUDA pair on download.pytorch.org from 2.1.0 on: 75 pairs, each with and without the +cuNNN tag, so 150 runs. Against base f95a5b1f, only the six 2.7.1 runs (cu118, cu126, cu128) change, from torch270 to torch271, and every extra the script prints exists in pyproject.toml. Pairs the script doesn't support (cu129, cu132, cu134, torch 2.14.1 and 2.15.0) raise the same error on base and here.
| run | base f95a5b1f script |
this PR |
|---|---|---|
test_torch2110_cuda_extras.py -k torch27 (9 cases) |
4 failed (all 2.7.1), 5 passed | 9 passed |
all of test_torch2110_cuda_extras.py |
73 passed |
Pushed d8f257b8 to this branch. The torch260 boundary row used 2.6.1+cu124, but torch 2.6.1 was never released, so it's now 2.6.0+cu124. _auto_install.py is unchanged. Codex on our mirror found no issues at this head.
The real cu128 install is done too: a Colab T4 (Python 3.12), one VM, a clean venv per side with torch==2.7.1 from the cu128 index, then _auto_install.py from base f95a5b1f and from d8f257b8, and the printed command run as-is. The command installs unsloth from main, which is fine because this PR only changes _auto_install.py.
base f95a5b1f |
this PR d8f257b8 |
|
|---|---|---|
| extra it prints | cu128-torch270 |
cu128-torch271 |
| torch after install | 2.7.0+cu126: uninstalls 2.7.1+cu128 and torchvision, and drops to CUDA 12.6 | 2.7.1+cu128, kept |
| xformers | 0.0.30 | 0.0.31.post1 |
memory_efficient_attention on the T4 |
works | works |
| 10-step LoRA SFT, SmolLM2-135M | loss 0.708 to 0.598 | loss 0.708 to 0.598 |
So on cu128, base doesn't just downgrade torch, it also swaps the CUDA 12.8 build for the default PyPI CUDA 12.6 one, because the xformers 0.0.30 wheel in the torch270 extra pulls plain torch==2.7.0. This PR keeps the user's torch and CUDA build. Nothing else is outstanding from my side.
…treaming without diffusers (#18535) ## Summary `(Python 3.13, diffusion)` fails on `main` for every PR (seen on #18526 and #18348, neither of which touches diffusion). Four tests, from two recent merges: ``` FAILED tests/test_diffusion_backend.py::test_apply_loras_quant_unbaked_requires_reload FAILED tests/test_diffusion_backend.py::test_apply_loras_quant_baked_matrix Expected regex: 'Reload the model with the adapter selection' Actual message: 'This INT8 build was loaded without LoRA adapters, ... Reload the model with the LoRA selection: on the Images page click Reapply ...' FAILED tests/test_diffusion_te_residency.py::test_release_streams_and_restore_unhooks_with_identical_outputs assert 0 == 4 (release('test') == r.mib) FAILED tests/test_diffusion_te_residency.py::test_a_restore_that_runs_out_of_memory_keeps_streaming assert True is False ``` ## Root causes **LoRA reload refusal (#18420).** #18420 turned this refusal into `LoraReloadRequiredError` and rewrote its message to name the remedy (Reapply on the Images page, or `loras` in `/images/load`). The routes key on the type (`X-Unsloth-Refusal: lora-reload`, `error.code = "lora_reload_required"`). The two tests still matched the old wording. The behaviour is intended; the tests pinned prose. **Encoder residency streaming (#18424).** `EncoderResidency.release()` streams the text encoders through diffusers' group offloading. The `(Python 3.13, diffusion)` lane does not install diffusers (the same log shows `No module named 'diffusers'` skips), so the stream fails, `release()` correctly keeps the encoders resident and returns 0, and the two tests that need a real stream fail. The module is right to refuse; the tests needed diffusers and did not say so. ## Changes - `test_diffusion_backend.py`: both tests assert `pytest.raises(LoraReloadRequiredError, match = "Reload the model with the LoRA selection")`, the typed refusal plus the remedy phrase both messages share. - `test_diffusion_te_residency.py`: the two streaming tests are marked to skip when `importlib.util.find_spec("diffusers") is None`. Only the absence of diffusers skips: with diffusers installed, a regression in Unsloth's streaming still fails them. The tests that do not stream (host RAM refusal, a failed stream putting the encoders back) keep running everywhere. Test-only change. ## Testing - With diffusers 0.43.0 (current release) on a CPU host: `pytest tests/test_diffusion_te_residency.py tests/test_diffusion_backend.py`: 733 passed, the two streaming tests included. - Sabotage: raising a plain `LoraSelectionError` instead of `LoraReloadRequiredError` fails both LoRA tests. - The no-diffusers lane is the `(Python 3.13, diffusion)` job on this PR.
|
@codex review |
1 similar comment
|
@codex review |
Codex Review Summary: ✅ CompletedThis 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 Review: Didn't find any major issues. Swish! 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". |
The auto-install script currently prints a
torch270extra for PyTorch 2.7.1. The project defines a separatetorch271extra with a different xFormers version.Move the cutoff from
2.7.9to2.7.1so 2.7.0 keepstorch270and 2.7.1 selectstorch271. The matrix tests cover cu118, cu126, and cu128 and check that the selected extras exist. All 73 installer tests passed locally.