Skip to content

Studio: reroute only official NVFP4 checkpoints to INT8 on pre-Blackwell GPUs - #17343

Merged
danielhanchen merged 2 commits into
mainfrom
studio-nvfp4-route-trusted-only
Nov 10, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-nvfp4-route-trusted-only

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

On a pre-Blackwell GPU, Studio could swap a fine-tuned NVFP4 checkpoint for the official base model's INT8 build. It did this whenever the file or repo name spelled a known base. For example, flux-2-klein-4b-my-finetune-nvfp4.safetensors, or any file in my-team/FLUX.2-klein-4B-personal-finetune, loaded black-forest-labs/FLUX.2-klein-4B. The user got the stock model's images with no error, and only a precision fallback note.

With this change, a checkpoint is replaced only when it is a known official NVFP4 checkpoint. Every other pick keeps its own weights.

Root cause

#17229 added core/inference/diffusion_nvfp4_route.py. When a pick was not a registered hosted repo, the router found the base with _named_base, which checks whether a known base's name appears in the filename or repo id. With an explicit base_repo, it used that base directly. Neither proves the checkpoint holds that base's weights, but the router still replaced model_path with the base pipeline and dropped the selected file.

Fix

A checkpoint is replaced only when it matches an explicit registry of official NVFP4 checkpoints:

  • the hosted unsloth/*-NVFP4 repos and files, read from the family tables (prequant_repos, prequant_variant_repos, prequant_filenames);
  • a short list of vendor-published files, each mapped to its base: black-forest-labs/FLUX.2-klein-{4b,9b}-nvfp4, FLUX.2-klein-base-{4b,9b}-nvfp4, FLUX.1-dev-NVFP4, FLUX.1-Kontext-dev-NVFP4, FLUX.2-dev-NVFP4, and Lightricks/LTX-2.5 diffusion_models/ltx-2.5-22b-distilled-transformer-nvfp4.safetensors.

Matching rules:

  • Hub pick: the repo id must be in the registry. If a file is named, it must be that repo's registered file.
  • Local file: the file name must be a registered official file name (case and punctuation ignored).
    • If the file sits in a Hub cache snapshot (models--owner--name), that repo must be the registered one.
    • If the Unsloth header records a base (base_model_id), it must be the mapped base.
  • Anything else is kept as picked and logged. That is the behaviour from before Studio: load INT8 instead of NVFP4 on pre-Blackwell GPUs #17229: a weight-only load, or the existing refusal.

The name-matching helpers (_named_base, _family_int8_base, _video_int8_base, _name_tokens) are removed. Explicit NVFP4 precision picks, text-encoder picks and prequant-path handling are unchanged. The kill switch UNSLOTH_NVFP4_PRE_BLACKWELL_INT8=0 is also unchanged.

The registry also keeps the earlier variant guarantees: an LTX-2.5 dev file, LTX-2.3 files and unregistered FLUX.1 variants are still kept.

One behaviour change for a valid path: a local qwen-image-2.1-turbo-nvfp4.safetensors was previously replaced by Qwen/Qwen-Image-2.1-Turbo. No official NVFP4 file has that name, so it is now kept. The test table now expects that.

Flip test

tests/test_diffusion_nvfp4_route.py::test_a_custom_nvfp4_checkpoint_keeps_its_own_weights has six cases on a simulated sm_89 device:

  • a local fine-tune with a custom name, without and with a header naming another base;
  • the official file name with a header naming another base;
  • the official file name cached from another repo;
  • a third-party repo with the official file name;
  • a third-party -nvfp4 repo with no filename.

All six fail on main (each is replaced by black-forest-labs/FLUX.2-klein-4B) and pass with the fix.

test_an_official_nvfp4_checkpoint_is_still_replaced covers these cases, which still reroute on both main and the fix:

  • the BFL klein 4B / 9B repos;
  • unsloth/Z-Image-Turbo-NVFP4;
  • a Hub cache snapshot of the BFL repo;
  • a local hosted file whose header records the right base.

test_every_trusted_nvfp4_file_resolves_to_a_family checks that every vendor row maps to a base that a family loads.

Tests run

  • tests/test_diffusion_nvfp4_route.py and tests/test_video_routes.py pass with the fix. This includes the existing 308-case routing matrix: the LTX-2.5 packed file, hosted repo and kill-switch arms are unchanged.
  • The 83 test files that reference NVFP4 (-o addopts= -m "not server and not native_mxc", CPU) were run on main and with the fix. They have the same 16 failures on both sides: moss_image, export_reap, video_ltx25 and others, all pre-existing and unrelated. The only difference was the intended qwen-image-2.1-turbo expectation change.

Not proven

  • No GPU run. The decision is a pure routing function, and it is covered on CPU with simulated device profiles.
  • The vendor file list matches the Hub listings as of today. A new official NVFP4 release needs a row in the registry before it reroutes. Until then it is kept, as it was before Studio: load INT8 instead of NVFP4 on pre-Blackwell GPUs #17229.
  • A fine-tune saved under the exact official file name, outside a Hub cache and with no recorded base in its header, is still treated as official. Telling it apart would mean hashing multi-GB files.

…ell GPUs

The pre-Blackwell NVFP4 route replaced any NVFP4 single file or repo whose
name spelled a known base with that base's INT8 pipeline, so a fine-tune
named like flux-2-klein-4b-my-finetune-nvfp4 loaded the stock weights.

Replace a checkpoint only when it matches a registry of official NVFP4
checkpoints (the hosted unsloth repos from the family tables plus the
vendor BFL / Lightricks files). Local files must carry the official file
name, come from that repo when in a Hub cache, and not record another base
in their header. Everything else keeps its own weights as before #17229.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 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-10T04:20:45.231473Z df85b2c 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. Can't wait for the next one!

Reviewed commit: df85b2c2f2

ℹ️ 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 5aa8989 into main Nov 10, 2026
@danielhanchen
danielhanchen deleted the studio-nvfp4-route-trusted-only branch November 10, 2026 04:56
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