Skip to content

Say when xFormers is installed but its kernels cannot load - #8157

Merged
danielhanchen merged 37 commits into
mainfrom
nv/p0-xformers
Aug 9, 2026
Merged

danielhanchen merged 37 commits into
mainfrom
nv/p0-xformers

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

Summary

When xFormers is installed but its compiled extensions cannot load, nothing tells the user. The package imports, reports a version, and silently has no memory-efficient attention. This is the detection and reporting half of the fix-before-launch report; the wheel selection itself is a separate change.

Three things kept the failure quiet:

  • unsloth/models/_utils.py:2186-2266 has a real check that calls _register_extensions() and falls back to xformers = None, but its torch to xFormers table stops at torch 2.4, so nothing covers 2.10 or 2.11 against 0.0.33 or 0.0.34.
  • That failure printed only under UNSLOTH_ENABLE_LOGGING.
  • _utils.py:2179-2183 silenced the xFormers CUDA-mismatch warning immediately before the import, which is precisely the diagnostic for this bug.
  • unsloth/utils/attention_dispatch.py:57-62 gated the only code that actually runs the kernel to sm_120 and above, with the comment "Below sm_120 xformers always works; skip the probe". A cu128-built xFormers on a cu130 torch on sm_90 was never probed.

What changed

  • New unsloth/xformers_compat.py: stdlib-only, no torch or xformers import. Carries the declared Requires-Dist: torch==X per release plus XFORMERS_BUILT_FOR_TORCH, and reads the installed wheel's own xformers/cpp_lib.json, which records the torch version, CUDA version and Python it was built with.
  • unsloth/models/_utils.py: resolves the mismatch from the wheel before importing xFormers, so it can leave xFormers' own warning un-silenced in exactly the case where that warning is the bug report. Prints one actionable message on the default path. Populates XFORMERS_BUILD_METADATA and XFORMERS_BROKEN_REASON.
  • unsloth/utils/attention_dispatch.py: the probe now runs on every capability and with flash-attn present, targets LOCAL_RANK's device, caches the reason, and announces it.
  • New studio/backend/utils/hardware/accelerator_probe.py plus hardware.py: per-package installed, imports, runs and built-for, behind a new include_accelerators flag.
  • Frontend: accelerator status in Settings and the About tab, all 12 locales.

Verification

I range-read the published PyPI wheels' zip central directories. xFormers 0.0.34 and 0.0.35 win_amd64 both record torch 2.10.0+cu128 / Python 3.10.11, which is the exact string in the report. Diffing the pin table against the PyPI JSON API showed it was correct but missing 0.0.28, 0.0.28.post3, 0.0.29 and 0.0.29.post2; 0.0.35 declares torch>=2.10 while shipping a single _C.pyd built against 2.10.0. No xFormers release exists for torch 2.11 or later.

Running the new report on this host caught a live instance of the bug class unprompted: torchao 0.18.0+cu130 against torch 2.9.1+cu128 does not import.

  • tests/utils/test_xformers_capability_gate.py: 22 passed
  • studio/backend/tests -k "hardware or system": 238 passed, 1 skipped
  • test_xformers_compat and test_xformers_broken_warning: 55 passed
  • whole tests/utils: 336 passed, 2 skipped
  • no-torch sandbox: 6 passed
  • studio source-shape and text-io-encoding: 889 passed, 1 skipped
  • typecheck, build and strict i18n parity: clean
  • 21-step Llama-3.2-1B QLoRA run against this worktree: loss 1.47, coherent generation, exit 0

Judgement call worth flagging

The report asks to block release when optimized kernels cannot load. This implements the detection and makes it loud, but Studio still starts. Degraded attention is a slower app; refusing to boot is a dead one, on precisely the installs this is meant to describe. The banner, the About table and the import-time warning make it hard to miss, and nothing gates startup.

Bugs found in review and fixed

  • The in-process probe left 40 stale torchao.* submodules in sys.modules, the hazard purge_partial_import already documents, and import bitsandbytes latched a CUDA context in the web-server process, which would have cost several hundred MB off every later VRAM reading. Both fixed by moving the probe to a throwaway child.
  • _describe_xformers_break asserted a mismatch whenever build metadata merely existed, without comparing, so [WinError 126] with a matching wheel, the most common Windows failure that is not a mismatch, was misdiagnosed and the real error discarded.
  • The Mac and CPU gate let ROCm and Intel XPU through, moving a false banner to AMD and Intel users.
  • Any probe exception became process-wide HAS_XFORMERS = False with no output, so a full GPU or an EXCLUSIVE_PROCESS device would have caused a silent 2x memory regression created by the diagnostic itself. Those are now inconclusive rather than negative.
  • Tests that were green for the wrong reason were rewritten, and there is now a test that a healthy install prints nothing.

Known gaps

  • The Settings UI is typechecked, unit-tested and builds, but was not visually verified.
  • unsloth/models/llama.py:130 keeps its own HAS_XFORMERS = xformers is not None, bypassing the probe gate. Pre-existing and harmless here, left alone rather than risk that legacy path.
  • A CUDA-built xFormers on a ROCm torch reports nothing, since there is no running CUDA major to compare. A false negative, never a false positive.
  • First Settings open costs about 3.5s for the probe subprocess, once per backend process.

Daniel Han and others added 11 commits August 8, 2026 08:48
xformers wheels are compiled against one torch release and one CUDA major, but
nothing at install time enforces it: the wheels are abi3/none-tagged and
--no-deps skips Requires-Dist entirely, so a cu128 wheel drops cleanly next to a
cu130 runtime and only fails inside torch.ops.load_library, which xformers
catches and downgrades to a logger warning.

_utils.py made that worse in two ways: it silenced the xformers logger to ERROR
immediately before the import, and it reported the resulting failure only under
UNSLOTH_ENABLE_LOGGING. The net effect was a silent fall back to SDPA attention.
Its torch<->xformers version table also stopped at torch 2.4.

New unsloth/xformers_compat.py (stdlib only, imports neither torch nor xformers)
carries the version knowledge up to torch 2.10 / xformers 0.0.35 and reads the
installed wheel's own xformers/cpp_lib.json to learn what it was really built
against. The tables and the cpp_lib.json shape were read off the published
wheels, not inferred.

0.0.35 is the case worth calling out: it is the first release to declare a range
(torch>=2.10) while its _C is still a single build against 2.10.0, so pip will
pair it with torch 2.11+ and the extension will not load. No xformers release is
built for torch 2.11 or later, so xformers_for_torch returns None there rather
than recommending the install that produces the bug.

Because the check runs off the file before the import, the mismatch is known in
time to leave xformers' own diagnostic un-silenced in exactly the case where it
is the bug report, and to print a single actionable message naming the torch,
CUDA and Python the wheel was built for versus what is running. A Python version
difference alone is never reported as a break: _C loads through
torch.ops.load_library, not the CPython ABI.

XFORMERS_BUILD_METADATA and XFORMERS_BROKEN_REASON are exported so callers can
report what broke instead of guessing.
_xformers_disabled_for_capability returned early below sm_120 with the comment
"Below sm_120 xformers always works; skip the probe". That holds only when the
wheel matches the runtime. A cu128-built xformers on a cu130 torch is dead on an
sm_90 Hopper exactly as it is on an sm_120, and the early return meant the one
piece of code that actually runs the kernel never looked. The gate also skipped
the probe whenever flash-attn was installed, so those machines could never report
a dead xformers at all.

Now the real op decides on every capability, including with flash-attn present.
The extra cost is one 1x8x1x64 forward on a CUDA context torch has already
initialised, since _XFORMERS_FP32_UNSUPPORTED just below forces the same lazy
init unconditionally.

The probe also caches why it failed in XFORMERS_PROBE_REASON, surfaced as
XFORMERS_DISABLED_REASON alongside XFORMERS_BROKEN_REASON from _utils, so a
caller can report what is wrong rather than only that xformers is off. It still
never raises: it runs at import, so a diagnostic must not be what breaks the
import.

The #4631 regressions are kept and extended: a working kernel is still kept on
sm_120, and now the probe-means-disable failure mode is pinned on every other
capability too.
get_package_versions() covered unsloth, torch, transformers and torch's CUDA/HIP
version, and nothing else. An xformers built for a different torch reports its
version happily and has no memory-efficient attention, so the report a user sends
with a bug looked identical whether the acceleration stack worked or not. There
was no Python version either, which is half of what a mismatch report needs.

get_package_versions() now also carries python, xformers, flash_attn, torchao and
bitsandbytes as plain version strings. Still flat str-or-None, so every existing
consumer is untouched.

The part that costs a real import lives in the new get_accelerator_report(),
returned under /api/system/hardware?include_details=true only -- the default
response is polled for training-method selection and must stay cheap. Per package
it separates installed / imports / runs, and for xformers reads the wheel's own
cpp_lib.json to say what it was compiled against, which is the part that names
the fix. The cpp_lib.json read is a deliberate copy of the one in
unsloth.xformers_compat rather than a call to it: this module has to keep working
with no torch installed, and importing unsloth would execute unsloth/__init__.py.

Cached per process, deep-copied out, never raises, and skippable with
UNSLOTH_SKIP_ACCELERATOR_PROBE=1 for an install where importing a broken native
wheel is worse than not knowing.

Deliberately does not gate startup. NVIDIA asked to block release when optimized
kernels cannot load; blocking the app instead would turn a slower-but-working
install into a dead one. Detection and loud reporting, not refusal to run.

Ran it here and it immediately found a real one: torchao 0.18.0+cu130 against
torch 2.9.1+cu128 does not import.
The About tab showed a version string per runtime and nothing else, which a
mismatched xformers reports exactly as happily as a working one, and no Python
version at all -- the other half of every "built for 3.10, running 3.13" report.

About gains a Python row and an Optimized kernels section listing xFormers,
FlashAttention, torchao and bitsandbytes, each as installed / not installed /
working / not loading rather than as a version. A broken one shows what its wheel
was built for, with the full reason behind the row's info hint.

The banner sits in the Settings dialog rather than on the About tab, above
whichever tab is showing: a kernel that is installed and cannot load produces no
symptom other than being slower, so a user has no reason to go looking in About.
It mounts inside DialogContent, which Radix only renders while the dialog is
open, so the detail fetch and the native imports behind it stay off app startup.

Status is never colour-only -- each state carries its own word -- so it survives
a greyscale screenshot in a bug report, which is where this will mostly be read.

Parsing moved to hooks/accelerator-report.ts so it is importable without react or
the auth chain, which is what makes it unit testable. A backend that predates the
field parses to null, not to an empty healthy report: "cannot tell" must not
render as "all fine".

Also drops the misleading half of the CLI fix hint. On a torch newer than any
xformers release there is no version to pin, and naming one would send the user
back into the same mismatch, so it now says so and points at a source build.
The suite is routinely run as `pytest studio/backend/tests -k "hardware or
system"`, and only 1 of the 15 matched under the old filename. It is the
hardware module's report, so name it that way.
bitsandbytes is a dependency on every platform but only loads on CUDA/XPU, so on
a Mac or a CPU-only host its import failure is the expected outcome, not a broken
acceleration stack. Probing there pinned a permanent false banner to those
installs, which is exactly the credibility problem that makes people stop reading
banners.

The probe now runs only when get_device() is CUDA or XPU, and "we did not look"
stays distinguishable from "you told us not to look": "not used on this device"
versus "not probed".

The probe tests pinned get_device to CUDA as well. Without that they passed on a
CPU-only runner by never probing at all -- green for the wrong reason.
It sat inside the Hardware section, which only renders when there is a GPU or an
accelerator runtime to show. On a CPU-only host that hid the one field a bug
report most needs.
…reason

Review of the first pass turned up four things that were worse than the problem
being reported, three of them measured on this host.

Importing the packages in the web-server process was wrong three ways. A package
whose __init__ raises leaves every submodule it already executed in sys.modules,
so the next import returns a half-built module -- this repo already documents
that hazard and ships purge_partial_import for it (#7580);
torchao left 40 stale submodules behind here. `import bitsandbytes` latches a
CUDA context, and the backend deliberately never had one: main.py pins
CUDA_DEVICE_ORDER before any torch import and the export planner budgets from
free VRAM read before a context exists, so a diagnostic was about to take several
hundred MB off every later VRAM reading for the rest of the session. And a badly
broken native wheel can abort the interpreter rather than raise, which in the
server means the app dies on exactly the installs this is meant to describe.

It now runs in one throwaway child with CUDA_VISIBLE_DEVICES emptied. Measured
after the change: no CUDA context, no leaked modules, 3.5s once per process.

_describe_xformers_break asserted a version mismatch whenever build metadata
merely existed, without ever comparing it to the runtime, and dropped the real
exception on the floor. [WinError 126] with a perfectly matching wheel -- a
missing VC++ runtime or CUDA DLL, the most common Windows xformers failure that
is NOT a mismatch -- was reported as "built for X but runs X". It now compares
first and hands back the real error otherwise.

The Mac/CPU gate let ROCm and Intel XPU through: ROCm hosts report
DeviceType.CUDA internally, and the stock bitsandbytes is CUDA-only on both. Same
permanent false banner, just moved to AMD and Intel users.

The report also moves off include_details onto its own include_accelerators flag.
The detail path is read by Export, Video and onboarding, none of which should pay
for this, so the frontend gets a separate hook used only by the Settings surfaces.

Also: read xformers' already-recorded _cpp_library_load_exception instead of
re-calling the private _register_extensions (whose absence was being reported as
"broken"), cap reason strings that land in an aria-label, name the subprocess
encoding so Windows paths survive, and carry hip through to the UI so a ROCm
wheel shows a build at all.

Tests: the probe seam is faked everywhere, so none of them import the host's
native wheels; added the matching-build, python-only, cuda-minor, ROCm, XPU and
could-not-be-checked cases that let those defects through.
…aught

Review of the first pass found the new probe reintroducing the failure mode it
was written to remove, plus two ways of stating the wrong cause.

The gate turned any probe exception into HAS_XFORMERS = False for the whole
process, and printed nothing. Before, capability[0] < 12 returned early, so
sm_70-sm_100 could not lose xformers this way at all. A full device 0, a device
claimed by another rank under EXCLUSIVE_PROCESS, a MIG slice: each of those now
cost memory-efficient attention for the session, silently, because of the
diagnostic. Those failures are now inconclusive -- xformers stays on and the real
forward decides -- and a conclusive one is announced through the same path as an
ABI mismatch, so XFORMERS_DISABLED_REASON is no longer written and never read.

The probe also targeted device 0 for everybody. Under torchrun each rank owns a
different GPU, and on a mixed box device 0 is often the small display card, so a
wheel with no kernel for the weakest GPU disabled xformers on the good ones. It
now probes LOCAL_RANK's device.

The loud warning was reflowing every exception into "its optimized kernels cannot
load ... install the matching build". That arm also catches the sm_100/110/120
FA3 guard and the three old-torch guards, whose messages are multi-line, fenced
and already actionable; the template stated the wrong cause and mangled the text.
Only a real build mismatch gets the version-pin treatment now.

xformers_compat: a .dev/rc build no longer folds onto its release. The fourteen
0.0.35.devNNNN wheels on PyPI are built against torch nightlies, so answering
"0.0.35, therefore torch 2.10.0" for one was confidently wrong; unknown is the
honest answer. And declared_torch_pin's docstring claimed it returns None for a
range pin when it falls back to the build table -- the code is right, the
docstring was not.

Tests: test_warning_is_printed_once was vacuous (a fresh subprocess reaches the
announcement once whether or not the guard exists), so it now counts in-process;
_mismatched_build synthesizes a CUDA-major difference and is skipped where there
is no running CUDA major; the probe tests patch the globals they write through
instead of leaking them into the session; and there is now a test that a healthy
install prints nothing at all, which is the half of "never cry wolf" nothing
covered.
Both subprocess tests in tests/utils/test_xformers_broken_warning.py failed on
the cross-platform runners for two independent reasons, neither of them the
warning they are meant to prove.

First, the child ran a bare `python -c`. Everything else under tests/ gets
tests/conftest.py, the GPU-free harness that forces DEVICE_TYPE to "cuda" and
stubs the torch.cuda probes unsloth fires at import time; the child got none of
it, so unsloth/_gpu_init.py's module-scope torch.cuda.get_device_capability()
raised "Found no NVIDIA driver" and the import exited 1. That is also why the
in-process `import unsloth` in test_xformers_capability_gate.py was green on the
same runner. The child now loads that same harness by path before importing
unsloth, so the subprocess and the parent agree about the host. On a real
accelerator the harness is a no-op.

Second, the stub xformers was an importable module with no .dist-info, and
`import unsloth` asks importlib.metadata for the xformers version twice. With no
xformers on the host that raised PackageNotFoundError straight out of
fix_xformers_performance_issue(); with one, it silently answered from the HOST's
xformers, which is exactly what this file's docstring promises not to depend on.
The stub now ships its own metadata and the child asserts the version it reads
back is the stub's.

test_a_healthy_install_says_nothing additionally needs a healthy install to
exist, so it now skips when importlib.util.find_spec("xformers") is None instead
of reaching its "this host's xformers is genuinely broken" skip, which would
have been the wrong reason for a host that simply has no xformers.

Tests only - no change to the detection in unsloth/models/_utils.py,
unsloth/xformers_compat.py or unsloth/utils/attention_dispatch.py.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Widening the probe from sm_120-only to every capability put it on the standard
multi-GPU path for the first time, and it does not survive there. Both of
these reproduce on a real two-GPU torchrun; neither happens on main.

The probe placed q on cuda:{LOCAL_RANK} but built the attn_bias with
BlockDiagonalCausalMask.from_seqlens, which allocates on the CURRENT device --
still cuda:0 on every rank at import time, because launchers set LOCAL_RANK in
the environment while torch.cuda.set_device happens later inside the trainer.
So the two tensors disagreed, xformers rejected the pair with "Attention bias
and Query/Key/Value should be on the same device", and since that text is not
an inconclusive marker the gate hard-disabled xformers. Measured on two
healthy identical B200s: rank 0 kept xformers, rank 1 lost it. On an 8-GPU
node that is 7 ranks silently dropping to SDPA at double the attention memory
-- the exact regression the inconclusive guard was written to prevent, caused
by the diagnostic itself, and reported to the user as a broken install. It
also allocated on cuda:0 from every rank, pinning a second context per rank,
about 700 MB each. Running the whole probe under torch.cuda.device fixes both.

Separately, LOCAL_RANK is a rank and not an index into the devices a process
can see. Slurm with --gpus-per-task=1, and anything that narrows
CUDA_VISIBLE_DEVICES per rank, gives a rank one visible device while still
exporting its global rank; accelerate and transformers both use -1 to mean
"not distributed". torch.cuda.get_device_capability raises on an invalid
ordinal and that call is at module scope, so `import unsloth` died outright
with AssertionError: Invalid device id. Verified for LOCAL_RANK of 3, 1, 07
and -1 against one visible device; all four now import and fall back to
device 0, which is the only device such a rank has.

Clamping is the fix rather than a try/except around the capability read: with
an out-of-range index the probe fails with "invalid device ordinal", which is
not an inconclusive marker either, so catching the crash alone would have
converted it into the silent disable above. Those two strings are added to the
inconclusive list regardless, so that path can never again be read as evidence
about the build.

Two more things this turned up. The probe's reason is a captured exception,
and xformers answers a capability rejection with a dozen lines listing every
operator it considered -- announced verbatim, that is what every RTX 50-series
user would see on every import. Print the first line and put the rest behind
UNSLOTH_ENABLE_LOGGING, truncating at the call site because the announcer's
other callers pass deliberately fenced, copy-pasteable text that has to arrive
intact. And re-silence the xformers logger once the extensions turn out to
have loaded: skipping the silencing on a PREDICTED break is right, but the
prediction is read off cpp_lib.json and is wrong in the healthy direction
whenever a wheel records a torch patch it still loads against, and leaving the
logger open is permanent and process-wide.

_XFORMERS_FP32_UNSUPPORTED now reads the same device the probe used, which is
what its comment already claimed.

Tests: the rank-targeting test stubs torch.cuda.device so it runs on a host
with any GPU count and asserts the context index, not just the tensor's; new
tests cover the clamp invariant and a real subprocess import under five
hostile LOCAL_RANK values, which is the regression the mocked test could not
catch.
@danielhanchen

Copy link
Copy Markdown
Member Author

Related: #4381 reports exactly this failure mode independently (RTX 3090, torch 2.10.0+cu130, xformers 0.0.35, Xformers = None). That issue is what this PR's detection is meant to make self-diagnosing, so it is worth verifying against once this lands.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen and others added 3 commits August 8, 2026 12:50
The probe decodes its child as UTF-8, but the child's own stdout defaults to
locale.getpreferredencoding(), which on Windows is the ANSI code page. That is exactly
where this probe's value is: native import errors quote DLL and file paths, and a
non-ASCII path would come back mangled. Route the env through utf8_child_env, as the
repo's own contract test requires.
- the xFormers probe picked bf16 from device 0 while probing this rank's GPU,
  so a mixed box with a Turing card wrote off a healthy install.
- the fix hint pinned a version but no index; all three CUDA families publish
  the same version string and PyPI carries only cu128, so on the reported case
  it reinstalled the identical broken wheel.
- both mismatch diagnoses (unsloth and Studio) called a stable-ABI wheel on a
  later torch a mismatch, and the Studio one compared full version strings, so
  2.10.0+cu126 vs 2.10.0+cu128 hid the real error before the CUDA-major check
  could give the accurate one.
- the probe reported bitsandbytes and torchao as working on an import alone,
  which is exactly the state where 4-bit dies mid-run and torchao has no
  kernels; both now check their native side, bitsandbytes through the same
  leaf module the loader gates on.
- xFormers loading its library is not the same as having a kernel for this
  GPU; a capability rejection now reads as degraded instead of Working.
- ROCm hosts probed nothing at all, though Unsloth enables flash-attn there.
- and a child that dies without answering no longer erases the whole report:
  the survivors keep their answers and the package that killed it is named.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Daniel Han and others added 2 commits August 8, 2026 19:06
…checked

Five things the probe got wrong once it started answering "does this run".

nvidia-smi lists physical devices and ignores CUDA_VISIBLE_DEVICES, so on a mixed
host masked to the sm_120 card the verdict was computed against row 0's sm_90 op
table, and xFormers read as working on a GPU that has no kernel for it. The mask is
resolved in the parent now, by index or by (abbreviated) UUID, and handed to the
child as UNSLOTH_PROBE_DEVICE_CC, because the child is started with the mask cleared
and cannot recover it.

bitsandbytes picks its native library from torch.cuda.is_available(), so hiding the
GPUs from the child made a healthy CUDA install report dead handles and light the
banner. It gets its own child now, with the mask the app itself runs under. The
server still never holds a context: that child exits immediately.

On Intel XPU the applicable set was empty, so a broken XPU bitsandbytes wheel was
"not used on this device" and never reached degraded, while the loader gates 4-bit
on native_kernels_ready(_bnb_probe, DEVICE_TYPE) with XPU symbols. It is probed.

torch.ops.<ns> materialises an empty _OpNamespace on attribute access, and its dir()
already lists __name__ and friends, so dir(torch.ops.torchao) was non-empty for the
no-extension case the check exists to catch. Counted off the dispatcher instead.

And the About table read one report-wide "probed" flag onto every row, so a package
the backend deliberately skipped rendered "Not loading" as soon as any other package
was probed -- red for something that is fine, and absent from the banner. Each entry
carries its own probed flag; the report-wide one is the fallback for an older backend.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…see the verdict

Two ways the probe could hurt the thing it was added to protect.

The gate read torch.cuda.get_device_capability() at the call site, at module scope, and
CUDA refuses that query when the device is busy, in exclusive-compute mode or otherwise
unavailable. There it raised before the probe could classify the failure as
inconclusive, so a diagnostic whose worst answer is "keep xformers on and let the
forward decide" turned `import unsloth` into a crash. The argument is gone (the gate
asks the kernel, not the number), and the fp32 read below it now degrades to unknown
through a guarded helper. A test walks the module's top-level statements and fails on
any capability query that runs at import.

And llama.py recomputed HAS_XFORMERS as `xformers is not None`, so turning the
dispatcher's flag off never reached the model code. Mistral answers "xFormers is on" by
skipping the 4D sliding-window mask and letting the xFormers bias carry the window; with
the dispatcher already on SDPA, that mask is the only thing making the window local, so
a sequence longer than config.sliding_window attended to the whole causal history. It
takes the probed flag from the dispatcher now.
@danielhanchen
danielhanchen requested a review from Datta0 as a code owner August 8, 2026 19:36
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Daniel Han added 2 commits August 8, 2026 20:13
…tell

Five follow-ups, all the same shape: a diagnostic that overstates what it knows.

Mistral's training branch takes `elif self.training: pass`, so no 4D mask is synthesized,
and its AttentionContext never carried sliding_window at all. With xFormers off and
flash-attn absent, nothing was left holding the window and every sequence past
config.sliding_window attended its whole causal history. The context carries the window
now, and the SDPA path builds a windowed keep mask even with no padding mask to hang it
off, since is_causal is full causal and has no window of its own.

The capability resolver truncated the mask to its first entry, so with
CUDA_VISIBLE_DEVICES=0,1 across a mixed pair a rank on the second card fell back to SDPA
while the verdict from the first said Working. Every visible device is resolved and
handed to the child now, and one uncovered card makes the whole install degraded.

flash-attn recorded runs=true on the strength of importing its interface. Our own
installer refuses prebuilt wheels on sm_100+ because none covers those cards, so a wheel
that got there another way could load and still fail on its first launch. That is
unknown, with the reason, rather than a verdict this child would have to launch a kernel
to earn.

The About table read runs=null as Working. A probe that ran and could not decide -- an
unrecognised xformers layout, a missing bitsandbytes checker, a torch with no dispatcher
table, the flash-attn case above -- is unknown, and nothing else would have corrected it
since those packages are not in degraded either.

And xformers_for_torch returned None above 2.10, which contradicted this module's own
describe_xformers_mismatch: it accepts a 2.10-built wheel on 2.11 under the stable ABI,
then the fix hint told the user no release exists and to downgrade torch or build from
source. Above the floor the answer is 0.0.35, and the hint already names the CUDA index
that repairs the family.
Daniel Han and others added 2 commits August 8, 2026 22:20
The no-metadata path (a source or editable 0.0.34+ build) fell back to the
recorded torch pin and called every later release a mismatch, contradicting the
stable-ABI rule the build-metadata branch two blocks up already applies. An
unrelated extension failure was therefore diagnosed as a torch-version problem
with reinstall instructions that fix nothing.

The breakage announcement claimed a fallback to SDPA and more memory even when
FlashAttention is installed, which select_attention_backend prefers over
xformers anyway. The consequence sentence now follows what actually picks up the
work; the breakage is still reported either way.

A numeric CUDA_VISIBLE_DEVICES entry is a CUDA ordinal in the current
CUDA_DEVICE_ORDER, and nvidia-smi's index is the PCI_BUS_ID ordering. The pin is
a setdefault, so a user who exported FASTEST_FIRST keeps it and the ordinal
cannot be inverted without initialising CUDA. That case now answers unknown
instead of probing the wrong card; UUID masks are unaffected.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

An unresolvable device mask reached the probe child as an empty
UNSLOTH_PROBE_DEVICE_CC, which the child reads as no override at all and answers
from nvidia-smi over every physical GPU: the whole-box verdict the resolver
returned None to avoid. It now travels as an explicit unknown sentinel, and the
child refuses to fall back on it.

An xformers whose _cpp_lib raises a native load error left runs at None, so the
package stayed out of degraded and the About row read 'Not checked' with no
banner, on exactly the corrupt install this report is for. That is now broken; a
layout with no _cpp_lib at all stays unknown.

bitsandbytes is probed on ROCm. device_type.py imports it on every backend and
gates 4-bit and prequantized loading on native_kernels_ready, so a dead ROCm
wheel silently costs quantized loading while the report called the package 'not
used on this device'.

And the fix hint redacts the mirror URL. UNSLOTH_PYTORCH_MIRROR can carry
credentials or a signed-URL query, and that hint prints to stdout on the default
import path, into logs and shared notebooks.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 8, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 8, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 8, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 8, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 8, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 8, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 8, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 285f6b467b

ℹ️ 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".

Daniel Han added 2 commits August 8, 2026 23:23
find_spec is the right answer for an installed unsloth, but CI installs a
published wheel that predates bnb_availability.py, so the lookup landed on a
site-packages copy without the file and every bitsandbytes verdict came back
unknown. This file's own location settles it: studio/backend/utils/hardware to
the repo root.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

A transient probe failure is not a broken wheel. bitsandbytes keeps CUDA visible
on purpose, so opening Settings while a trainer has filled the GPU, or holds it
in EXCLUSIVE_PROCESS, fails at context creation on a healthy install -- and that
answer is cached for the life of the backend, so the banner sat there until
restart. Busy, out-of-memory and unavailable now read as not probed, with the
reason shown, using the same classification the in-process xformers probe makes.

The mirror redactor no longer returns its input when it cannot parse it. A
malformed authority is exactly the URL whose credentials or signed query this
was added to keep out of stdout, so it drops the index instead and the hint
omits --index-url.

And the Settings banner no longer promises a slower fallback. When xFormers is
the dead package and FlashAttention loaded, the dispatcher prefers FlashAttention
and there is no slower path; the banner now names what cannot load and points at
the list, in every locale.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 8, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 8, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 8, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 20cd9929a6

ℹ️ 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".

Both assert on the probe's classification, and on a CPU-only runner the
report never probes at all: every row comes back "not used on this device"
and degraded is empty, so the two assertions failed on CI while passing on
any machine with a GPU. The on_accelerator fixture the rest of the file
already uses is what makes the probe applicable.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 9ea53c0bf7

ℹ️ 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".

@danielhanchen
danielhanchen merged commit 72aec0f into main Aug 9, 2026
66 of 73 checks passed
@danielhanchen
danielhanchen deleted the nv/p0-xformers branch August 9, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant