Skip to content

[textual_inversion_sdxl.py] fix lr scheduler steps count #11557

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

yuanjua
Copy link
Contributor

@yuanjua yuanjua commented May 15, 2025

What does this PR do?

Part of #8384
Fix for LR in a distributed training when num_train_epoch is passed

run with the following scripts:

from huggingface_hub import snapshot_download

local_dir = "./cat"
snapshot_download(
    "diffusers/cat_toy_example", local_dir=local_dir, repo_type="dataset", ignore_patterns=".gitattributes"
)
#!/bin/bash

mkdir -p textual_inversion_cat/logs

accelerate launch \
  --multi_gpu \
  --num_processes=2 \
  --mixed_precision="bf16" \
  textual_inversion_sdxl.py \
  --pretrained_model_name_or_path="stabilityai/stable-diffusion-xl-base-1.0" \
  --train_data_dir="./cat" \
  --output_dir="textual_inversion_cat" \
  --placeholder_token="<my-token>" \
  --initializer_token="cat" \
  --resolution=1024 \
  --train_batch_size=1 \
  --gradient_accumulation_steps=1 \
  --max_train_steps=100 \
  --learning_rate=1e-4 \
  --num_vectors=4 \
  --validation_prompt="a photo of a <my-token>" \
  --num_validation_images=4 \
  --validation_steps=100 \
  --save_steps=500 \
  --mixed_precision="bf16" \
  --enable_xformers_memory_efficient_attention \
  --gradient_checkpointing \
  --center_crop \
  --report_to="tensorboard" \
  --logging_dir="textual_inversion_cat/logs"

Before submitting

Who can review?

@sayakpaul

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.

Thank you.

@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.

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