diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

DreamBooth: Not applying accelerator.accumulate on text_encoder

Open immortalCO opened this issue 10 months ago • 4 comments

Describe the bug

At examples/dreambooth/train_dreambooth_lora_sdxl.py#L1618, only unet is applied with accelerator.accumulate().

      for step, batch in enumerate(train_dataloader):
            with accelerator.accumulate(unet): # HERE
                pixel_values = batch["pixel_values"].to(dtype=vae.dtype)
                prompts = batch["prompts"]

However, when using --train_text_encoder, the text encoders text_encoder_one and text_encoder_two are also training. Shouldn't they be also applied with accelerator.accumulate()?

Reproduction

None. It is like a logical one instead of a behavior, so no need to reproduce.

Logs

No response

System Info

None. It is like a logical one instead of a behavior, so no need to mention the environment.

Who can help?

@sayakpaul

immortalCO avatar Apr 07 '24 23:04 immortalCO

I remember we did this because accelerate wasn't able to accumulate for multiple models. But this has changed now. Ccing @muellerzr for confirmation.

sayakpaul avatar Apr 08 '24 00:04 sayakpaul

Yes, all models being trained should be passed to accumulate

muellerzr avatar Apr 08 '24 01:04 muellerzr

@immortalCO would you be able to submit a PR for this?

sayakpaul avatar Apr 08 '24 02:04 sayakpaul

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar May 08 '24 15:05 github-actions[bot]

Closing this issue because of inactivity. Feel free to reopen.

sayakpaul avatar Jun 29 '24 13:06 sayakpaul