Repository navigation
Raise the released torch ceiling to <2.15.0 #12152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
390abda
Raise the released torch ceiling to <2.15.0
danielhanchen 6c40e2d
Test that the released torch range admits Studio's torch and every pi…
danielhanchen a332f28
Read pyproject.toml as utf-8 in the torch ceiling test
danielhanchen 597949e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3823a7a
Fall back to tomli below Python 3.11 in the torch ceiling test
danielhanchen 1e4192f
Merge pip into r12152
danielhanchen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # SPDX-License-Identifier: AGPL-3.0-only | ||
| # Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. | ||
|
|
||
| """The released torch range must admit what Studio installs and every torch an extra pins. | ||
|
|
||
| `unsloth studio update` re-resolves unsloth under this range: an installed torch outside it | ||
| is swapped for PyPI's default on the next update. Studio installs torch 2.13 on the Linux | ||
| cu130 Python 3.13 route once this range admits it. | ||
| """ | ||
|
|
||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
| from packaging.requirements import Requirement | ||
| from packaging.version import Version | ||
|
|
||
| tomllib = pytest.importorskip("tomllib" if sys.version_info >= (3, 11) else "tomli") | ||
|
|
||
| _PYPROJECT = tomllib.loads( | ||
| (Path(__file__).resolve().parents[1] / "pyproject.toml").read_text(encoding = "utf-8") | ||
| ) | ||
|
|
||
|
|
||
| def _base_torch() -> Requirement: | ||
| reqs = [Requirement(r) for r in _PYPROJECT["project"]["dependencies"]] | ||
| torch = [r for r in reqs if r.name == "torch"] | ||
| assert len(torch) == 1, torch | ||
| return torch[0] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("release", ["2.4.0", "2.11.0", "2.12.1", "2.13.0", "2.14.0"]) | ||
| def test_the_released_range_admits_every_supported_torch(release): | ||
| assert Version(release) in _base_torch().specifier | ||
|
|
||
|
|
||
| def test_the_released_range_stops_before_an_unvalidated_minor(): | ||
| assert Version("2.15.0") not in _base_torch().specifier | ||
|
|
||
|
|
||
| def test_every_torch_an_extra_pins_is_inside_the_released_range(): | ||
| spec = _base_torch().specifier | ||
| pinned = set() | ||
| for extra in _PYPROJECT["project"].get("optional-dependencies", {}).values(): | ||
| for raw in extra: | ||
| req = Requirement(raw) | ||
| if req.name != "torch" or req.url: | ||
| continue | ||
| for s in req.specifier: | ||
| if s.operator == "==": | ||
| pinned.add(Version(s.version.split("+", 1)[0])) | ||
| outside = sorted(str(v) for v in pinned if v not in spec) | ||
| assert not outside, f"extras pin torch outside the released range: {outside}" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new module is not executed by the current CI configuration:
pyproject.toml:1203restricts default discovery totests/security, while the root-test commands in.github/workflows/consolidated-tests-ci.ymlexplicitly enumerate other modules and never name this file. Consequently, a later change can violate the torch ceiling or extra-pin invariants while CI remains green; add this module to an appropriate explicit pytest invocation.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module already runs in CI: studio-backend-ci.yml's Repo tests (CPU, rest) shard walks tests/ minus the named subtrees, and collecting that selection picks up all 7 tests here (it is also the job that flagged this file's encoding earlier).