fix(flux2): filter non-transformer keys from bundled checkpoints#9060
Open
fix(flux2): filter non-transformer keys from bundled checkpoints#9060
Conversation
Some Flux.2 .safetensors files are combined checkpoints that bundle text encoder and VAE weights alongside the transformer. These extra keys (text_encoders.*, vae.*) were passing through to load_state_dict and causing RuntimeError due to unexpected keys. Filter them out before conversion, matching the approach used by the Z-Image loader. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verify that text_encoders.* and vae.* keys are properly filtered from bundled FLUX.2 checkpoints, and that non-bundled checkpoints are unaffected. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
This PR handles the case of FLUX.2 all-in-one checkpoints that have bundled text encoders and or VAEs. It uses the same logic as the Z-Image loader:
RuntimeError: Error(s) in loading state_dict for Flux2Transformer2DModelwhen loading bundled Flux.2.safetensorscheckpoints that include text encoder (text_encoders.*) and VAE (vae.*) keys alongside the transformer weights.load_state_dict, matching the approach already used by the Z-Image loader.Flux2CheckpointModel) and the GGUF loader (Flux2GGUFCheckpointModel).Testing
tests/backend/model_manager/load/model_loaders/test_flux2_checkpoint_bundled_keys.pysucceeds.Merge Plan
Simple merge