Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flux dreambooth lora training] make LoRA target modules configurable + small bug fix #9646

Merged
merged 20 commits into from
Oct 28, 2024

Conversation

linoytsaban
Copy link
Collaborator

@linoytsaban linoytsaban commented Oct 11, 2024

new feature for the Flux dreambooth lora training script:

  • make LoRA target modules configurable through --lora_layers

  • change the current default target modules to not be attention layers only

& small fix to mixed precision training for dreambooth script, as proposed in #9565

@HuggingFaceDocBuilderDev

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.

@linoytsaban linoytsaban changed the title [flux lora training] make LoRA target modules configurable [flux dreambooth lora training] make LoRA target modules configurable + small bug fix Oct 15, 2024
Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Minor notes.

@@ -161,7 +161,7 @@ def log_validation(
f"Running validation... \n Generating {args.num_validation_images} images with prompt:"
f" {args.validation_prompt}."
)
pipeline = pipeline.to(accelerator.device, dtype=torch_dtype)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's provide the author courtesy here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@linoytsaban did we resolve this?

Comment on lines +1201 to +1214
target_modules = [
"attn.to_k",
"attn.to_q",
"attn.to_v",
"attn.to_out.0",
"attn.add_k_proj",
"attn.add_q_proj",
"attn.add_v_proj",
"attn.to_add_out",
"ff.net.0.proj",
"ff.net.2",
"ff_context.net.0.proj",
"ff_context.net.2",
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a bit breaking no? Better to not do it and instead make a note from the README?

WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking or just changing default behavior? I think it's geared more towards the latter, but I think it's in line with the other trainers & makes sense for Transformer based models, so maybe a Warning note and a guide on how to train it the old way for e.g.?

Copy link
Member

@sayakpaul sayakpaul Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah maybe a warning note at the beginning of the README should cut it.

With this change, we're likely also increasing the total training wall-clock time in the default setting, so, that is worth noting.

@linoytsaban linoytsaban requested a review from sayakpaul October 28, 2024 13:48
--cache_latents
--learning_rate 5.0e-04
--scale_lr
--lora_layers single_transformer_blocks.0.attn.to_k
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit): could make "single_transformer_blocks.0.attn.to_k" a constant and then supply it here. This way we know what we're testing for immediately. WDYT?

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Minor comments.

@linoytsaban linoytsaban merged commit 743a569 into huggingface:main Oct 28, 2024
8 checks passed
@linoytsaban linoytsaban deleted the lora_modules branch November 26, 2024 10:18
sayakpaul added a commit that referenced this pull request Dec 23, 2024
… + small bug fix (#9646)

* make lora target modules configurable and change the default

* style

* make lora target modules configurable and change the default

* fix bug when using prodigy and training te

* fix mixed precision training as  proposed in #9565 for full dreambooth as well

* add test and notes

* style

* address sayaks comments

* style

* fix test

---------

Co-authored-by: Sayak Paul <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants