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

Add some informations for SDXL training #431

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

Conversation

ANGJustinl
Copy link

Mainly from

https://github.com/kohya-ss/sd-scripts/blob/main/docs/train_README-zh.md`
https://github.com/kohya-ss/sd-scripts/blob/main/docs/train_SDXL-en.md

xformers 是否会较 原生torch 增加显存占用/降低 我不确定,所以并未写入,其他新增注释测试个人无误
我自己使用v1.8.3训练时xformer反而增加了显存消耗

@ANGJustinl
Copy link
Author

https://github.com/kohya-ss/sd-scripts/blob/main/docs/train_README-zh.md#%E4%BC%98%E5%8C%96%E5%99%A8%E7%9B%B8%E5%85%B3

优化器相关

  • --optimizer_type
    -- 指定优化器类型。您可以指定

  • --learning_rate

    指定学习率。合适的学习率取决于训练脚本,所以请参考每个解释。

  • --lr_scheduler / --lr_warmup_steps / --lr_scheduler_num_cycles / --lr_scheduler_power

    学习率的调度程序相关规范。

    使用 lr_scheduler 选项,您可以从线性、余弦、cosine_with_restarts、多项式、常数、constant_with_warmup 或任何调度程序中选择学习率调度程序。默认值是常量。

    使用 lr_warmup_steps,您可以指定预热调度程序的步数(逐渐改变学习率)。

    lr_scheduler_num_cycles 是 cosine with restarts 调度器中的重启次数,lr_scheduler_power 是多项式调度器中的多项式幂。

    有关详细信息,请自行研究。

    要使用任何调度程序,请像使用任何优化器一样使用“--scheduler_args”指定可选参数。

关于指定优化器

使用 --optimizer_args 选项指定优化器选项参数。可以以key=value的格式指定多个值。此外,您可以指定多个值,以逗号分隔。例如,要指定 AdamW 优化器的参数,--optimizer_args weight_decay=0.01 betas=.9,.999

指定可选参数时,请检查每个优化器的规格。
一些优化器有一个必需的参数,如果省略它会自动添加(例如 SGDNesterov 的动量)。检查控制台输出。

D-Adaptation 优化器自动调整学习率。学习率选项指定的值不是学习率本身,而是D-Adaptation决定的学习率的应用率,所以通常指定1.0。如果您希望 Text Encoder 的学习率是 U-Net 的一半,请指定 --text_encoder_lr=0.5 --unet_lr=1.0
如果指定 relative_step=True,AdaFactor 优化器可以自动调整学习率(如果省略,将默认添加)。自动调整时,学习率调度器被迫使用 adafactor_scheduler。此外,指定 scale_parameter 和 warmup_init 似乎也不错。

自动调整的选项类似于--optimizer_args "relative_step=True" "scale_parameter=True" "warmup_init=True"

如果您不想自动调整学习率,请添加可选参数 relative_step=False。在那种情况下,似乎建议将 constant_with_warmup 用于学习率调度程序,而不要为梯度剪裁范数。所以参数就像--optimizer_type=adafactor --optimizer_args "relative_step=False" --lr_scheduler="constant_with_warmup" --max_grad_norm=0.0

使用任何优化器

使用 torch.optim 优化器时,仅指定类名(例如 --optimizer_type=RMSprop),使用其他模块的优化器时,指定“模块名.类名”。(例如--optimizer_type=bitsandbytes.optim.lamb.LAMB)。

(内部仅通过 importlib 未确认操作。如果需要,请安装包。)

Copy link
Author

@ANGJustinl ANGJustinl left a comment

Choose a reason for hiding this comment

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

坏了刚刚不小心改了

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.

None yet

1 participant