Repository navigation
Add the Qwen-Image-2.1 family, and the Diffusers it needs by default - #11405
Conversation
torchao weight subclasses are wrapper tensors, so every pre-quant artifact
we publish has had to be a torch.save pickle, read under weights_only plus a
constructor allowlist. torchao 0.16 added flatten_tensor_state_dict and
unflatten_tensor_state_dict, the same pair transformers and diffusers use for
their own torchao checkpoints, so the subclass can be split into plain tensors
plus a JSON description and stored in safetensors after all.
Adds core/inference/prequant_safetensors.py, which reads and writes that
container, and teaches the transformer and text encoder loaders to dispatch on
the file extension. Both containers come back as the same
{"format", "state_dict", "metadata"} dict, so every existing check (scheme,
base model, min_features, fast_accum, the fp8 activation floor probe, the
rotation biconditional, the kernel preference pin) runs unchanged on both and
the two formats cannot drift into having different acceptance rules.
What this buys, beyond the file format:
- No constructor allowlist. restricted_prequant_load_supported is a real gate:
video.py refuses a pre-quant checkpoint outright when it answers False, which
is what happens on a torch too old for add_safe_globals or a torchao missing
a scheme's constructors. A safetensors artifact names no constructors, so it
takes the filename now and answers that question for the right container.
- Validation before any weight is read. The scheme probe answers from the
header, a few KB of JSON, rather than parsing a multi-gigabyte pickle.
- mmap, lazy per-tensor reads and the Hub file viewer come with the format.
usable_prequant_source now resolves before it gates, because the answer differs
per container: a repo whose primary artifact is safetensors is usable on an
install that could not open a pickle at all, and asking first returned None for
it, making the pre-quant invisible to memory planning and silently loading dense.
Nothing about existing artifacts moves. The format tags still describe what the
weights mean, so a rotated safetensors checkpoint is still v2 and still refused
by a build that cannot rotate; old builds are kept away from these files by the
filename, since they only ever ask for <Model>-<SCHEME>.pt.
Two upstream limitations are handled rather than hoped about:
- unflatten splits every key on ".", so a root-level tensor writes cleanly and
can never be read back. The builder refuses up front and names the keys.
- Through torchao 0.17 the int8 config still produces the legacy
LinearActivationQuantizedTensor, which cannot be flattened; 0.18 produces
Int8Tensor, which can. Reading is unaffected either way, so this binds the
machine that builds an artifact and now says so instead of surfacing a bare
"Unsupported tensor type" from inside torchao.
build_prequant_checkpoint.py picks the container from the --out extension, and
refuses to publish a safetensors artifact under a name no loader would ask for:
every derived name ends in .pt, so without a family prequant_filenames entry
the upload is a file nothing can reach on a repo that looks like it has one.
Verified on a real save and a fresh safe_open: fp8 and int8 both reconstruct
Float8Tensor / Int8Tensor bit-identically and pass load_state_dict(strict=True),
and the header satisfies torchao's own is_metadata_torchao, so transformers and
diffusers can read these files too. That last assertion is deliberate: torchao
returns its metadata already JSON encoded, and encoding it a second time round
trips perfectly against our own reader while producing a header every Hugging
Face loader rejects.
Qwen-Image-2.1 is a different architecture, not a refreshed Qwen-Image checkpoint, so it gets its own family rather than a prequant_variant_repos row: 32 single-stream blocks against 60 dual-stream MMDiT ones, nine weights per block, zero bias tensors anywhere, one global modulation projection, a Qwen3-VL text encoder and its own VAE class. Sharing the qwen-image entry would hand it that family's pipeline, transformer, VAE and exclusion rules, none of which fit. The int8 exclusion list is measured, not inherited. Six arms rendered the 16-prompt calibration set at 1024 and were scored against the bf16 reference, paired per prompt, with a bf16-on-the-same-GPU control that scored exactly 0.00000 LPIPS so the pairing carries no device confound: int8 + txt_in excluded 0.06415 int8, modulation included 0.09375 int8 generic tokens 0.10317 fp8 + txt_in excluded 0.10465 fp8 runtime default 0.11209 fp8 + modulation excluded 0.13019 Only txt_in survives as a real lever, and only for int8: -0.03901 against the generic tokens, CI95 [-0.07081, -0.00722], better on 14 of 16 prompts. Worth saying plainly that this is a QUALITY lever here and not the small-M crash guard it is on qwen-image, since every arm rendered a deliberately two-token prompt without tripping _int_mm's M floor. The two levers that did not survive are recorded as such rather than shipped: excluding modulation.1 under fp8 is +0.01810 CI95 [-0.01619, +0.05239], and removing int8's inherited modulation exclusion is -0.00941 CI95 [-0.02175, +0.00292]. The one global tensor every block reads is simply not unusually sensitive on this architecture, in either direction, so fp8 keeps the runtime default and adds no special case. The family names .safetensors artifacts in prequant_filenames, because every derived fallback name ends in .pt: without those rows the loader would ask the Hub for a file that is not there and fall back to the dense bf16 download. build_prequant_checkpoint.py gains --base-model-id, for building from weights staged in a local directory. The loader compares final path segments, so an artifact built from ./temp/qwen_image_21 records a base whose tail is "qwen_image_21", a load asking for "Qwen/Qwen-Image-2.1" sees different tails, and a good artifact is refused after the dense shards were already dropped. The override is pinned to the family's own base_repo, so it can only ever name the model that family is for and cannot relabel one checkpoint as another. Both artifacts are built and verified end to end on B200. Loaded in a fresh process through load_prequantized_transformer, which runs the real format, scheme, base_model_id, min_features, fast_accum and fp8 activation-floor checks: fp8 7.12 GB load 1.4s peak 6.63 GiB Float8Tensor LPIPS 0.11209 int8 7.26 GB load 1.5s peak 6.73 GiB Int8Tensor LPIPS 0.06415 against 13.25 GiB dense, so roughly half. The renders are not merely close to the in-memory quantize, they are BYTE-IDENTICAL to it across all 16 prompts, which is the evidence that the safetensors round-trip loses nothing between the builder and a user's machine. QwenImage21Pipeline is registered against diffusers 0.41.0, the first release that can carry it: 2.1 merged upstream on 2026-09-18, four weeks after 0.40.0 was cut. _version_tuple stops at the first non-numeric part, so a 0.41.0.dev0 build from main reads as (0, 41, 0) and satisfies the same entry.
The first commit made safetensors possible; this makes it the default. The
name a repo is asked for is now a CHAIN, best first:
<Model>-<SCHEME>.safetensors (new, preferred)
<Model>-<SCHEME>.pt (what is hosted today)
transformer_<scheme>.pt (legacy)
Deriving the preference rather than declaring it per family means a repo that
gains a safetensors sibling is picked up with no code change, and a repo that
never does keeps resolving exactly what it resolves today, because the pickle
spellings stay in the chain behind it. Existing repos are unaffected:
unsloth/Qwen-Image-FP8 still resolves Qwen-Image-FP8.pt and transformer_fp8.pt,
and a .pt name still routes to the pickle reader and its constructor allowlist.
PrequantSource grows fallback_filenames plus a candidate_filenames property, so
the downloader, the cache probe and the planner read one ordered list instead of
three hand-maintained pairs. fallback_filename stays as a property returning the
first, because callers outside this module read it by name.
Two things had to change with it, and both would have been silent regressions:
cached_checkpoint_path credited ONLY the primary name. That was right while the
primary was the only name a repo realistically hosted. With the chain leading on
a safetensors name that no repo hosts yet, it would have reported every existing
.pt repo as "this would have to download several GB" and handed the pick to the
GGUF while the checkpoint sat in the cache. It now walks the chain in order,
which keeps the property that motivated primary-only: the better name still wins
whenever it is actually present.
usable_prequant_source would have turned optimistic. Every family now derives a
safetensors candidate, so "is any candidate readable" answers yes even on an
install that cannot open a pickle at all, for a repo that only has .pt. Planning
would budget a 6 GB artifact, the fetch would 404 down to the pickle, the pickle
would be refused, and the load would fall back to dense under a plan that never
budgeted it -- the evict-then-OOM that function exists to prevent. A DERIVED
safetensors name is a guess, so it now counts only with evidence: the family
declared it, or it is already cached. PrequantSource records which names were
declared so the two can be told apart.
candidate_filenames_of() reads the chain off anything shaped like a source,
because planning passes lightweight stand-ins carrying only filename and
fallback_filename; reading the property directly turned one of those into an
AttributeError swallowed into "no prequant plan" and a silent dense fallback.
1171 tests pass. The suites that encoded the old two-name contract are updated
rather than deleted, including the one that asserted primary-only caching, whose
comment now records why that rule changed.
Qwen-Image-2.1 merged upstream on 2026-09-18, four weeks after 0.40.0 was cut, so 0.41.0 is the first release that can carry it and there is nothing on PyPI that works. Without this the only way to try it is to break the release pin by hand. diffusers-pin.txt is untouched. It is the single source of truth for the release everything is built against, and it deliberately refuses a source build so installs stay reproducible and keep working behind a PyPI mirror with no route to github.com. Both properties are worth more than shipping one model early, so the default install is exactly what it was and this is something you ask for with UNSLOTH_DIFFUSERS_MAIN=1. A COMMIT, not a branch, because nothing in Unsloth can tell two builds of main apart: a git checkout reports 0.41.0.dev0 whatever it was built from, and _version_tuple truncates that to (0, 41, 0), so the family version gate reads any main build as satisfying 0.41.0. The commit is the only thing actually pinning behaviour. It is also cheaper to check: for a full SHA _direct_reference_is_installed compares what direct_url.json recorded and needs no network at all, while a branch ref costs a git ls-remote every pass. The pinned commit is the tree the Qwen-Image-2.1 FP8 and INT8 artifacts were built and measured against, so what an opting-in user gets is what was tested. Three things the ordinary _skip_step path does not cover, each handled: - A version says nothing here, so satisfaction is read off direct_url.json. Exercised against the real check: installed at the pinned SHA is satisfied, installed from main with the same commit_id is NOT (the recorded ref differs), an older SHA is not, and a released wheel with no vcs_info is not. No ls-remote is attempted for a SHA. - Diffusers is mandatory, unlike triton_kernels, so a host with no working git must not be left broken. It is not: the release pin ran first and is already in place, so the step declines and says why rather than failing the install. - The step runs immediately AFTER the release pin, or the release would overwrite it. The test compares call sites rather than filenames, because the helper is defined earlier in the file than either install and a filename compare would pass by accident. Retiring it is one line: bump diffusers-pin.txt to 0.41.0 and delete the file. The family entry already records 0.41.0 as QwenImage21Pipeline's minimum. tests/studio/install: 6878 passed. Two failures in test_install_manifest.py are pre-existing and fail identically on main.
Codex Review SummaryThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01d83277aa
ℹ️ 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".
| # upstream but has not reached a release. Runs immediately after the release pin so it | ||
| # overwrites it, and never at all without the flag, so the default install keeps the exact | ||
| # release everything is built against and keeps working with no route to github.com. | ||
| _diffusers_main_step() |
There was a problem hiding this comment.
Check the main build before replacing it with the release
With UNSLOTH_DIFFUSERS_MAIN=1 on a subsequent install, the release-pin step immediately above sees 0.41.0.dev0 as not satisfying diffusers==0.40.0 and replaces the already-correct Git build; this call then observes no matching direct_url.json and reinstalls the same Git commit. Consequently, every opt-in update performs both installs, and an offline update with a working pinned build first downgrades it and then fails trying to fetch GitHub. Preserve/check the matching direct reference before applying the release pin.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 4905b27. This was failing CI on all three platforms, not only in theory: test_a_second_update_changes_nothing_on_disk reported diffusers as the single distribution a second, changeless update rewrote, same version 0.41.0.dev0, new mtime. Reproduced by running two passes with pip recorded: the PR as submitted installed diffusers-main.txt on pass one and diffusers-pin.txt again on pass two, against a base that installed nothing on either. _skip_step now takes a superseded flag and the release pin stands down when the main build is both wanted and already resident, which is also the offline case you name, since the downgrade is a local resolve that lands while the restore needs github.com and cannot. Opting out and a first install are unchanged, so the release still goes down before the commit and stays what a failed source build degrades to.
| _progress("diffusers main (satisfied, skipped)") | ||
| _record_step("diffusers-main.txt", "skipped") | ||
| return | ||
| _progress("diffusers main") |
There was a problem hiding this comment.
Count the opt-in install in the progress total
When the opt-in flag is enabled, this new _progress call consumes an additional step, but install_python_stack() leaves _TOTAL unchanged. All later progress updates therefore run past the denominator, producing values such as 20/19 and an over-width progress bar, while the completion manifest records the wrong step count. Add the optional slot to _TOTAL under the same condition that makes this step report progress.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct against the commit this was written on, where the step was opt-in and base_total was untouched, and already fixed by cb07398: the step now spends exactly one slot on every path, opt-out included, and base_total went 13/14 to 14/15. Verified rather than read, over 4 platforms x 7 branches of the step x skip-base x no-torch, 112 cells, every one ending with _STEP == _TOTAL and rc 0; removing one _progress from the opt-out branch turns 16 of those cells red, so the matrix is not vacuous. Counting the slot conditionally would have been the wrong repair, because the denominator is fixed before the opt-out is known.
Qwen-Image-2.1 needs a Diffusers no release carries yet, and behind a flag that means nobody gets it. This flips UNSLOTH_DIFFUSERS_MAIN: the pinned commit installs by default, and UNSLOTH_DIFFUSERS_MAIN=0 (also false/no/off) opts out. Unset means yes, so a typo in the variable name cannot silently take a model away. The release pin is still installed first and diffusers-main.txt is still a separate file rather than an edit to it. That separation is what makes running by default safe: the release lands and stays resident, so the main build is only ever an upgrade on top of a working install. The step therefore uses pip_install_try, not pip_install. pip_install exits the installer on failure, which as an opt-in cost the few people who asked for it and as a default would make a reachable github.com a hard requirement of installing Unsloth: a PyPI mirror with no route out, a proxy blocking git over https, or an upstream outage would each turn a working install into no install. It now degrades to the release with a note naming the opt-out, the same way the no-git path already did. pip_install_try gains req=, routed through _effective_requirements exactly as pip_install does, so a file installed through either entry point is the file the install-manifest gate audits. One thing the flip exposed: the step spends a progress slot, and an early return without a _progress left the bar short of its own total for anyone who opted out. It now emits exactly one _progress on every branch, opting out included, and base_total counts it unconditionally. That moved 25 hard-coded step totals in test_rocm_support.py, test_windows_torch_flavor_invariant.py and test_mlx_install.py. tests/studio/install: 6880 passed. The two remaining test_install_manifest.py failures are pre-existing and fail identically on main.
Three places treated the container as settled once the name resolved. The Windows ROCm torchao stub answers every torchao.* import with a fabricated callable, so importing the flatten/unflatten pair succeeded there and reported safetensors support on an install whose unflatten returns None. Planning would drop the dense shards for a checkpoint the loader can never rebuild. The pickle probe already asked is_stubbed; the safetensors one now does too. The download plan committed to the first candidate the repo HELD, which is no longer the same question as the first it can OPEN now that the chain spans two containers. A repo still serving only the legacy pickle, met by an install that cannot restrict that load, spent the download and then refused it with no dense weights left. It now skips a name it cannot read and reports the miss, which keeps the shards in the pull. An explicit --upload-filename skipped the container check as well as the family table, so a safetensors build could be published under .pt and a pickle under .safetensors. Both upload cleanly and neither can ever be opened, after the hours the quantization took. Also updates the Qwen-Image-2512 filename test, which pinned the single derived name and now asserts the whole chain: safetensors first, the .pt the repo actually serves still in it, the legacy spelling last.
…o studio-qwen-image-21
The release pin is a version pin and every build of main reports 0.41.0.dev0, so diffusers==0.40.0 never reads as satisfied once the commit is in place. Left alone the release step reinstalled the release on every pass and the step after it put the same commit back on top, so no update was ever a no-op: the idempotency suite caught it on Linux, Windows and macOS alike, with diffusers the single distribution a second, changeless update rewrote. Offline it is worse than wasteful. The downgrade is a local resolve and lands; the restore needs github.com and cannot, so an update that had a working pinned build ends without one. _skip_step grows a superseded flag for this: the requirement really is unsatisfied, and must still not run, because running it undoes the step that supersedes it. The gate is deliberately narrow, wanted AND already resident, so opting out still reinstates the release and a first install still lays it down before the commit goes on top, which is what a failed source build degrades to. The slot is spent either way, so the progress total is unchanged. Also merges the base PR and main.
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4905b27179
ℹ️ 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".
| "will refuse with a message naming the version they want.", | ||
| ) | ||
| return | ||
| if _direct_reference_is_installed(req, "diffusers"): |
There was a problem hiding this comment.
Verify the main build payload before skipping reinstall
When the pinned Diffusers distribution retains its dist-info/direct_url.json but any package file has been deleted or damaged, this provenance-only check still treats the build as satisfied. The same predicate also marks the release pin as superseded, so neither step repairs the mandatory dependency and every later installer run leaves Studio broken. Require _payload_recorded_intact("diffusers") (as the triton-kernels path already does) before both skipping this step and suppressing the release fallback.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed, fixed in 7153a29, and the coupling you point at is the part that made it worth fixing rather than noting: the release pin reads the same predicate to decide it has been superseded, so a provenance-only answer skipped the reinstall and the repair together, on a mandatory dependency, on every later pass rather than one. _diffusers_main_resident now pairs the ref check with _payload_recorded_intact, the same pairing _triton_kernels_step already uses and for the same stated reason, and either half failing means install it, which is the recoverable direction.
…stion too The plan learned to skip a candidate this install cannot open; the two places that answer alongside it did not, and an asymmetry there is worse than the original gap. _resolve_checkpoint_path took the first name the repo HELD. On a repo hosting both containers the plan would stage the readable one while this fetched the other, spending a second multi-gigabyte download to fail on it and then falling back to dense weights the plan had already left out. It now filters the chain with the same per-filename check, and only when that leaves something, so a source that should never have been offered still reaches the loader's refusal rather than a silent None. cached_checkpoint_path walks every candidate, so a cached legacy pickle satisfied the declared-or-cached evidence gate for an install that cannot open one. The probe is now scoped to the readable names: a cached .pt is a real hit for sizing and a non-answer for this question, and only the caller knows which is being asked.
direct_url.json survives inside dist-info while the package tree under it is deleted or truncated, so a provenance-only check reported the build as satisfied when it was not there. The release pin reads the same predicate to decide it has been superseded, so that answer skipped the reinstall AND the repair, on a mandatory dependency, on every later pass rather than one: Studio would stay broken. _diffusers_main_resident pairs the ref check with _payload_recorded_intact, exactly as the triton kernels step already does, and either half failing means install it, which is the recoverable direction.
|
@codex review |
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. 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". |
# Conflicts: # studio/backend/tests/test_build_prequant_checkpoint.py
…i#11573) (Python 3.13, a-k) fails the same four tests on every PR. Bisected on main with the GPU hidden, as on the runner; each is a test that stopped describing the product, not a product regression: - test_download_plan_counts_a_cached_lower_auto_prequant, since unslothai#11394. The plan now skips a pre-quant name this install cannot open, and torchao 0.18, which the shard installs unpinned, has no int8 pickle constructors. The test offers only Qwen-Image-INT8.pt. It now pins the readability answer and also asserts the converse: an unreadable artifact is not budgeted. - test_every_third_party_bf16_pipeline_the_catalog_offers_is_mirrored, since unslothai#11405 offered Qwen/Qwen-Image-2.1. unsloth/Qwen-Image-2.1 is not on the Hub, so a mirror row would 404 every fetch it redirects. Named as a pending mirror that fails once the row lands or the catalog drops it. - test_the_recorded_base_must_be_the_canonical_id_not_just_the_same_tail, added by unslothai#11405. build_prequant_checkpoint.main imports diffusers before reading an argument and the shard has no diffusers. An empty stand-in when it is absent; the refusal lands before any diffusers attribute is read. - test_qwen_image_21_gguf_reaches_sd_cpp_with_its_own_vae_and_a_qwen3vl_encoder, since unslothai#11542 moved the encoder to UD-Q4_K_XL on purpose and pins that name in its own test. This one now reads the declared name and keeps its own claim, that the file is a 4-bit GGUF.
…s unmet (unslothai#11578) * Compare a full pass to a skipping one without the click both record as unmet Unsloth Update CI has failed on Linux and macOS since unslothai#11405 (last success 12:04Z): test_full_deps_forces_every_step_and_still_changes_nothing and test_the_install_is_left_working see click 8.5.0 against 8.3.0 and nothing else. sqlfluff<4 caps click at 8.3.0 and huggingface-hub 1.23+ needs 8.4.2, so click lands wherever the last step that resolved it put it. unslothai#11405 added Diffusers main as a direct reference after the data-designer deps; installing it re-resolves hub's closure. install.sh and a full-deps pass run it (8.5.0); the settle run re-ran data-designer deps and skipped it (8.3.0). The update logs in the run's studio-update-log artifact show exactly that. A distribution both manifests record as known_unmet is now set aside. It must still be installed on both sides, and every other name and version must match. * Trust known_unmet only against the installed set it was written for The installer reads the record only when known_unmet_index matches the current installed-set digest, and so should the test: a stale record could otherwise set aside a distribution a later step moved. snapshot() now computes that digest in the venv with the installer's own installed_dependency_index, hashed as _installed_index_digest hashes it; a record whose index does not match names nothing. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Count records per name before setting a known_unmet version aside A set of names collapses a second metadata record for an exempted distribution (a pip backup the installer's index skips, a duplicate dist-info), and the version filter then hides it. Compare per-name counts instead, so an extra or missing record fails even for a known_unmet name. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…ffusers main build needs (#11625) * Unsloth Studio: raise the huggingface_hub floor to what the pinned Diffusers main build needs diffusers reads httpx out of huggingface_hub.utils, a forwarding shim that only exists from hub 1.31, and it does so in utils/hub_utils.py, so plain `import diffusers` fails on an older hub and every model on the diffusers engine is unreachable, not just Qwen-Image-2.1. The pinned main build declares huggingface-hub>=1.31.0,<2.0. Unsloth declared >=1.23.0, which was the floor the diffusers RELEASE wanted; #11405 pinned a main commit with a higher floor and left this one behind. Anything resolved into the gap satisfies Unsloth, breaks diffusers, and nothing in the install says so. * Correct the list of files that carry the hub floor base.txt has never declared huggingface_hub. The fifth place that moved to the 1.x window is the studio extra in pyproject.toml. * Shorten the hub floor comment in the macOS arm64 overrides --------- Co-authored-by: Daniel Han <[email protected]>
…nothing else (unslothai#11751) * Clean-machine trace leg: let git fetch the pinned git+ requirements, nothing else A default install with a working git clones the pinned Diffusers main build through uv (unslothai#11405 made it the default; a clone records a ref, the archive fallback does not). The macOS trace / file leg's notools check rejected every git line, so the first installer PR to run that leg since then went red. notools now takes UNSLOTH_ALLOW_GIT_FROM, a list of requirement files. Each git line may name only their git+ remotes, remoteless lines (uv's rev-parse, reset, clone --local in its cache) count only when an allowed remote was fetched, and git --version is the installer's probe. Any other remote, a compiler or brew is still a hit, and with the variable unset nothing changes. tests/sh/test_clean_machine_notools_pinned_git.sh replays the trace that leg recorded and covers the rejections. * notools: allow remoteless git only in uv's exact cache shapes One allowed fetch enabled every URL-free git line for the whole trace, so `git fetch origin` (its URL comes from config) or a clone between arbitrary local paths passed beside it. A remoteless line must now be init, rev-parse, submodule update --recursive --init, reset --hard to a pinned commit, or clone --local from $UV_CACHE_DIR/git-v0/db to $UV_CACHE_DIR/git-v0/checkouts. A line naming a remote may carry no -c except remote.origin.url=. * notools: a git line naming a remote must only read from it Any subcommand that named the pinned remote passed, push included. The line must now be fetch, ls-remote or submodule update (uv's shapes), with no -c anywhere except the leading remote.origin.url= pair. * notools: read a remote-naming git line as git reads its argv Any URL-looking substring counted as the repository, so an option value (fetch --all --server-option=URL) passed, and also counted as the allowed fetch that unlocks uv's cache operations. A remote-naming line must now be uv's fetch shape (known options, then the allowed repository, then only src:refs/ refspecs) or -c remote.origin.url=URL submodule update with only --init/--recursive. ls-remote is no longer accepted; uv does not use it. * notools: accept a submodule update only inside uv's checkout git submodule update fetches whatever the current checkout's .gitmodules names, and the trace recorded argv only, so the same command in any other repository passed. The trace git wrapper now also records its working directory beside the trace, and both submodule update shapes count only when every run with those arguments was under $UV_CACHE_DIR/git-v0/checkouts. No record fails closed, and the verify step checks the wrapper writes one. * notools: take the reset commit from uv's checkout, not this checkout's pin The macOS trace legs run overlay-free, so the installer and its requirement files come from the released wheel, which can pin an older Diffusers commit than this checkout's diffusers-main.txt. The reset to that commit was then a hit. uv names each checkout directory after the short commit it installs, so reset --hard now needs a full 40-hex commit, run in a uv checkout whose name it starts with. The remote allowance still reads the requirement file. * notools: scope init and rev-parse to uv's cache; read the pin after the last @ A bare git init or rev-parse passed wherever it ran. Both now count only when every run was under $UV_CACHE_DIR/git-v0, where uv keeps its database and checkouts. The allowed remote stopped at the first @, so an ssh requirement (ssh://git@host/repo.git@SHA) allowed only ssh://git and rejected its own fetch. The revision is now what follows the last @. * Clean-machine trace leg: allow the installed package's git+ remote too The overlay-free trace legs install the released wheel, so a checkout that repins Diffusers to another repository before a release would reject the installed package's legitimate fetch. The assert step now also passes the installed package's diffusers-main.txt from the managed venv, and notools allows the union of both files' remotes. * Clean-machine trace leg: read the git+ allowance from the installed package alone Adding the installed copy to the checkout's pin allowed both repositories, so a checkout-only remote fetched by mistake would still pass. The installed package's diffusers-main.txt now replaces the checkout's; the checkout's is a fallback, with a warning, only when the managed venv has none. * notools: the reset commit must be the one the installed package pins A reset to any commit passed as long as uv's checkout was named after it. Now that the workflow passes the installed package's own diffusers-main.txt, reset --hard must also name exactly the 40-hex commit it pins. * clean-machine-env.sh: start the git working-directory record empty The trace was truncated at setup but the .git-cwd record was only appended to, so a second trace with the same CLEAN_MACHINE_DIR judged the new install by an older one's rows. It is now truncated with the trace. The shell test runs trace setup twice for real and checks the wrapper records where git ran and that a new trace starts the record empty.
unslothai#11759) Without the Command Line Tools, Apple Silicon's /usr/bin/git is a shim, and running it (even git --version) raises the "install the command line developer tools" dialog. install.sh's _has_working_git answers from the path there; install_python_stack.py's ran the shim unconditionally. That was harmless while only the triton step, skipped on macOS, asked, but since the pinned Diffusers main build became the default (unslothai#11405) every macOS install asks, so a Mac without the CLT got the dialog mid-install. The Python probe now mirrors install.sh: on Apple Silicon hardware (Rosetta included, via hw.optional.arm64), a git that resolves to exactly /usr/bin/git with no toolchain selected (xcode-select -p fails) is answered as missing without running it. Homebrew, Xcode.app and Intel Mac gits are still run.
…nslothai#11405) * Let a pre-quant checkpoint be safetensors instead of a pickle torchao weight subclasses are wrapper tensors, so every pre-quant artifact we publish has had to be a torch.save pickle, read under weights_only plus a constructor allowlist. torchao 0.16 added flatten_tensor_state_dict and unflatten_tensor_state_dict, the same pair transformers and diffusers use for their own torchao checkpoints, so the subclass can be split into plain tensors plus a JSON description and stored in safetensors after all. Adds core/inference/prequant_safetensors.py, which reads and writes that container, and teaches the transformer and text encoder loaders to dispatch on the file extension. Both containers come back as the same {"format", "state_dict", "metadata"} dict, so every existing check (scheme, base model, min_features, fast_accum, the fp8 activation floor probe, the rotation biconditional, the kernel preference pin) runs unchanged on both and the two formats cannot drift into having different acceptance rules. What this buys, beyond the file format: - No constructor allowlist. restricted_prequant_load_supported is a real gate: video.py refuses a pre-quant checkpoint outright when it answers False, which is what happens on a torch too old for add_safe_globals or a torchao missing a scheme's constructors. A safetensors artifact names no constructors, so it takes the filename now and answers that question for the right container. - Validation before any weight is read. The scheme probe answers from the header, a few KB of JSON, rather than parsing a multi-gigabyte pickle. - mmap, lazy per-tensor reads and the Hub file viewer come with the format. usable_prequant_source now resolves before it gates, because the answer differs per container: a repo whose primary artifact is safetensors is usable on an install that could not open a pickle at all, and asking first returned None for it, making the pre-quant invisible to memory planning and silently loading dense. Nothing about existing artifacts moves. The format tags still describe what the weights mean, so a rotated safetensors checkpoint is still v2 and still refused by a build that cannot rotate; old builds are kept away from these files by the filename, since they only ever ask for <Model>-<SCHEME>.pt. Two upstream limitations are handled rather than hoped about: - unflatten splits every key on ".", so a root-level tensor writes cleanly and can never be read back. The builder refuses up front and names the keys. - Through torchao 0.17 the int8 config still produces the legacy LinearActivationQuantizedTensor, which cannot be flattened; 0.18 produces Int8Tensor, which can. Reading is unaffected either way, so this binds the machine that builds an artifact and now says so instead of surfacing a bare "Unsupported tensor type" from inside torchao. build_prequant_checkpoint.py picks the container from the --out extension, and refuses to publish a safetensors artifact under a name no loader would ask for: every derived name ends in .pt, so without a family prequant_filenames entry the upload is a file nothing can reach on a repo that looks like it has one. Verified on a real save and a fresh safe_open: fp8 and int8 both reconstruct Float8Tensor / Int8Tensor bit-identically and pass load_state_dict(strict=True), and the header satisfies torchao's own is_metadata_torchao, so transformers and diffusers can read these files too. That last assertion is deliberate: torchao returns its metadata already JSON encoded, and encoding it a second time round trips perfectly against our own reader while producing a header every Hugging Face loader rejects. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add the Qwen-Image-2.1 family with measured int8 exclusions Qwen-Image-2.1 is a different architecture, not a refreshed Qwen-Image checkpoint, so it gets its own family rather than a prequant_variant_repos row: 32 single-stream blocks against 60 dual-stream MMDiT ones, nine weights per block, zero bias tensors anywhere, one global modulation projection, a Qwen3-VL text encoder and its own VAE class. Sharing the qwen-image entry would hand it that family's pipeline, transformer, VAE and exclusion rules, none of which fit. The int8 exclusion list is measured, not inherited. Six arms rendered the 16-prompt calibration set at 1024 and were scored against the bf16 reference, paired per prompt, with a bf16-on-the-same-GPU control that scored exactly 0.00000 LPIPS so the pairing carries no device confound: int8 + txt_in excluded 0.06415 int8, modulation included 0.09375 int8 generic tokens 0.10317 fp8 + txt_in excluded 0.10465 fp8 runtime default 0.11209 fp8 + modulation excluded 0.13019 Only txt_in survives as a real lever, and only for int8: -0.03901 against the generic tokens, CI95 [-0.07081, -0.00722], better on 14 of 16 prompts. Worth saying plainly that this is a QUALITY lever here and not the small-M crash guard it is on qwen-image, since every arm rendered a deliberately two-token prompt without tripping _int_mm's M floor. The two levers that did not survive are recorded as such rather than shipped: excluding modulation.1 under fp8 is +0.01810 CI95 [-0.01619, +0.05239], and removing int8's inherited modulation exclusion is -0.00941 CI95 [-0.02175, +0.00292]. The one global tensor every block reads is simply not unusually sensitive on this architecture, in either direction, so fp8 keeps the runtime default and adds no special case. The family names .safetensors artifacts in prequant_filenames, because every derived fallback name ends in .pt: without those rows the loader would ask the Hub for a file that is not there and fall back to the dense bf16 download. build_prequant_checkpoint.py gains --base-model-id, for building from weights staged in a local directory. The loader compares final path segments, so an artifact built from ./temp/qwen_image_21 records a base whose tail is "qwen_image_21", a load asking for "Qwen/Qwen-Image-2.1" sees different tails, and a good artifact is refused after the dense shards were already dropped. The override is pinned to the family's own base_repo, so it can only ever name the model that family is for and cannot relabel one checkpoint as another. Both artifacts are built and verified end to end on B200. Loaded in a fresh process through load_prequantized_transformer, which runs the real format, scheme, base_model_id, min_features, fast_accum and fp8 activation-floor checks: fp8 7.12 GB load 1.4s peak 6.63 GiB Float8Tensor LPIPS 0.11209 int8 7.26 GB load 1.5s peak 6.73 GiB Int8Tensor LPIPS 0.06415 against 13.25 GiB dense, so roughly half. The renders are not merely close to the in-memory quantize, they are BYTE-IDENTICAL to it across all 16 prompts, which is the evidence that the safetensors round-trip loses nothing between the builder and a user's machine. QwenImage21Pipeline is registered against diffusers 0.41.0, the first release that can carry it: 2.1 merged upstream on 2026-09-18, four weeks after 0.40.0 was cut. _version_tuple stops at the first non-numeric part, so a 0.41.0.dev0 build from main reads as (0, 41, 0) and satisfies the same entry. * Prefer safetensors over the pickle for every pre-quant repo The first commit made safetensors possible; this makes it the default. The name a repo is asked for is now a CHAIN, best first: <Model>-<SCHEME>.safetensors (new, preferred) <Model>-<SCHEME>.pt (what is hosted today) transformer_<scheme>.pt (legacy) Deriving the preference rather than declaring it per family means a repo that gains a safetensors sibling is picked up with no code change, and a repo that never does keeps resolving exactly what it resolves today, because the pickle spellings stay in the chain behind it. Existing repos are unaffected: unsloth/Qwen-Image-FP8 still resolves Qwen-Image-FP8.pt and transformer_fp8.pt, and a .pt name still routes to the pickle reader and its constructor allowlist. PrequantSource grows fallback_filenames plus a candidate_filenames property, so the downloader, the cache probe and the planner read one ordered list instead of three hand-maintained pairs. fallback_filename stays as a property returning the first, because callers outside this module read it by name. Two things had to change with it, and both would have been silent regressions: cached_checkpoint_path credited ONLY the primary name. That was right while the primary was the only name a repo realistically hosted. With the chain leading on a safetensors name that no repo hosts yet, it would have reported every existing .pt repo as "this would have to download several GB" and handed the pick to the GGUF while the checkpoint sat in the cache. It now walks the chain in order, which keeps the property that motivated primary-only: the better name still wins whenever it is actually present. usable_prequant_source would have turned optimistic. Every family now derives a safetensors candidate, so "is any candidate readable" answers yes even on an install that cannot open a pickle at all, for a repo that only has .pt. Planning would budget a 6 GB artifact, the fetch would 404 down to the pickle, the pickle would be refused, and the load would fall back to dense under a plan that never budgeted it -- the evict-then-OOM that function exists to prevent. A DERIVED safetensors name is a guess, so it now counts only with evidence: the family declared it, or it is already cached. PrequantSource records which names were declared so the two can be told apart. candidate_filenames_of() reads the chain off anything shaped like a source, because planning passes lightweight stand-ins carrying only filename and fallback_filename; reading the property directly turned one of those into an AttributeError swallowed into "no prequant plan" and a silent dense fallback. 1171 tests pass. The suites that encoded the old two-name contract are updated rather than deleted, including the one that asserted primary-only caching, whose comment now records why that rule changed. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Let an install opt in to a pinned Diffusers main build Qwen-Image-2.1 merged upstream on 2026-09-18, four weeks after 0.40.0 was cut, so 0.41.0 is the first release that can carry it and there is nothing on PyPI that works. Without this the only way to try it is to break the release pin by hand. diffusers-pin.txt is untouched. It is the single source of truth for the release everything is built against, and it deliberately refuses a source build so installs stay reproducible and keep working behind a PyPI mirror with no route to github.com. Both properties are worth more than shipping one model early, so the default install is exactly what it was and this is something you ask for with UNSLOTH_DIFFUSERS_MAIN=1. A COMMIT, not a branch, because nothing in Unsloth can tell two builds of main apart: a git checkout reports 0.41.0.dev0 whatever it was built from, and _version_tuple truncates that to (0, 41, 0), so the family version gate reads any main build as satisfying 0.41.0. The commit is the only thing actually pinning behaviour. It is also cheaper to check: for a full SHA _direct_reference_is_installed compares what direct_url.json recorded and needs no network at all, while a branch ref costs a git ls-remote every pass. The pinned commit is the tree the Qwen-Image-2.1 FP8 and INT8 artifacts were built and measured against, so what an opting-in user gets is what was tested. Three things the ordinary _skip_step path does not cover, each handled: - A version says nothing here, so satisfaction is read off direct_url.json. Exercised against the real check: installed at the pinned SHA is satisfied, installed from main with the same commit_id is NOT (the recorded ref differs), an older SHA is not, and a released wheel with no vcs_info is not. No ls-remote is attempted for a SHA. - Diffusers is mandatory, unlike triton_kernels, so a host with no working git must not be left broken. It is not: the release pin ran first and is already in place, so the step declines and says why rather than failing the install. - The step runs immediately AFTER the release pin, or the release would overwrite it. The test compares call sites rather than filenames, because the helper is defined earlier in the file than either install and a filename compare would pass by accident. Retiring it is one line: bump diffusers-pin.txt to 0.41.0 and delete the file. The family entry already records 0.41.0 as QwenImage21Pipeline's minimum. tests/studio/install: 6878 passed. Two failures in test_install_manifest.py are pre-existing and fail identically on main. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Install the pinned Diffusers main build by default Qwen-Image-2.1 needs a Diffusers no release carries yet, and behind a flag that means nobody gets it. This flips UNSLOTH_DIFFUSERS_MAIN: the pinned commit installs by default, and UNSLOTH_DIFFUSERS_MAIN=0 (also false/no/off) opts out. Unset means yes, so a typo in the variable name cannot silently take a model away. The release pin is still installed first and diffusers-main.txt is still a separate file rather than an edit to it. That separation is what makes running by default safe: the release lands and stays resident, so the main build is only ever an upgrade on top of a working install. The step therefore uses pip_install_try, not pip_install. pip_install exits the installer on failure, which as an opt-in cost the few people who asked for it and as a default would make a reachable github.com a hard requirement of installing Unsloth: a PyPI mirror with no route out, a proxy blocking git over https, or an upstream outage would each turn a working install into no install. It now degrades to the release with a note naming the opt-out, the same way the no-git path already did. pip_install_try gains req=, routed through _effective_requirements exactly as pip_install does, so a file installed through either entry point is the file the install-manifest gate audits. One thing the flip exposed: the step spends a progress slot, and an early return without a _progress left the bar short of its own total for anyone who opted out. It now emits exactly one _progress on every branch, opting out included, and base_total counts it unconditionally. That moved 25 hard-coded step totals in test_rocm_support.py, test_windows_torch_flavor_invariant.py and test_mlx_install.py. tests/studio/install: 6880 passed. The two remaining test_install_manifest.py failures are pre-existing and fail identically on main. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Ask whether a pre-quant name is readable, not just whether it exists Three places treated the container as settled once the name resolved. The Windows ROCm torchao stub answers every torchao.* import with a fabricated callable, so importing the flatten/unflatten pair succeeded there and reported safetensors support on an install whose unflatten returns None. Planning would drop the dense shards for a checkpoint the loader can never rebuild. The pickle probe already asked is_stubbed; the safetensors one now does too. The download plan committed to the first candidate the repo HELD, which is no longer the same question as the first it can OPEN now that the chain spans two containers. A repo still serving only the legacy pickle, met by an install that cannot restrict that load, spent the download and then refused it with no dense weights left. It now skips a name it cannot read and reports the miss, which keeps the shards in the pull. An explicit --upload-filename skipped the container check as well as the family table, so a safetensors build could be published under .pt and a pickle under .safetensors. Both upload cleanly and neither can ever be opened, after the hours the quantization took. Also updates the Qwen-Image-2512 filename test, which pinned the single derived name and now asserts the whole chain: safetensors first, the .pt the repo actually serves still in it, the legacy spelling last. * Let the release pin stand down once the pinned main build is resident The release pin is a version pin and every build of main reports 0.41.0.dev0, so diffusers==0.40.0 never reads as satisfied once the commit is in place. Left alone the release step reinstalled the release on every pass and the step after it put the same commit back on top, so no update was ever a no-op: the idempotency suite caught it on Linux, Windows and macOS alike, with diffusers the single distribution a second, changeless update rewrote. Offline it is worse than wasteful. The downgrade is a local resolve and lands; the restore needs github.com and cannot, so an update that had a working pinned build ends without one. _skip_step grows a superseded flag for this: the requirement really is unsatisfied, and must still not run, because running it undoes the step that supersedes it. The gate is deliberately narrow, wanted AND already resident, so opting out still reinstates the release and a first install still lays it down before the commit goes on top, which is what a failed source build degrades to. The slot is spent either way, so the progress total is unchanged. Also merges the base PR and main. * Make the runtime resolver and the cache probe ask the readability question too The plan learned to skip a candidate this install cannot open; the two places that answer alongside it did not, and an asymmetry there is worse than the original gap. _resolve_checkpoint_path took the first name the repo HELD. On a repo hosting both containers the plan would stage the readable one while this fetched the other, spending a second multi-gigabyte download to fail on it and then falling back to dense weights the plan had already left out. It now filters the chain with the same per-filename check, and only when that leaves something, so a source that should never have been offered still reaches the loader's refusal rather than a silent None. cached_checkpoint_path walks every candidate, so a cached legacy pickle satisfied the declared-or-cached evidence gate for an install that cannot open one. The probe is now scoped to the readable names: a cached .pt is a real hit for sizing and a non-answer for this question, and only the caller knows which is being asked. * Require the pinned main build to be on disk, not just recorded direct_url.json survives inside dist-info while the package tree under it is deleted or truncated, so a provenance-only check reported the build as satisfied when it was not there. The release pin reads the same predicate to decide it has been superseded, so that answer skipped the reinstall AND the repair, on a mandatory dependency, on every later pass rather than one: Studio would stay broken. _diffusers_main_resident pairs the ref check with _payload_recorded_intact, exactly as the triton kernels step already does, and either half failing means install it, which is the recoverable direction. * Let a plain safetensors build use the name the loader now asks for first The refusal predates the derived chain. upload_destination rejected a safetensors build for any family with no prequant_filenames entry, on the reasoning that every derived name ends in .pt so nothing would ever ask the Hub for the artifact. derived_prequant_filenames now puts <Model>-<SCHEME>.safetensors ahead of both .pt spellings, so the reachability that refusal was protecting is exactly what the chain supplies, and the builder was making every such family compute and pass an override it could derive itself. Derived from --upload-repo, and the test reads the expected name back out of the resolver rather than restating it, so the two cannot drift. A ROTATED build still refuses: no derived spelling carries the marker, which is the other half of why the refusal exists. * Make the Qwen-Image-2.1 family actually loadable, and stop clinging to 3.9 The family entry shipped inert. Detection resolved it and the version gate passed once the pinned main build was in, and then validate_load_request refused it as a non-unsloth repo, because _TRUSTED_NON_GGUF_REPOS is a separate list that the base was never added to. Every non-GGUF pick of Qwen-Image-2.1 died with "Non-GGUF diffusion loads are restricted to unsloth/* repos". Two tests now cover it: the specific chain a picker walks for this family, and the general one, that no family may declare a base repo validate_load_request refuses, so the next family cannot ship inert the same way. The main-build step also stands down below Python 3.10. The release pin file still names 0.36.0 there, so 3.9 is a supported install, while Diffusers main declares requires-python 3.10: unmarked, pip clones the repository and only then rejects it, and since the build can never become resident that clone repeats on every install and update forever. The slot is still spent, so the progress total is unchanged. Also fixes the satisfied-build test, which mocked provenance but not the payload check added alongside it, so a test environment with no installed Diffusers payload fell through to the failing stub. * Give Qwen-Image-2.1 a size the auto policy can plan against Without a row in the bf16 component table estimate_dense_quant returns None, so resolve_dense_quant_candidate returns None, so a pipeline pick has nothing to seed its denoiser from and downloads the dense transformer: exactly the download the family's prequant_repos rows exist to avoid, and only on the lower-memory cards that need them most. The family entry looks complete on its own, which is why this was invisible from it. Read off Qwen/Qwen-Image-2.1's own sibling metadata rather than copied from Qwen-Image, which would be wrong in both directions at once: the DiT is 14.2 GB against 40.9 (32 single-stream blocks, not 60 dual-stream) while the Qwen3-VL 8B encoder is LARGER at 17.5 against 16.6. Ships bf16, so resident equals on-disk. The general test is the one that matters: no family may declare hosted pre-quant checkpoints the auto policy cannot size. * Check the declared upload name against the container in both directions The family-derived name was compared against the container only when the build was safetensors, so the reverse mismatch went through: a rotated pickle build for a family whose prequant_filenames entry ends in .safetensors returned that name, and torch.save bytes would be published under it. Every loader dispatches on the extension, hands the file to safe_open and rejects it, so the artifact is unopenable for a reason that points nowhere near the real mistake. Reachable as soon as a family moves its entry to a safetensors artifact, which is exactly what the Qwen-Image-2.1 family does: upload_destination(fam, 'fp8', rotated=True, safetensors=False) -> 'Qwen-Image-2.1-FP8.safetensors' One symmetric check now covers both directions, with the message naming the container --out writes and the extension the declared name carries. Tests cover each direction. * Count the second requirements-file installer in the shared-filter invariant pip_install_try now installs a requirements file too, and it goes through _effective_requirements like pip_install does, which is the point of the invariant: every path that installs or reasons about a requirements file filters it the same way. The test pinned the number of call sites at three, so the fourth SHARED one read as a violation. The count stays as the check's teeth, with the docstring saying why four is the invariant holding rather than loosening: a caller that grew its own filtering would still surface here. * Do not blame the last candidate for an unreachable Hub LocalEntryNotFoundError subclasses EntryNotFoundError, so walking the candidate chain under the base caught an unreachable Hub as if the name were absent: three download attempts instead of one, and the error surfaced was the last candidate's 404 rather than the connection failure. Online it now re-raises as itself; offline, where a cache miss is the only verdict there is, the chain is still walked. * Never count a cached name this install cannot open, and probe the scheme before the build Two gaps with the same shape: a check that passes, then a failure after the expensive part. A cached .safetensors on a host without torchao's flatten helpers was a cache hit, so planning committed to the prequant and dropped the dense shards, while the resolver filtered that very file out and found the other name uncached. The narrowing that fixed the opposite direction only reached the one caller that passed names=readable. Readability is now asked per name in the walk itself, so every caller gets it, and the lookup still never raises. The builder's safetensors preflight asked whether the helpers import, which is not whether this scheme produces something they take: through torchao 0.17 int8 quantises to LinearActivationQuantizedTensor and flatten refuses it, so the build failed after the download and the hours of GPU quantization. Probed on one tiny CPU Linear instead, with an unprobeable config treated as no evidence. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Let the escape hatch reach the diffusers steps, and stop prescribing a release that does not exist Three things this family entry got wrong once it started installing a build of main by default. UNSLOTH_STUDIO_FULL_DEPS could not repair Diffusers: the main step skipped on resident evidence the hatch exists to override, and the release pin read as superseded behind it, so a same-size payload corruption survived both. Both now run under the hatch, release first. The refusal for a class needing 0.41.0 told the user to run pip install -U 'diffusers>=0.41.0', which has no candidate while 0.41.0 is unreleased. It now names the pinned main build Studio actually installs. --base-model-id validated with the loader's tail-tolerant comparison, which is right for a local mirror directory and wrong for what a published file CLAIMS to be: other/Qwen-Image-2.1 passed it. It now has to be the canonical id, and the check moved ahead of the transformer class lookup so it lands in a second. * Qwen-Image-2.1 takes reference images, so say so The family was registered as plain text-to-image, which refuses reference images outright. Upstream ships one unified pipeline: QwenImage21Pipeline.__call__ takes image as optional condition images beside the prompt, the encoder reads each as vision context and the VAE prepends latent tokens to the noise, and there is no strength and no separate img2img or inpaint class. That is the FLUX.2 shape, so reference rather than edit, which would mean the pipeline IS the edit pipeline and would demand an input image for every generation. * Put Qwen-Image-2.1 in the image model picker The family is only reachable by pasting a repo id: IMAGE_CATALOG is a static list and 2.1 was never in it, so everything this branch wires up (the pipeline, the pre-cast FP8/INT8 denoiser, the pre-cast Qwen3-VL encoder) shipped with no way to pick it. One group, bf16 pipeline row only, with the FP8 repo aliased so a pasted id lands on it the way the 2512 row does. No GGUF row here: that route needs the sd.cpp VAE and encoder wiring, which is a separate branch. The check asserts the thing that is easy to get wrong with a dotted version: every 2.1 repo groups on 2.1 and none of them falls back to plain Qwen-Image, whose stripped key is a prefix of theirs. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…i#11573) (Python 3.13, a-k) fails the same four tests on every PR. Bisected on main with the GPU hidden, as on the runner; each is a test that stopped describing the product, not a product regression: - test_download_plan_counts_a_cached_lower_auto_prequant, since unslothai#11394. The plan now skips a pre-quant name this install cannot open, and torchao 0.18, which the shard installs unpinned, has no int8 pickle constructors. The test offers only Qwen-Image-INT8.pt. It now pins the readability answer and also asserts the converse: an unreadable artifact is not budgeted. - test_every_third_party_bf16_pipeline_the_catalog_offers_is_mirrored, since unslothai#11405 offered Qwen/Qwen-Image-2.1. unsloth/Qwen-Image-2.1 is not on the Hub, so a mirror row would 404 every fetch it redirects. Named as a pending mirror that fails once the row lands or the catalog drops it. - test_the_recorded_base_must_be_the_canonical_id_not_just_the_same_tail, added by unslothai#11405. build_prequant_checkpoint.main imports diffusers before reading an argument and the shard has no diffusers. An empty stand-in when it is absent; the refusal lands before any diffusers attribute is read. - test_qwen_image_21_gguf_reaches_sd_cpp_with_its_own_vae_and_a_qwen3vl_encoder, since unslothai#11542 moved the encoder to UD-Q4_K_XL on purpose and pins that name in its own test. This one now reads the declared name and keeps its own claim, that the file is a 4-bit GGUF.
…s unmet (unslothai#11578) * Compare a full pass to a skipping one without the click both record as unmet Unsloth Update CI has failed on Linux and macOS since unslothai#11405 (last success 12:04Z): test_full_deps_forces_every_step_and_still_changes_nothing and test_the_install_is_left_working see click 8.5.0 against 8.3.0 and nothing else. sqlfluff<4 caps click at 8.3.0 and huggingface-hub 1.23+ needs 8.4.2, so click lands wherever the last step that resolved it put it. unslothai#11405 added Diffusers main as a direct reference after the data-designer deps; installing it re-resolves hub's closure. install.sh and a full-deps pass run it (8.5.0); the settle run re-ran data-designer deps and skipped it (8.3.0). The update logs in the run's studio-update-log artifact show exactly that. A distribution both manifests record as known_unmet is now set aside. It must still be installed on both sides, and every other name and version must match. * Trust known_unmet only against the installed set it was written for The installer reads the record only when known_unmet_index matches the current installed-set digest, and so should the test: a stale record could otherwise set aside a distribution a later step moved. snapshot() now computes that digest in the venv with the installer's own installed_dependency_index, hashed as _installed_index_digest hashes it; a record whose index does not match names nothing. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Count records per name before setting a known_unmet version aside A set of names collapses a second metadata record for an exempted distribution (a pip backup the installer's index skips, a duplicate dist-info), and the version filter then hides it. Compare per-name counts instead, so an extra or missing record fails even for a known_unmet name. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…ffusers main build needs (unslothai#11625) * Unsloth Studio: raise the huggingface_hub floor to what the pinned Diffusers main build needs diffusers reads httpx out of huggingface_hub.utils, a forwarding shim that only exists from hub 1.31, and it does so in utils/hub_utils.py, so plain `import diffusers` fails on an older hub and every model on the diffusers engine is unreachable, not just Qwen-Image-2.1. The pinned main build declares huggingface-hub>=1.31.0,<2.0. Unsloth declared >=1.23.0, which was the floor the diffusers RELEASE wanted; unslothai#11405 pinned a main commit with a higher floor and left this one behind. Anything resolved into the gap satisfies Unsloth, breaks diffusers, and nothing in the install says so. * Correct the list of files that carry the hub floor base.txt has never declared huggingface_hub. The fifth place that moved to the 1.x window is the studio extra in pyproject.toml. * Shorten the hub floor comment in the macOS arm64 overrides --------- Co-authored-by: Daniel Han <[email protected]>
…nothing else (unslothai#11751) * Clean-machine trace leg: let git fetch the pinned git+ requirements, nothing else A default install with a working git clones the pinned Diffusers main build through uv (unslothai#11405 made it the default; a clone records a ref, the archive fallback does not). The macOS trace / file leg's notools check rejected every git line, so the first installer PR to run that leg since then went red. notools now takes UNSLOTH_ALLOW_GIT_FROM, a list of requirement files. Each git line may name only their git+ remotes, remoteless lines (uv's rev-parse, reset, clone --local in its cache) count only when an allowed remote was fetched, and git --version is the installer's probe. Any other remote, a compiler or brew is still a hit, and with the variable unset nothing changes. tests/sh/test_clean_machine_notools_pinned_git.sh replays the trace that leg recorded and covers the rejections. * notools: allow remoteless git only in uv's exact cache shapes One allowed fetch enabled every URL-free git line for the whole trace, so `git fetch origin` (its URL comes from config) or a clone between arbitrary local paths passed beside it. A remoteless line must now be init, rev-parse, submodule update --recursive --init, reset --hard to a pinned commit, or clone --local from $UV_CACHE_DIR/git-v0/db to $UV_CACHE_DIR/git-v0/checkouts. A line naming a remote may carry no -c except remote.origin.url=. * notools: a git line naming a remote must only read from it Any subcommand that named the pinned remote passed, push included. The line must now be fetch, ls-remote or submodule update (uv's shapes), with no -c anywhere except the leading remote.origin.url= pair. * notools: read a remote-naming git line as git reads its argv Any URL-looking substring counted as the repository, so an option value (fetch --all --server-option=URL) passed, and also counted as the allowed fetch that unlocks uv's cache operations. A remote-naming line must now be uv's fetch shape (known options, then the allowed repository, then only src:refs/ refspecs) or -c remote.origin.url=URL submodule update with only --init/--recursive. ls-remote is no longer accepted; uv does not use it. * notools: accept a submodule update only inside uv's checkout git submodule update fetches whatever the current checkout's .gitmodules names, and the trace recorded argv only, so the same command in any other repository passed. The trace git wrapper now also records its working directory beside the trace, and both submodule update shapes count only when every run with those arguments was under $UV_CACHE_DIR/git-v0/checkouts. No record fails closed, and the verify step checks the wrapper writes one. * notools: take the reset commit from uv's checkout, not this checkout's pin The macOS trace legs run overlay-free, so the installer and its requirement files come from the released wheel, which can pin an older Diffusers commit than this checkout's diffusers-main.txt. The reset to that commit was then a hit. uv names each checkout directory after the short commit it installs, so reset --hard now needs a full 40-hex commit, run in a uv checkout whose name it starts with. The remote allowance still reads the requirement file. * notools: scope init and rev-parse to uv's cache; read the pin after the last @ A bare git init or rev-parse passed wherever it ran. Both now count only when every run was under $UV_CACHE_DIR/git-v0, where uv keeps its database and checkouts. The allowed remote stopped at the first @, so an ssh requirement (ssh://git@host/repo.git@SHA) allowed only ssh://git and rejected its own fetch. The revision is now what follows the last @. * Clean-machine trace leg: allow the installed package's git+ remote too The overlay-free trace legs install the released wheel, so a checkout that repins Diffusers to another repository before a release would reject the installed package's legitimate fetch. The assert step now also passes the installed package's diffusers-main.txt from the managed venv, and notools allows the union of both files' remotes. * Clean-machine trace leg: read the git+ allowance from the installed package alone Adding the installed copy to the checkout's pin allowed both repositories, so a checkout-only remote fetched by mistake would still pass. The installed package's diffusers-main.txt now replaces the checkout's; the checkout's is a fallback, with a warning, only when the managed venv has none. * notools: the reset commit must be the one the installed package pins A reset to any commit passed as long as uv's checkout was named after it. Now that the workflow passes the installed package's own diffusers-main.txt, reset --hard must also name exactly the 40-hex commit it pins. * clean-machine-env.sh: start the git working-directory record empty The trace was truncated at setup but the .git-cwd record was only appended to, so a second trace with the same CLEAN_MACHINE_DIR judged the new install by an older one's rows. It is now truncated with the trace. The shell test runs trace setup twice for real and checks the wrapper records where git ran and that a new trace starts the record empty.
unslothai#11759) Without the Command Line Tools, Apple Silicon's /usr/bin/git is a shim, and running it (even git --version) raises the "install the command line developer tools" dialog. install.sh's _has_working_git answers from the path there; install_python_stack.py's ran the shim unconditionally. That was harmless while only the triton step, skipped on macOS, asked, but since the pinned Diffusers main build became the default (unslothai#11405) every macOS install asks, so a Mac without the CLT got the dialog mid-install. The Python probe now mirrors install.sh: on Apple Silicon hardware (Rosetta included, via hw.optional.arm64), a git that resolves to exactly /usr/bin/git with no toolchain selected (xcode-select -p fails) is answered as missing without running it. Homebrew, Xcode.app and Intel Mac gits are still run.
Stacked on #11394, which adds the safetensors pre-quant container this uses. Review that one first.
Qwen-Image-2.1 is a different architecture, not a refreshed Qwen-Image checkpoint, so it gets its own family rather than a
prequant_variant_reposrow: 32 single-stream blocks against 60 dual-stream MMDiT ones, nine weights per block, zero bias tensors anywhere, one global modulation projection, a Qwen3-VL text encoder and its own VAE class. Sharing theqwen-imageentry would hand it that family's pipeline, transformer, VAE and exclusion rules, none of which fit.The int8 exclusions are measured, not inherited
Six arms rendered the 16-prompt calibration set at 1024 and were scored against the bf16 reference, paired per prompt. The bf16-on-the-same-GPU control scored exactly 0.00000 LPIPS, so the pairing carries no device confound.
txt_inexcludedmodulationincludedtxt_inexcludedmodulationexcludedOnly
txt_insurvives as a real lever, and only for int8: -0.03901 against the generic tokens, CI95 [-0.07081, -0.00722], better on 14 of 16 prompts. It is a quality lever here and not the small-M crash guard it is onqwen-image: every arm rendered a deliberately two-token prompt without tripping_int_mm's M floor.The two levers that did not survive are recorded as such rather than shipped. Excluding
modulation.1under fp8 is +0.01810, CI95 [-0.01619, +0.05239]. Removing int8's inheritedmodulationexclusion is -0.00941, CI95 [-0.02175, +0.00292]. The one global tensor every block reads is simply not unusually sensitive on this architecture, in either direction, so fp8 keeps the runtime default and adds no special case. One cell of the grid is untested,txt_inexcluded andmodulationincluded; given modulation was null on both schemes I do not expect it to matter, and I would rather say so than imply it was covered.Artifacts, built and verified
Loaded in a fresh process through
load_prequantized_transformer, which runs the real format, scheme,base_model_id,min_features,fast_accumand fp8 activation-floor checks:against 13.25 GiB dense, so roughly half. The renders are not merely close to the in-memory quantize, they are byte-identical to it across all 16 prompts (SHA-256 per PNG), which is the evidence that the safetensors round-trip loses nothing between the builder and a user's machine.
build_prequant_checkpoint.pygains--base-model-id, for building from weights staged in a local directory. The loader compares final path segments, so an artifact built from./temp/qwen_image_21records a base whose tail isqwen_image_21, a load asking forQwen/Qwen-Image-2.1sees different tails, and a good artifact is refused after the dense shards were already dropped. The override is pinned to the family's ownbase_repo, so it can only ever name the model that family is for.Getting the Diffusers it needs
2.1 merged upstream on 2026-09-18, four weeks after 0.40.0 was cut, so no released diffusers has it and 0.41.0 is the first that can.
studio/backend/requirements/diffusers-main.txtpins that commit and is installed by default.UNSLOTH_DIFFUSERS_MAIN=0(also false/no/off) opts out; unset means yes, so a typo in the variable name cannot silently take a model away.diffusers-pin.txtis untouched and still runs first. Keeping them as two files is what makes running by default safe rather than a cosmetic split: the release lands and stays resident, so the main build is only ever an upgrade on top of an install that already works. Folding the commit into the pin would make a reachable github.com a hard requirement of installing Unsloth at all.For the same reason the step calls
pip_install_try, notpip_install.pip_installexits the installer on failure, which as an opt-in cost only the people who asked for it, and as a default would turn a PyPI mirror with no route out, a proxy blocking git over https, or an afternoon of upstream downtime into no install. It now degrades to the release with a note naming the opt-out, the same way the no-git path already did.pip_install_trygainsreq=, routed through_effective_requirementsexactly aspip_installdoes, so a file installed through either entry point is the file the install-manifest gate audits.A commit, not a branch, because nothing here can tell two builds of main apart: a git checkout reports
0.41.0.dev0whatever it came from, and_version_tupletruncates that to(0, 41, 0), so the family version gate reads any main build as satisfying 0.41.0. The commit is the only thing actually pinning behaviour, and on by default that matters more, not less: everyone lands on the same tree, and it is the tree these artifacts were measured against. It is also cheaper: for a full SHA_direct_reference_is_installedreadsdirect_url.jsonand needs no network, while a branch ref would cost agit ls-remoteon every pass of every install.Exercised against the real check rather than assumed:
and no
ls-remoteis attempted for a SHA. A version comparison would have answered True to all four, which is exactly why bumping the pin has to reinstall offdirect_url.json.One thing the flip exposed. The step spends a progress slot, and an early return without a
_progressleft the bar short of its own total for precisely the users who opted out. It now emits exactly one_progresson every branch, opting out included, andbase_totalcounts it unconditionally. That moved 25 hard-coded step totals acrosstest_rocm_support.py,test_windows_torch_flavor_invariant.pyandtest_mlx_install.py.Retiring the whole thing is one line once 0.41.0 ships: bump the pin and delete the file, since the family already records 0.41.0 as
QwenImage21Pipeline's minimum.Tests
tests/studio/install: 6880 passed. Backend prequant, family, builder and auto-policy suites: 817 passed. The failures on this box (two intest_install_manifest.py, one intest_diffusion_more_families.py) are pre-existing and fail identically onmain, which I checked rather than assumed.The picker row
The family was reachable only by pasting a repo id:
IMAGE_CATALOGis a static list and 2.1 was never in it, so everything here shipped with no way to select it. One group is added, bf16 pipeline row only, with the FP8 repo aliased the way the 2512 row does it. The GGUF row belongs on the sd.cpp branch, where the wiring it needs lives.Measured on a CUDA host against this PR's merge base (11394's branch, not
main, so the pair isolates this change): option count 31 to 32, and the new row readsQwen-Image 2.1 (Fast FP8) 7.1B, which is the host's dense-quant ladder answering for the new family. TheQwen-Image 2512andQwen-Imagerows are unchanged in text, badge and size, which is the control worth having: those ids share a prefix with the new ones.Qwen-Image 2.1 (Fast FP8), 7.1BArtifacts
unsloth/Qwen-Image-2.1-FP8andunsloth/Qwen-Image-2.1-GGUFare published and public. The FP8 repo carries the INT8 and FP8 denoisers and the pre-cast Qwen3-VL text encoder; anonymous reads of both were checked rather than assumed.