Repository navigation
Swap shift and scale in Flux2 LoRAs of final_layer.adaLN_modulation.1 - #15276
Merged
sayakpaul merged 2 commits intoNov 13, 2026
Merged
Conversation
The original final layer orders its modulation (shift, scale) and diffusers' norm_out (scale, shift). The checkpoint converter swaps the halves; the LoRA converter now swaps lora_B's halves the same way. Fixes huggingface#15275 Co-Authored-By: Claude Opus 5.5 <[email protected]>
sayakpaul
approved these changes
Nov 13, 2026
Member
|
/diffusers-bot pytest tests/models/transformers/test_models_transformer_flux2.py::TestFlux2TransformerLoRA |
Contributor
|
✅ |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
What does this PR do?
Fixes #15275
_convert_non_diffusers_flux2_lora_to_diffusersmapped the original keyfinal_layer.adaLN_modulation.1tonorm_out.linearunchanged. The two layers split their output differently:(shift, scale).AdaLayerNormContinuoussplits it into(scale, shift).convert_flux2_transformer_checkpoint_to_diffusersswaps the halves for the weights. This PR does the same for the adapter: it swaps the halves oflora_Bwith the existingswap_scale_shifthelper, becauselora_B's rows are the layer's outputs.lora_Astays as it is.The new test
TestFlux2TransformerLoRA.test_lora_bfl_final_layer_modulationchecks that the converted adapter's update equals the original update with its halves swapped.Tests run (macOS 27.2 arm64, torch 2.15.0, Python 3.12):
The 11 failures are the same with and without this change on this machine:
test_hotswapping_compile_on_different_shapestest_hotswapping_compiled_model_lineartest_hotswapping_compiled_model_both_linear_and_othertest_lora_layerwise_casting_inferencetest_lora_layerwise_casting_peft_input_autocastruff==0.9.10 checkandruff format --checkpass on both files.Self-review notes (the
self-reviewskill's rubric:review-rules.md,code_style.md,testing.md):_convert_non_diffusers_flux2_lokr_to_diffusersmaps the same key the same way. For LoKr, swapping the output halves only factors into the Kronecker factors when the first factor has an even number of rows (then you swap that factor's halves). I left it out rather than guess. Should it get that swap, or an error when it does not factor?Before submitting
self-reviewskill on the diff?Who can review?
@sayakpaul
🤖 Generated with Claude Code