Repository navigation
Studio: load NVFP4 diffusion checkpoints from .safetensors only - #16739
Merged
Merged
Conversation
The hosted unsloth/*-NVFP4 diffusion repos now hold only .safetensors. With UNSLOTH_NVFP4_DIFFUSION on, Studio never resolves, prefers from the cache, accepts as a local override, or unpickles an NVFP4 .pt / .pth: - resolve_prequant_source derives and declares only <Model>-NVFP4.safetensors for nvfp4 and ignores UNSLOTH_PREQUANT_SAFETENSORS_TWINS for it - video family rows name the hosted .safetensors files - _resolve_checkpoint_path drops pickle names for nvfp4 and refuses with a clear message when this torchao cannot rebuild NVFP4 safetensors - NVFP4 classes leave the pickle allowlist; the loader refuses an nvfp4 pickle by requested scheme and by recorded metadata - nvfp4 detection reads only safetensors headers - gate records point at the .safetensors files and their LFS sha256 - build_prequant_checkpoint.py refuses a non-safetensors nvfp4 output int8 / fp8 / mxfp8 chains, pickle fallbacks and the allowlist are unchanged.
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. |
Member
Author
|
@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". |
[skip ci]
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
The hosted
unsloth/*-NVFP4diffusion repos now hold only.safetensorsfiles (each one was checked bit-identical to its old.ptthrough Studio's loader before the.ptfiles were removed). NVFP4 is still off by default (UNSLOTH_NVFP4_DIFFUSION), so default users see no change. With the flag on, Studio now asks for and loads only the.safetensorsand never resolves, prefers or unpickles an NVFP4 pickle.Changes
studio/backend/core/inference/diffusion_prequant.pyresolve_prequant_source: fornvfp4the chain has no.pt/.pthname (no derived<Model>-NVFP4.pt, no legacytransformer_nvfp4.pt, no declared pickle).derived_prequant_filenamesderives only<Model>-NVFP4.safetensors, and it counts as declared, so planning does not need the file cached first.UNSLOTH_PREQUANT_SAFETENSORS_TWINS=0no longer brings back the pickle chain for nvfp4._resolve_checkpoint_path: drops pickle names for nvfp4 even if the source still lists them, soreadable or namescannot fall back to a pickle. If this install cannot rebuild NVFP4 safetensors (torchao < 0.17), the load is refused with a clear message.restricted_prequant_load_supported("nvfp4", <pickle>)is always False. The scheme-only question for nvfp4 now means "can this install read nvfp4 safetensors"._PREQUANT_SAFE_GLOBALSand_SCHEME_REQUIRED_GLOBALS. Since torchao adds them to the global safe list itself, the loader also refuses explicitly:_load_prequant_checkpointrejects a non-safetensors path whenscheme="nvfp4"is passed, and rejects any pickle whose metadata recordsnvfp4..ptoverride is not used as a source, and the loader refuses it if it gets one anyway.local_prequant_schemenever reportsnvfp4for a pickle._artifacts_declare_nvfp4only reads safetensors headers, anddeclares_nvfp4_checkpointdecides a single.ptfile by its name without unpickling it.prefer_cached_pickle_twinscannot pick a cached nvfp4.pt: the pickle is unreadable for nvfp4 and is no longer in the chain.Tables and tools
video_families.py: the nvfp4 rows name the hosted files (Wan2.2-TI2V-5B-NVFP4.safetensors,Wan2.2-T2V-A14B-NVFP4.safetensors,Wan2.2-T2V-A14B-transformer_2-NVFP4.safetensors,HunyuanVideo-1.5-Diffusers-480p_t2v-NVFP4.safetensors/720p). Image families derive<Model>-NVFP4.safetensors, which matches the Hub for all four image repos.nvfp4_gate_record.json: each record'sfilenameis now the.safetensorsname andcheckpoint_sha256is that file's LFS sha256 from the Hub listing.scripts/build_prequant_checkpoint.pyrefuses a non-safetensors--out(and pickle upload names) for--scheme nvfp4.scripts/convert_prequant_to_safetensors.pystill reads a local pickle directly, so it remains the way to turn an old local NVFP4.ptinto a.safetensors.diffusion_families.pyand updated the tests that hard-coded NVFP4.ptnames.INT8, FP8 and MXFP8 are unchanged: same chains,
.pttwins and fallbacks, cached-pickle preference and allowlist.Tests
New
studio/backend/tests/test_prequant_nvfp4_safetensors_only.py(38 tests) covers:.ptPlus nvfp4 cases added to
test_prequant_prefer_cached_pickle.pyandtest_video_prequant_safetensors_twins.py, and refusal tests intest_build_prequant_checkpoint.py.7ec4b20bc2) with the new test file: 30 failed, 8 passed. The 8 that pass are the int8 / fp8 controls. Two of the 30 call the newscheme=keyword, which base does not have.test_diffusion_more_families.py::test_create_causal_mask_patch_is_self_disabling_and_idempotent, which fails on main too.All of this ran on CPU. No GPU render was done here; the
.safetensorsfiles had already been verified bit-identical to the old.ptfiles through Studio's loader.