Repository navigation
feat(flux3): load unsloth's diffusers-named torchao fp8 build - #10182
Draft
Pfannkuchensack wants to merge 15 commits into
Draft
Pfannkuchensack wants to merge 15 commits into
Pfannkuchensack wants to merge 15 commits into
Conversation
FLUX.3 Klein and Klein Base now load Comfy-Org's int8_convrot and nvfp4 files and BFL's fp8r and nvfp4 variants; one rule set refuses at install what the loader cannot run. BFL's nvfp4 is re-laid out to Comfy's packing after the reservation, and the int8 build's fused qkv is split into the model's projections.
…hecks Install-time validation now reuses check_int8_layer_layout, so a missing scale, blockwise scale or oversized rotation group is refused at install.
… check Split the rotation-width rule out of check_int8_layer_layout so the swap runs it after the target-shape check; install runs both.
# Conflicts: # docs/src/content/docs/Users Guide/03.Models/Local Models/flux-3.mdx # invokeai/backend/flux3/denoise_working_memory.py
# Conflicts: # docs/src/content/docs/Users Guide/03.Models/Local Models/flux-3.mdx
Translate torchao fp8 layers into the scaled-fp8 form and refuse other torchao layouts at install. Release the file mapping when a load folds every layer.
Recognize the layout only with a torchao payload and read the Klein variant from it.
This branch has not been deployed
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
unsloth's
flux-3-image-klein-FP8.safetensorsinstalled as an unknown model: it uses diffusers' key names, and identification only read Black Forest Labs' native layout. It now installs as Klein and loads.flux3_transformer_configreads shapes through the same key mapping as the native route, andflux3_transformer_from_nativeis renamed toflux3_transformer_from_single_file._weight_qdata, so a Klein file that quantizes that embedder is not recorded as Klein Base.Related Issues / Discussions
Follow-up to #9798. Depends on #10093 and #10179.
QA Instructions
RTX 4090, Windows, 1024x1024, 16 steps, CFG 1, three prompts with fixed seeds,
use_cache=false, model cache emptied before each block. Reference isflux3_image_klein_sd_bf16.safetensors, whose dense tensors match the FP8 file byte for byte under native names (44 of 45 compared directly);flux3-image-klein-base-bf16matches none. All its tensors are BF16 andfp8_storageis unset. The FP8 file installs as Klein with FP8 Storage on; the log reports 228 layers kept in fp8.fp8_computeRepeated renders with the same seed were bit-identical on both sides, and bf16 was identical across both server settings. Images compared by eye: clean, same subject, text intact.
Real files on CPU: after translation the key set equals the native conversion of the bf16 source (359 keys), all 131 dense tensors match it by value, including the swapped
norm_out.linear, and all 228 quantized layers sit at a relative error of 0.0263-0.0265.ruff checkandruff format --checkpass.make frontend-openapiandmake frontend-typegenwere rerun.Not run: a partial load on a real device, the fold path on a GPU, ROCm and other hardware. The family E2E tool was not run. No Klein Base torchao file exists, so that case is covered by fixtures only, and the INT8 build's refusal rests on the layout of the sibling families.
Review
Resolved during review:
clone_unreplaced_tensors.Remaining: a diffusers-named torchao file with quantized
x_embeddersis refused safely, but the message wrongly names Black Forest Labs' key names. No such file is known.The 86 F32 q/k norms in this file go through the existing cast and are widened again by
_keep_qk_norms_in_fp32; all of them are exactly representable in bf16, so nothing is lost.Compatibility / Rollout
No migration.
openapi.jsonandschema.tschange only in theMain_Checkpoint_Flux3_Configdescription.Checklist
What's Newcopy (if doing a release after this PR)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.