Tighten comments in torch2110 CUDA extras

This commit is contained in:
Daniel Han 2026-07-18 08:17:15 +00:00
commit 1086bab371
3 changed files with 12 additions and 21 deletions

View file

@ -326,28 +326,26 @@ cu130onlytorch291 = [
"xformers @ https://download.pytorch.org/whl/cu130/xformers-0.0.33.post2-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32')",
]
cu126onlytorch2100 = [
# Pin torch so ARM64 installs (x86-64-only xformers wheel and its transitive
# torch pin skipped) stay on 2.10 instead of resolving newer.
# Pin torch so ARM64 (x86-64-only xformers wheel skipped) stays on 2.10.
"torch==2.10.0",
"xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.34-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform) and (platform_machine == 'AMD64' or platform_machine == 'x86_64')",
"xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.34-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')",
]
cu128onlytorch2100 = [
# Same explicit torch pin as cu126onlytorch2100 above.
# Same torch pin as cu126onlytorch2100.
"torch==2.10.0",
"xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.34-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform) and (platform_machine == 'AMD64' or platform_machine == 'x86_64')",
"xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.34-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')",
]
cu130onlytorch2100 = [
# Same explicit torch pin as cu126onlytorch2100 above.
# Same torch pin as cu126onlytorch2100.
"torch==2.10.0",
"xformers @ https://download.pytorch.org/whl/cu130/xformers-0.0.34-cp39-abi3-manylinux_2_28_x86_64.whl ; ('linux' in sys_platform) and (platform_machine == 'AMD64' or platform_machine == 'x86_64')",
"xformers @ https://download.pytorch.org/whl/cu130/xformers-0.0.34-cp39-abi3-win_amd64.whl ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')",
]
cu126onlytorch2110 = [
# xformers 0.0.35 does not pin torch, so pin the trio to the +cu126 local
# build: torch 2.11 defaults to a CUDA-13 PyPI wheel, and only the +cu126 tag
# resolves from the cu126 index alongside the cu126 xformers below.
# xformers 0.0.35 does not pin torch; pin the trio to +cu126 so it resolves
# from the cu126 index (torch 2.11 defaults to a CUDA-13 PyPI wheel).
"torch==2.11.0+cu126",
"torchvision==0.26.0+cu126",
"torchaudio==2.11.0+cu126",
@ -355,8 +353,7 @@ cu126onlytorch2110 = [
"xformers @ https://download.pytorch.org/whl/cu126/xformers-0.0.35-py39-none-win_amd64.whl ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')",
]
cu128onlytorch2110 = [
# Same +cuNNN pin as cu126onlytorch2110: keeps the trio on the cu128 index
# instead of torch 2.11's CUDA-13 PyPI default.
# Same +cuNNN pin as cu126onlytorch2110, on the cu128 index.
"torch==2.11.0+cu128",
"torchvision==0.26.0+cu128",
"torchaudio==2.11.0+cu128",
@ -364,9 +361,8 @@ cu128onlytorch2110 = [
"xformers @ https://download.pytorch.org/whl/cu128/xformers-0.0.35-py39-none-win_amd64.whl ; (sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')",
]
cu130onlytorch2110 = [
# Same +cuNNN pin as the cu126/cu128 extras: a bare range lets a CUDA-12 index
# win (PEP 440 ranks +cu126 above unlabelled 2.11.0) and ===2.11.0 would
# force-replace official cu130-index installs. _auto_install.py adds the index.
# Same +cuNNN pin as cu126/cu128: a bare range lets +cu126 win (PEP 440) and
# ===2.11.0 would force-replace cu130-index installs. _auto_install.py adds the index.
"torch==2.11.0+cu130",
"torchvision==0.26.0+cu130",
"torchaudio==2.11.0+cu130",

View file

@ -44,7 +44,7 @@ def _extra(name: str) -> list[str]:
def _reqs(specs: list[str]) -> dict[str, list[Requirement]]:
# name -> list: each extra has one Linux and one Windows xformers requirement.
# name -> reqs (one Linux + one Windows xformers per extra)
out: dict[str, list[Requirement]] = {}
for spec in specs:
r = Requirement(spec)
@ -54,7 +54,6 @@ def _reqs(specs: list[str]) -> dict[str, list[Requirement]]:
@pytest.mark.parametrize("cuda", ["cu126", "cu128", "cu130"])
def test_cuda12_torch2110_pins_matching_local_build(cuda: str):
# Each trio member must pin the exact +cuXXX local build.
reqs = _reqs(_extra(f"{cuda}onlytorch2110"))
for pkg in _TORCH_TRIO:
(req,) = reqs[pkg]
@ -62,7 +61,6 @@ def test_cuda12_torch2110_pins_matching_local_build(cuda: str):
assert (
spec == f"=={('2.11.0' if pkg != 'torchvision' else '0.26.0')}+{cuda}"
), f"{cuda}onlytorch2110: {pkg} pinned as '{spec}', expected the +{cuda} local build"
# Both xformers wheels (Linux and Windows) must come from the same CUDA index.
xformers = reqs["xformers"]
assert len(xformers) == 2, f"expected Linux + Windows xformers wheels, got {xformers}"
linux = [r for r in xformers if r.url and r.url.endswith("manylinux_2_28_x86_64.whl")]
@ -72,7 +70,7 @@ def test_cuda12_torch2110_pins_matching_local_build(cuda: str):
assert (
f"/whl/{cuda}/xformers-0.0.35-" in r.url
), f"xformers not on the {cuda} index: {r.url}"
# x86-64-only wheels: markers must exclude aarch64 / ARM64.
# markers must exclude aarch64 / ARM64
assert r.marker is not None
assert not r.marker.evaluate({"sys_platform": "linux", "platform_machine": "aarch64"})
assert not r.marker.evaluate({"sys_platform": "win32", "platform_machine": "ARM64"})
@ -83,7 +81,6 @@ def test_cuda12_torch2110_pins_matching_local_build(cuda: str):
@pytest.mark.parametrize("cuda", ["cu126", "cu128", "cu130"])
@pytest.mark.parametrize("variant", ["", "ampere-"])
def test_torch2110_wrapper_references_matching_leaf(cuda: str, variant: str):
# Wrappers pull huggingface + bitsandbytes and the leaf of the same CUDA version.
specs = _extra(f"{cuda}-{variant}torch2110")
assert specs == [
"unsloth[huggingface]",
@ -94,8 +91,7 @@ def test_torch2110_wrapper_references_matching_leaf(cuda: str, variant: str):
@pytest.mark.parametrize("cuda", ["cu126", "cu128", "cu130"])
def test_cuda12_torch2100_keeps_torch_pinned_off_x86(cuda: str):
# Now the xformers wheels carry x86-64 markers, the leaf must pin torch
# explicitly so ARM64 installs stay on 2.10 instead of resolving newer.
# xformers wheels now carry x86-64 markers, so the leaf must pin torch for ARM64.
reqs = _reqs(_extra(f"{cuda}onlytorch2100"))
(torch_req,) = reqs["torch"]
assert str(torch_req.specifier) == "==2.10.0", (

View file

@ -42,7 +42,6 @@ else: raise RuntimeError(f"Torch = {v} too new!")
if v > V('2.6.9') and cuda not in ("11.8", "12.6", "12.8", "13.0"): raise RuntimeError(f"CUDA = {cuda} not supported!")
if v >= V('2.10.0') and cuda not in ("12.6", "12.8", "13.0"): raise RuntimeError(f"Torch = {v} requires CUDA 12.6, 12.8, or 13.0! Got CUDA = {cuda}")
x = x.format(cuda.replace(".", ""), "-ampere" if False else "") # is_ampere is broken due to flash-attn
# The torch2110 extras pin the trio to +cuNNN local builds, which only resolve
# from the matching PyTorch CUDA index, so add that index for torch 2.11.
# torch2110 extras pin +cuNNN local builds that only resolve from the matching index.
extra_index = f' --extra-index-url https://download.pytorch.org/whl/cu{cuda.replace(".", "")}' if (x.endswith('-torch2110') and cuda in ("12.6", "12.8", "13.0")) else ''
print(f'pip install --upgrade pip setuptools wheel && pip install --no-deps git+https://github.com/unslothai/unsloth-zoo.git && pip install "unsloth[{x}] @ git+https://github.com/unslothai/unsloth.git" --no-build-isolation{extra_index}')