Speedup Stable diffusion model Loading time

A1111 Webui

webui-user.bat
set COMMANDLINE_ARGS= --xformers --no-hashing --opt-channelslast --no-download-sd-model --lowram
set SAFETENSORS_FAST_GPU=1

stable-diffusion-webui/modules/sd_models.py
Switch
pl_sd = safetensors.torch.load_file(checkpoint_file, device=device)
by
pl_sd = safetensors.torch.load(open(checkpoint_file, 'rb').read())

pl_sd = safetensors.torch.load(open(checkpoint_file, 'rb').read())
pl_sd = {k: v.to(device) for k, v in pl_sd.items()}

Comfyui

Comfyui/Comfyui/comfy/utils.pyreplacing
sd = safetensors.torch.load_file(ckpt, device=device.type)
by
sd = safetensors.torch.load(open(ckpt, 'rb').read())

It will increased the speed from the HDD x6 times, from 15M/s to 200MB/s