Skip to content

Studio: CPU-only devices run image and video models as GGUFs on sd.cpp only - #18444

Merged
danielhanchen merged 8 commits into
mainfrom
studio-cpu-gguf-stays-native
Nov 20, 2026
Merged

danielhanchen merged 8 commits into
mainfrom
studio-cpu-gguf-stays-native

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Problem

On a CPU-only device, the Model hub plans a GGUF image download for the native sd.cpp engine. For FLUX.3 klein UD-Q2_K_XL that is the GGUF (2.62 GB), the VAE (0.34 GB) and Qwen3-VL-4B-Instruct-Q8_0.gguf (4.28 GB), 7.24 GB in all.

If sd.cpp cannot start at load time, the router silently fell back to diffusers. The fallback fetched the dense bf16 Qwen3-VL-4B text encoder and configs inline (11.84 GB, 8.89 GB of it new), ignored the GGUF encoder the hub had just fetched, and ran on PyTorch CPU. Every catalog GGUF image family has the same gap; MiniMax-H3-Image is the worst at 151 GB against a 34 GB native plan.

The picker also offered non-GGUF rows on CPU. Examples are the FLUX.3 klein row labelled "Fast FP8" on a GPU, and the FP8, INT8 and bnb rows. On CPU they load bf16 on PyTorch: the FLUX.3 klein pipeline row alone is a 20.32 GB plan, which does not fit a 16 GB machine.

Change

The rule: on a CPU-only device, image and video models of a family with a GGUF route run as GGUFs on sd.cpp only.

Backend:

  • An automatic, explicit-Diffusers or env-forced diffusers load of a GGUF in an sd.cpp family is refused. So is a failed native start. Each refusal comes before the current model unloads.
  • Pipeline and single-file image loads of a family with an sd.cpp route are refused too. That covers /images/download-plan, /images/load and the hub's required-files plan, so nothing large is downloaded.
  • Video refuses non-GGUF picks for the families with a curated GGUF row: LTX-2.3, LTX-2.5 and MiniMax-H3.
  • The refusal says what the native start or install check found:
    • the installer could not be imported;
    • the engine folder is in use;
    • the build already recorded as unable to run;
    • the exec error, or the Windows loader status, for which it suggests deleting the engine folder so it reinstalls, then repairing the Visual C++ Redistributable;
    • a download failure;
    • an old build;
    • auto-install turned off.
  • The only way out is UNSLOTH_DIFFUSION_CPU_GGUF_DIFFUSERS_FALLBACK=1, for developers.

Frontend:

  • classifyHost returns a new cpu-only class for a plain CPU backend. A Mac keeps gguf-only, so its rows are unchanged.
  • On cpu-only, curatedArtifactIsOfferable drops every non-GGUF row of an image or video group that has a GGUF row. The Images and Video tab rows and the picker browse rows follow the same rule.
  • /images/status reports gguf_diffusers_allowed. When it is false, the Images Advanced Engine select drops Diffusers, and a remembered Diffusers pick is sent as Auto.
  • Krea 2 has an sd.cpp route but no curated GGUF row yet, so it has no row on CPU until one is added.
  • Families with no GGUF route keep their current rows on CPU:
    • images: SDXL Turbo, SDXL base, Lumina-Image-2.0, HiDream-I1, HunyuanImage-2.1, Ideogram 4;
    • video: Wan2.2 TI2V-5B and A14B, Wan2.1, HunyuanVideo-1.5, Cosmos3, LTX-2.

GPU devices and MPS are unchanged.

Tests

  • Dry run on a CPU host, using the real router and planner with only the "sd.cpp runnable" check mocked and nothing downloaded:
    • FLUX.3 klein GGUF: main plans 7.24 GB, then the load falls back and fetches 8.89 GB more. This PR plans the same and refuses before any download.
    • FLUX.3 klein bf16 pipeline (20.32 GB) and LTX-2.5 Diffusers: main accepts both, this PR refuses both before any download.
  • Backend, 34 router, sd.cpp, route and video files: the new rule's tests fail on main and pass here. The 38 other failures are the same on both sides (no gguf module and a diffusers import error in the test venv). Two tests read model-catalog.ts and check that the backend refuses exactly what the picker hides.
  • Frontend: host-artifact-policy.test.ts 21/21, the engine-choice tests 24/24, model-catalog.check.ts and tsc --noEmit pass.

Not run: a real Windows or macOS machine.

Screenshots

Two Studio installs from this PR's base and head on a CPU-only host (device_backend: cpu on both). In the unfiltered picker the image rows go from 44 to 27; SDXL, which has no GGUF route, keeps its 2 rows.

FLUX.3: the two BF16 rows are gone; only the two GGUF rows are offered.

FLUX.3 rows on a CPU-only host

Z-Image: the BF16 and bnb-4bit Z-Image-Turbo rows are gone; Z-Image-Turbo-GGUF and Z-Image-GGUF remain.

Z-Image rows on a CPU-only host

Krea 2: the BF16 Krea 2 Turbo row is hidden (sd.cpp runs Krea 2 GGUFs, and there is no curated GGUF row yet).

Krea 2 rows on a CPU-only host

…diffusers fallback

On a CPU-only torch the Hub plan stages a GGUF's native files (GGUF + VAE +
GGUF text encoder), but when the sd.cpp build could not be installed or run
at load time the router fell back to diffusers, which then downloaded the
dense bf16 text encoder inline. For FLUX.3 Klein UD-Q2_K_XL that is 7.2 GB
staged and 11.8 GB opened (8.9 GB new), to run on PyTorch CPU.

An automatic GGUF load of a natively mapped family on a CPU torch is now
refused with the native reason before anything unloads, and the plan
refuses the same pick. An explicit Diffusers engine pick,
UNSLOTH_DIFFUSION_ENGINE=diffusers, UNSLOTH_DIFFUSION_SD_CPP=0 and the new
UNSLOTH_DIFFUSION_CPU_GGUF_DIFFUSERS_FALLBACK=1 still reach diffusers.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T20:44:02.687951Z 402ed26 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 1b8593f544

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

A GGUF image load of a family sd.cpp supports on a CPU-only torch now runs
on the native engine only. An explicit Diffusers pick, the
UNSLOTH_DIFFUSION_ENGINE=diffusers pin and UNSLOTH_DIFFUSION_SD_CPP=0 are
refused for it too, in the load and in the download plan, so the dense
diffusers set is never staged. Only the developer switch
UNSLOTH_DIFFUSION_CPU_GGUF_DIFFUSERS_FALLBACK=1 restores the diffusers route.

The refusal now says what failed and how to fix it. The sd.cpp start probe
records why a build could not start: a Windows loader status
(STATUS_DLL_NOT_FOUND and friends) names the Microsoft Visual C++
Redistributable, since the win-cpu-x64 build imports MSVCP140, VCRUNTIME140
and VCOMP140; a failed prebuilt download names the network; an old build
names the reinstall.

The Images page hides the Diffusers engine choice on a CPU-only host
(status gguf_diffusers_allowed=false) and never sends a remembered one.
…UF route

The picker classified a CPU host as gguf-only but only used that to drop the
MiniMax-H3 pipeline, so a CPU-only device still listed the FP8 / INT8 /
bnb rows and the bf16 pipeline row that a GPU labels Fast FP8, which loads
20.3 GB of bf16 for FLUX.3 Klein on torch CPU.

classifyHost now returns cpu-only for a plain CPU backend (a Mac stays
gguf-only), and curatedArtifactIsOfferable drops every non-GGUF row of an
image or video group that has a GGUF row (or a native route with no curated
GGUF, Krea 2) there. The backend refuses the same picks: image pipeline and
single-file loads of a family with an sd.cpp route, and video loads of a
family whose GGUF is a curated row, on a CPU-only torch. Families with no
GGUF route keep their rows. The developer switch
UNSLOTH_DIFFUSION_CPU_GGUF_DIFFUSERS_FALLBACK=1 lifts it; the backend test
conftest sets it so GPU-path tests keep running on a CPU test host.

The native-engine refusal reports the probe's own reason (installer import,
install folder in use, a build already recorded as unable to run), and a
Windows loader status points at the engine folder before the Visual C++
runtime.
@danielhanchen danielhanchen changed the title Studio: keep CPU-only GGUF image loads on sd.cpp instead of a silent diffusers fallback Studio: CPU-only devices run image and video models as GGUFs on sd.cpp only Nov 19, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f24d5982b

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

// Modular Diffusers needs mem_get_info, which torch.mps lacks.
if (deviceType === "mac") return "gguf-only";
if (!(backend && budgetKnown)) return "unknown";
if (backend === "cpu") return "cpu-only";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Classify a confirmed CPU backend before the Mac fallback

On a Mac without usable MPS, such as an Intel Mac, the earlier deviceType === "mac" return prevents this CPU classification from running. Consequently, curatedArtifactIsOfferable still offers non-GGUF image and video rows, while the new backend guards reject those same selections because resolve_diffusion_device_target().backend is "cpu". This leaves users with advertised models whose download plans or loads always fail. Check a confirmed CPU backend before the Mac fallback, while retaining gguf-only for actual MPS/MLX hosts.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3feefd0. classifyHost now returns cpu-only for a confirmed cpu backend before the Mac fallback, so an Intel Mac hides the same dense rows the backend refuses there. A Mac reporting mlx, or a backend not known yet, stays gguf-only. The policy tests cover both.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3feefd0f27

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

Comment on lines +502 to +504
repo = str(getattr(fam, "gguf_repo", None) or "").lower()
if kind == "gguf" or repo not in CPU_GGUF_ONLY_VIDEO_REPOS:
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Distinguish LTX-2.0 from LTX-2.3 before refusing dense loads

On a CPU-only host, this also rejects the LTX-2.0 pipeline, which the picker still offers. detect_video_family('Lightricks/LTX-2') resolves to the shared ltx-2 family whose gguf_repo is unsloth/LTX-2.3-GGUF, so checking only that family field incorrectly applies the LTX-2.3 restriction to LTX-2.0. Meanwhile, model-catalog.ts lists Lightricks/LTX-2 in its own group without a GGUF artifact, so the new frontend filter retains it, but both download planning and loading reject it through validate_load_request. Make the refusal distinguish the selected version rather than relying solely on the shared family's GGUF repository.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest push. refuse_cpu_dense_video_pick now takes the pick's repo ids and file name. For the shared ltx-2 family it refuses only when one of them names 2.3 (LTX-2.3, ltx2.3, ltx23). An LTX-2.0 pick (Lightricks/LTX-2, or an ltx-2-19b file) keeps its pipeline row and its load, as the picker shows it. The tests cover both versions and validate_load_request('Lightricks/LTX-2'), which the previous head refused.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@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: 9a89ed537d

ℹ️ 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 pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 19, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 19, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 19, 2026
…rows

Its MLX stack can be unusable while diffusers still runs those rows on MPS, and the backend only refuses dense picks when the diffusion target itself is cpu.
… or MPS probes

resolve_diffusion_device_target() reads the card's compute capability, which initialises CUDA in the server on the first idle poll; the poll only needs to know whether the diffusion target is the CPU.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 402ed26f63

ℹ️ 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 added a commit that referenced this pull request Nov 19, 2026
#18420 (#18536)

## Summary

`Repo tests (CPU, studio)` fails on `main` (seen on #18444):

```
FAILED tests/studio/test_model_picker_contracts.py::test_a_plan_that_lands_after_a_newer_pick_is_dropped
E   AssertionError: features/images/images-page.tsx: a superseded plan is not dropped
```

## Root cause

#18420 added `dropReleasedPick(ownRevert);` to both superseded-plan
guards in `images-page.tsx`'s `loadOrStage`, between
`pickToast.dismiss(pickToastId);` and `return true;`, so a pick released
while it was the newest is cleaned up. The behaviour this test protects
is unchanged: a plan that lands after a newer pick still returns `true`
(started), so its rollback does not fire at the newer pick's label. The
test's regex allowed only the toast dismiss before the `return`, so it
no longer found either guard.

## Changes

- Both regexes in the test now allow plain call statements
(`name(...);`) between the toast dismiss and the `return`, and still
require the guard's condition and `return true` / the fallback-load
ordering exactly as before. One line says why.

Test-only change.

## Testing

- `pytest tests/studio/test_model_picker_contracts.py`: 205 passed (the
test fails on `main`).
- Sabotage: turning the first guard's `return true;` into `return
false;` fails the test ("a superseded pick reports failure").
@danielhanchen
danielhanchen merged commit 64ba576 into main Nov 20, 2026
@danielhanchen
danielhanchen deleted the studio-cpu-gguf-stays-native branch November 20, 2026 02:50
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