Skip to content

Studio loads: recheck fixes for klein 9B KV identity, pinned FLUX.3 cache reads, OOM tile probe, ConvRot-only hosted int8 video - #18982

Merged
danielhanchen merged 9 commits into
mainfrom
studio-recheck-load-fixes
Nov 23, 2026
Merged

danielhanchen merged 9 commits into
mainfrom
studio-recheck-load-fixes

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Four fixes found while re-checking recent Studio image and video load changes, one commit each, plus one test-compat fix.

  1. klein 9B KV identity (follow-up to Studio FLUX.2 klein 9B-KV: run KV checkpoints on their own pipeline (cached reference K/V, 1.47-2.23x edits) #18831). _resolve_base_repo swaps the KV base (black-forest-labs/FLUX.2-klein-9b-kv) for the stock 9B it borrows its text encoder, VAE and scheduler from. The queued load then wrote that 9B back into base_repo before load_pipeline picked the pipeline class, and a base taken from the model card never reached it at all. A KV GGUF or single file with a generic name (no "KV" in the repo or file name) ran through the stock Flux2KleinPipeline, advertised inpaint / outpaint, and passed the guard that keeps the base's dense transformer from replacing the KV DiT. _resolve_base_repo now records the base the caller or the card named (_checkpoint_base_of), the queued load passes it to load_pipeline as _checkpoint_base, and the pipeline class, that guard, the dense prefetch widening and the load state read it. Companion fetches still use the stock 9B.
  2. FLUX.3 cache-only reads pin the validated commit (follow-up to Studio diffusion: faster returning-user load for cached int8 FLUX.3 (one Hub call, persisted CUTLASS tile probe) #18837). current_snapshot returns the commit it validated, but the loader only kept a bool. Every cache-only read then resolved refs/main again. If another download moved that ref in between, the load read files from a snapshot nobody had validated. The commit is now passed as revision to every cache-only read (index, processor, text encoder, transformer, VAE, stored-dtype probes). A read that falls back to the Hub is unpinned, as before.
  3. CUTLASS tile probe and the async allocator (follow-up to Studio diffusion: faster returning-user load for cached int8 FLUX.3 (one Hub call, persisted CUTLASS tile probe) #18837). A failure persists only when it repeats and num_ooms did not move. Under PYTORCH_CUDA_ALLOC_CONF=backend:cudaMallocAsync that count stays 0, because the async allocator fills none of the native allocator's stats (CUDAMallocAsyncAllocator.cpp, getDeviceStats). A probe on a full card therefore persisted an empty tile list, and every later process on that card skipped the CUTLASS int8 tiles. _probe_tile now counts its own out-of-memory failures, and a probe that hit one does not persist. Editing the module also invalidates the verdicts already stored.
  4. Torchao-free hosted int8 commit takes only the ConvRot file (follow-up to Studio video: load explicit int8 LTX-2.5 on Windows ROCm from the hosted int8 DiT #18958). With no usable torchao (the Windows ROCm stub), the check that drops the dense LTX-2.5 DiT shards accepted any hosted .safetensors name. The native read only accepts the ConvRot file. So with UNSLOTH_DIFFUSION_INT8_CONVROT=0 (which resolves the unrotated LTX-2.5-INT8.safetensors), or with a listing that has no ConvRot file, the load staged 25 GB and the reader then refused it. Now only the -ConvRot.safetensors file counts. With ConvRot off, the ROCm hosted int8 route (plan, price, commit) does not apply, so the load uses the dense shards and runtime build as before. This matches the ConvRot gate the image route already has.
  5. Tests. The FLUX.3 warm-load fixture patched diffusers.Flux3Transformer2DModel.from_pretrained, so its four loader tests failed with AttributeError on a diffusers that meets the declared floor (>= 0.39) but predates the FLUX.3 classes. A missing class now gets a stand-in.

Tests

New tests fail on the merge base and pass on this branch (base arm = the merge base with the new test files copied in):

file new tests base head
test_diffusion_flux2_klein_kv.py card-only and explicit KV identity, queued load hands load_pipeline the KV identity, load_pipeline wiring 4 failed pass
test_diffusion_hub_snapshot.py cache-only reads pin the validated commit, Hub fallback stays unpinned, real hf_hub_download cache read after refs/main moves 2 failed (4 more fail on the old fixture with diffusers 0.40) pass
test_diffusion_int8_cutlass_probe_persist.py an OOM the allocator stats never count is not persisted 1 failed (persisted ok: []) pass
test_video_hosted_int8_fit.py unrotated file never committed without torchao, ConvRot file beside it still committed, ConvRot off takes the hosted route off 3 failed pass

Related suites (klein KV, FLUX.3 loader / storage / manual cast, hub snapshot, CUTLASS, gated base, compat preflight, video hosted int8 / native hosted / families, refactor guard): 1676 passed. The 8 failures are the same 8 test IDs on the merge base: 5 MiniMax H3 download-plan tests and 2 FLUX.3 retired-copy tests from a huggingface_hub without get_cached_repo_tree / diffusers 0.40, and 1 causal-mask patch test.

Not covered

  • No GPU run. The async-allocator OOM path is shown by injecting OutOfMemoryError with num_ooms fixed at 0, which is what the upstream allocator source reports. It was not run on a real card with backend:cudaMallocAsync.
  • No Windows ROCm run of the ConvRot gate. The check is CPU-only, using the existing torchao-stub fixture.
  • The native sd.cpp engine takes its base from the request alone, so a card-only KV identity does not reach its reference-edit refusal. That is not changed here.

…mpanion remap

_resolve_base_repo swaps the KV base (black-forest-labs/FLUX.2-klein-9b-kv) for
the stock 9B it borrows its text encoder, VAE and scheduler from. The queued load
then wrote that 9B back into base_repo before load_pipeline picked the pipeline
class, and a card-only base never reached it at all. A generically named KV GGUF
or single file (no "KV" in the repo or file name) therefore ran through the stock
Flux2KleinPipeline, advertised the stock inpaint / outpaint workflows, and passed
the guard that keeps the base's dense transformer from replacing the KV DiT.

_resolve_base_repo now records the base the caller or the trusted card named when
the companion remap replaces it (_checkpoint_base_of). The queued load hands it to
load_pipeline as _checkpoint_base, and the pipeline class, the dense-substitution
guard, the dense prefetch widening and the load state's checkpoint_base read it.
Companion fetches still use the stock 9B.
….3 classes

The loader fixture patched diffusers.Flux3Transformer2DModel.from_pretrained, so
on a diffusers that meets the declared floor (>= 0.39) but predates the FLUX.3
classes all four loader tests failed with AttributeError before running. A class
the installed library lacks now gets a stand-in; a present one is patched as
before.
…lidated

current_snapshot returns the commit it validated, but the loader kept only a
bool, and every cache-only component read resolved refs/main again. A concurrent
download that moved the shared cache's refs/main between the check and a read
handed this load another snapshot's files, one the check never validated, without
the cache-miss fallback.

The loader keeps the commit and passes it as revision to every cache-only read:
model_index.json, the processor, the text encoder, the transformer, the VAE and
the stored-dtype probes. A read that falls back to the Hub stays unpinned, as
before.
The tile verdict persists a failure only when it repeats and the allocator's
num_ooms did not move. Under PYTORCH_CUDA_ALLOC_CONF=backend:cudaMallocAsync that
count stays 0 (the async allocator fills none of the native allocator's stats), so
a probe on a full card that failed twice with OutOfMemoryError persisted an empty
tile list, and every later process on that card skipped the CUTLASS int8 tiles.

_probe_tile now counts its own out-of-memory failures, and a probe that saw one
does not persist. Editing this module also invalidates the verdicts already stored.
…Rot file

With no usable torchao (the Windows ROCm stub), the source check that drops the
dense LTX-2.5 DiT shards accepted any hosted .safetensors name. The native read
accepts only the ConvRot file, so with UNSLOTH_DIFFUSION_INT8_CONVROT=0 (which
resolves the unrotated LTX-2.5-INT8.safetensors), or a listing without the ConvRot
file, the load staged 25 GB that the reader then refused before the dense re-plan.

The torchao-free commit now counts only the -ConvRot.safetensors file, and with
ConvRot turned off the ROCm hosted int8 route (plan, price and torchao-free
commit) does not apply, so the load keeps the dense shards and the runtime build,
as before that route.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 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-23T04:58:15.920616Z 3401273 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.

@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: dc8e63ae3e

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

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 34012734ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit ec0626a into main Nov 23, 2026
@danielhanchen
danielhanchen deleted the studio-recheck-load-fixes branch November 23, 2026 05:35
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