stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

use empty_like to reduce model loading time

Open wkpark opened this issue 1 year ago • 1 comments

use empty_like() instead of zeros_like() in the LoadStateDictOnMeta() we don't have to initialize params with zeros, It will be overwrittened by param.copy_(input_param), (https://github.com/pytorch/pytorch/blob/main/torch/nn/modules/module.py#L2441 )

Checklist:

wkpark avatar Oct 22 '24 04:10 wkpark

I merged this into my fork a few months ago without issue.

Didn't test actual model load times to see if there was a difference, but I can say for certain that it didn't slow anything! https://github.com/aleph23/auto1111/pull/5

aleph23 avatar Jun 13 '25 14:06 aleph23