Skip to content

Conversation

@sdbds
Copy link
Contributor

@sdbds sdbds commented Jul 8, 2024

use
--num_last_block_to_freeze
to set freeze blocks num,reverse freeze.
(default none,you can set 0~240)

SD3 has 240 x_blocks, i test if freeze half of it will get better effect.

Comparison:
Before↓
image

After freeze 120↓
image

@kohya-ss
Copy link
Owner

kohya-ss commented Jul 8, 2024

Thank you for this! This seems to work like block_lr for SDXL. I will merge when I can confirm the SD3 training is fine :)

@sdbds
Copy link
Contributor Author

sdbds commented Jul 8, 2024

Thank you for this! This seems to work like block_lr for SDXL. I will merge when I can confirm the SD3 training is fine :)

Yes, the functionality is very similar with block_lr.
After freezing the blocks, I only input the parameters of the blocks that need to be trained to the optimizer.
This can reduce additional overhead.

@FurkanGozukara
Copy link

how do you know which layers you should freeze or it is purely experimental?

@sdbds
Copy link
Contributor Author

sdbds commented Jul 8, 2024

how do you know which layers you should freeze or it is purely experimental?

I received advice from SD3 trainer.

@FurkanGozukara
Copy link

how do you know which layers you should freeze or it is purely experimental?

I received advice from SD3 trainer.

makes sense. so what parameter they suggest ? like --num_last_block_to_freeze 80 ?

@sdbds
Copy link
Contributor Author

sdbds commented Jul 8, 2024

how do you know which layers you should freeze or it is purely experimental?

I received advice from SD3 trainer.

makes sense. so what parameter they suggest ? like --num_last_block_to_freeze 80 ?

120~240,i think magic number between these.

@kohya-ss kohya-ss mentioned this pull request Aug 24, 2024
@kohya-ss kohya-ss merged commit ef510b3 into kohya-ss:sd3 Sep 1, 2024
@kohya-ss
Copy link
Owner

kohya-ss commented Sep 1, 2024

Thank you for this! Sorry it took so long.

@kohya-ss kohya-ss mentioned this pull request Sep 1, 2024
25 tasks
nana0304 pushed a commit to nana0304/sd-scripts that referenced this pull request Jun 4, 2025
* Update sd3_train.py

* add freeze block lr

* Update train_util.py

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

3 participants