sd-scripts icon indicating copy to clipboard operation
sd-scripts copied to clipboard

[Bug] Sample generation is not deterministic when using `--seed`

Open feffy380 opened this issue 7 months ago • 5 comments

When training with a fixed seed, samples are different every time due to this block in train_util.sample_image_inference(), specifically the else branch: https://github.com/kohya-ss/sd-scripts/blob/25f961bc779bc79aef440813e3e8e92244ac5739/library/train_util.py#L5264-L5270

I understand that this was added so each process makes different images in a multi-gpu setting, but I think a better way to handle this would be to generate a random seed, then add the accelerator.process_index to it. This way each process has a unique seed while still being reproducible when using a fixed training seed.

feffy380 avatar Jul 20 '24 11:07 feffy380