Repository navigation
Studio: reroute only official NVFP4 checkpoints to INT8 on pre-Blackwell GPUs - #17343
Merged
Merged
Conversation
…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.
Codex Review Summary: ✅ CompletedThis 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. |
[skip ci]
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inmy-team/FLUX.2-klein-4B-personal-finetune, loadedblack-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 explicitbase_repo, it used that base directly. Neither proves the checkpoint holds that base's weights, but the router still replacedmodel_pathwith the base pipeline and dropped the selected file.Fix
A checkpoint is replaced only when it matches an explicit registry of official NVFP4 checkpoints:
unsloth/*-NVFP4repos and files, read from the family tables (prequant_repos,prequant_variant_repos,prequant_filenames);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, andLightricks/LTX-2.5diffusion_models/ltx-2.5-22b-distilled-transformer-nvfp4.safetensors.Matching rules:
models--owner--name), that repo must be the registered one.base_model_id), it must be the mapped base.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 switchUNSLOTH_NVFP4_PRE_BLACKWELL_INT8=0is 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.safetensorswas previously replaced byQwen/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_weightshas six cases on a simulated sm_89 device:-nvfp4repo 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_replacedcovers these cases, which still reroute on both main and the fix:unsloth/Z-Image-Turbo-NVFP4;test_every_trusted_nvfp4_file_resolves_to_a_familychecks that every vendor row maps to a base that a family loads.Tests run
tests/test_diffusion_nvfp4_route.pyandtests/test_video_routes.pypass 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.-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 intendedqwen-image-2.1-turboexpectation change.Not proven