Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Studio Windows repair hint: never recommend the managed xFormers on i…
…ts own

The managed xFormers 0.0.35 cu130 wheel builds no FlashAttention 2 of its own and its cutlass kernels stop at sm_90, so on an RTX 50-series card it is not an upgrade over an installed 0.0.34. The hint now keys on torch alone: no xformers_older_than_managed reason, no xFormers versions in the payload or the wording.

[skip ci]
  • Loading branch information
danielhanchen committed Nov 27, 2026
commit 1aceba77743426e587fcf15bb336deddfb6be54a
4 changes: 2 additions & 2 deletions studio/backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3142,7 +3142,7 @@ def _checkpoint_quant_formats() -> list[str]:


def _repair_recommendation() -> Optional[dict]:
"""Torch-free; None off Windows, off CUDA, or when the install already has the managed pair."""
"""Torch-free; None off Windows, off CUDA, or when the install already has the managed torch."""
try:
from utils.hardware.windows_repair import windows_repair_recommendation
return windows_repair_recommendation()
Expand Down Expand Up @@ -3315,7 +3315,7 @@ def get_system_info(
"nvfp4_diffusion": _nvfp4_diffusion_enabled(),
# Prequantized FP8 / NVFP4 LLM checkpoints this host runs natively. Additive key.
"checkpoint_quant_formats": _checkpoint_quant_formats(),
# Windows: an existing home older than the managed torch / xFormers pair. Additive key, null otherwise.
# Windows: an existing home older than the managed torch. Additive key, null otherwise.
"repair_recommendation": _repair_recommendation(),
}

Expand Down
12 changes: 9 additions & 3 deletions studio/backend/tests/test_windows_repair_recommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,17 @@ def test_an_old_torch_on_rtx50_recommends_repair():
rec = _rec()
assert rec["reason"] == "torch_older_than_managed"
assert rec["torch"] == "2.10.0+cu128"
assert (rec["managed_torch"], rec["managed_xformers"]) == ("2.13", "0.0.35")
assert rec["managed_torch"] == "2.13"
# The managed 0.0.35 xFormers is never offered: on sm_120 it has no FlashAttention 2 of its own.
assert not any("xformers" in key for key in rec)
assert "0.0.35" not in repr(rec)


def test_an_old_xformers_on_the_managed_torch_recommends_repair():
assert _rec(torch = "2.13.0+cu130", xformers = "0.0.33")["reason"] == "xformers_older_than_managed"
@pytest.mark.parametrize("xformers", ["0.0.34", "0.0.33.post2", None])
def test_an_xformers_older_than_the_managed_pin_is_never_a_reason(xformers):
# RTX 5090 with the managed torch and xFormers 0.0.34 (FA2 through flash_attn): working, and 0.0.35 from the
# cu130 index would not be an upgrade there, so nothing is recommended.
assert _rec(torch = "2.13.0+cu130", xformers = xformers) is None


@pytest.mark.parametrize(
Expand Down
23 changes: 7 additions & 16 deletions studio/backend/utils/hardware/windows_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"""Windows: whether an existing install should be repaired onto the managed PyTorch.

An existing home keeps the torch it was installed with; only a repair (UNSLOTH_TORCH_UPGRADE=1) moves it to
the managed build. On RTX 50-series (sm_120) cards xFormers trains only with torch 2.13 and xFormers 0.0.35,
so an older home there runs attention on SDPA instead, or fails in the backward of an old xFormers build.
the managed build (torch 2.13 on the cu130 route), which is what RTX 50-series (sm_120) support is tested on.
Torch only: the xFormers version is never a reason. The managed 0.0.35 cu130 wheel builds no FlashAttention 2
of its own and its cutlass kernels stop at sm_90, so on sm_120 it is not an upgrade over an installed 0.0.34.
Torch-free: package metadata and the cached nvidia-smi capability query, so the polled /api/system may call it."""

from __future__ import annotations
Expand All @@ -19,8 +20,6 @@

# Lower bound of install.ps1's managed CUDA torch for new installs ($script:Cu130NewInstallTorchSpec).
WINDOWS_MANAGED_TORCH_FLOOR = (2, 13)
# The first xFormers whose sm_120 build ships the backward kernels, paired with that torch.
WINDOWS_MANAGED_XFORMERS_FLOOR = (0, 0, 35)
_SM120 = 12
# The managed torch comes from the cu130 index, which install.ps1 picks only for a driver supporting CUDA 13.0.
_MANAGED_ROUTE_DRIVER_CUDA = (13, 0)
Expand Down Expand Up @@ -109,9 +108,8 @@ def windows_repair_recommendation(
managed_route_host: Callable[[], bool] = _managed_route_host,
driver_cuda_version: Callable[[], Optional[tuple[int, int]]] = _driver_cuda_version,
) -> Optional[dict]:
"""``{"reason", "torch", "xformers", "managed_torch", "managed_xformers"}`` when this Windows CUDA install
has an sm_120+ card and a torch (or an installed xFormers) older than the managed pair, and Repair can
reach that pair; else None. A driver too old for the cu130 route gets ``driver_older_than_managed``
"""``{"reason", "torch", "managed_torch"}`` when this Windows CUDA install has an sm_120+ card and a torch
older than the managed one, and Repair can reach it; else None. xFormers is never a reason (see above). A driver too old for the cu130 route gets ``driver_older_than_managed``
instead, since Repair alone would keep the old torch."""
if platform != "win32":
return None
Expand All @@ -122,14 +120,9 @@ def windows_repair_recommendation(
if not any(int(cap[0]) >= _SM120 for cap in capabilities().values()):
return None
torch_release = _release(torch_version)
xformers_version = dist_version("xformers")
xformers_release = _release(xformers_version)
if torch_release is not None and torch_release[:2] < WINDOWS_MANAGED_TORCH_FLOOR:
reason = "torch_older_than_managed"
elif xformers_release is not None and xformers_release < WINDOWS_MANAGED_XFORMERS_FLOOR:
reason = "xformers_older_than_managed"
else:
if torch_release is None or torch_release[:2] >= WINDOWS_MANAGED_TORCH_FLOOR:
return None
reason = "torch_older_than_managed"
# Only x64 with the Python 3.13 venv takes the managed torch; elsewhere Repair would not change it.
if not managed_route_host():
return None
Expand All @@ -139,7 +132,5 @@ def windows_repair_recommendation(
return {
"reason": reason,
"torch": torch_version,
"xformers": xformers_version,
"managed_torch": ".".join(map(str, WINDOWS_MANAGED_TORCH_FLOOR)),
"managed_xformers": ".".join(map(str, WINDOWS_MANAGED_XFORMERS_FLOOR)),
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0

/** `/api/system` `repair_recommendation`: an existing Windows home older than the managed torch / xFormers. */
/** `/api/system` `repair_recommendation`: an existing Windows home older than the managed torch. */
export interface RepairRecommendation {
reason:
| "torch_older_than_managed"
| "xformers_older_than_managed"
| "driver_older_than_managed"
| string;
torch?: string | null;
xformers?: string | null;
managed_torch?: string | null;
managed_xformers?: string | null;
}

type Translate = (key: never, values?: Record<string, string>) => string;
Expand All @@ -24,16 +21,11 @@ export function repairRecommendationText(
if (!rec) return null;
const values = {
torch: rec.torch ?? "",
xformers: rec.xformers ?? "",
managedTorch: rec.managed_torch ?? "",
managedXformers: rec.managed_xformers ?? "",
};
if (rec.reason === "torch_older_than_managed") {
return t("settings.general.repairInstall.recommendedTorch" as never, values);
}
if (rec.reason === "xformers_older_than_managed") {
return t("settings.general.repairInstall.recommendedXformers" as never, values);
}
if (rec.reason === "driver_older_than_managed") {
return t("settings.general.repairInstall.recommendedDriver" as never, values);
}
Expand Down
2 changes: 1 addition & 1 deletion studio/frontend/src/hooks/use-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export interface SystemInfoResponse {
nvfp4_diffusion?: boolean;
/** Prequantized LLM checkpoint formats ("fp8", "nvfp4") every card runs natively. Absent on older backends. */
checkpoint_quant_formats?: string[];
/** Windows: an existing home older than the managed torch / xFormers. Null or absent otherwise. */
/** Windows: an existing home older than the managed torch. Null or absent otherwise. */
repair_recommendation?: RepairRecommendation | null;
/** Whether group offload can stream torchao weights. Absent on older backends. */
quantised_streaming?: boolean;
Expand Down
6 changes: 2 additions & 4 deletions studio/frontend/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2455,11 +2455,9 @@ export const en = {
"Stops the server and reruns the installer. This is a Chat only install, so the installer also upgrades it to the full install with PyTorch, several gigabytes in total. Chats and settings are kept. This can take several minutes.",
confirmAction: "Repair now",
recommendedTorch:
"Repair recommended: this install has PyTorch {torch}, older than the managed {managedTorch}. Training attention on RTX 50-series GPUs needs PyTorch {managedTorch} with xFormers {managedXformers}.",
"Repair recommended: this install has PyTorch {torch}, older than the managed {managedTorch} that RTX 50-series GPUs are supported on.",
recommendedDriver:
"PyTorch {torch} is older than the managed {managedTorch}, which training attention on RTX 50-series GPUs needs, but this GPU driver does not support CUDA 13. Update the GPU driver first, then repair the installation.",
recommendedXformers:
"Repair recommended: this install has xFormers {xformers}, older than the managed {managedXformers}, whose RTX 50-series build has the kernels training needs.",
"PyTorch {torch} is older than the managed {managedTorch} that RTX 50-series GPUs are supported on, but this GPU driver does not support CUDA 13. Update the GPU driver first, then repair the installation.",
},
resetPreferences: {
sectionTitle: "Danger zone",
Expand Down
28 changes: 13 additions & 15 deletions studio/frontend/tests/repair-recommendation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,27 @@ const t = (key: never, values: Record<string, string> = {}) => {
return strings[leaf].replace(/\{(\w+)\}/g, (_m, name: string) => values[name] ?? `{${name}}`);
};

test("an old torch names both versions and the managed pair", () => {
test("an old torch names both torch versions and no xFormers upgrade", () => {
const text = repairRecommendationText(
{
reason: "torch_older_than_managed",
torch: "2.10.0+cu128",
xformers: "0.0.33",
managed_torch: "2.13",
managed_xformers: "0.0.35",
},
{ reason: "torch_older_than_managed", torch: "2.10.0+cu130", managed_torch: "2.13" },
t,
);
assert.ok(text?.startsWith("Repair recommended:"), text ?? "null");
assert.match(text, /PyTorch 2\.10\.0\+cu128/);
assert.match(text, /xFormers 0\.0\.35/);
assert.match(text, /PyTorch 2\.10\.0\+cu130, older than the managed 2\.13/);
// On sm_120 the managed xFormers 0.0.35 is not an upgrade over 0.0.34, so no wording offers it.
assert.doesNotMatch(text, /xFormers|0\.0\.35/);
assert.doesNotMatch(text, /\{/);
});

test("an old xFormers on a current torch gets its own wording", () => {
const text = repairRecommendationText(
{ reason: "xformers_older_than_managed", torch: "2.13.0+cu130", xformers: "0.0.33", managed_xformers: "0.0.35" },
t,
test("the old xFormers reason no longer renders, and no string names an xFormers version", () => {
assert.equal(
repairRecommendationText({ reason: "xformers_older_than_managed", torch: "2.13.0+cu130" }, t),
null,
);
assert.match(text ?? "", /xFormers 0\.0\.33, older than the managed 0\.0\.35/);
for (const key of ["recommendedTorch", "recommendedDriver"]) {
assert.doesNotMatch(strings[key], /xFormers/);
}
assert.equal(strings.recommendedXformers, undefined);
});

test("a driver too old for the managed route asks for a driver update first", () => {
Expand Down