Add train flux2 series lora config #13011
Open
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?
Expand LoRA support for FLUX.2 series single stream blocks and update docs
1. Architectural Evolution
Compared to the original FLUX framework, the FLUX.2 architecture has undergone significant changes. Firstly, the number of single-stream layers is far greater than that of double-stream layers. Furthermore, In the Single transformer Blocks, the q,k,v projections are fused with the MLP into a single unified linear layer:
attn.to_qkv_mlp_proj.Therefore, using Flux's Lora configuration to train Flux2 is insufficient.
2. Implementation Updates
To address these changes, I have updated the LoRA configuration in the following training scripts and added additional notes to the readme:
examples/dreambooth/README_flux2.mdexamples/dreambooth/train_dreambooth_lora_flux2.pyexamples/dreambooth/train_dreambooth_lora_flux2_klein.pyThe
target_moduleslogic has been modified to ensure that the Lora adapter can correctly train the main attention layers of both double-stream and single-stream layers.Flux2 has 48 single-stream layers, while Klein has 24.Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.