mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-04-26 14:59:03 +08:00
Ensure the cached weight will not be affected
This commit is contained in:
parent
110485d5bb
commit
50a21cb09f
@ -435,9 +435,9 @@ def load_model_weights(model, checkpoint_info: CheckpointInfo, state_dict, timer
|
|||||||
for module in model.modules():
|
for module in model.modules():
|
||||||
if isinstance(module, (torch.nn.Conv2d, torch.nn.Linear)):
|
if isinstance(module, (torch.nn.Conv2d, torch.nn.Linear)):
|
||||||
if shared.opts.cache_fp16_weight:
|
if shared.opts.cache_fp16_weight:
|
||||||
module.fp16_weight = module.weight.clone().half()
|
module.fp16_weight = module.weight.data.clone().cpu().half()
|
||||||
if module.bias is not None:
|
if module.bias is not None:
|
||||||
module.fp16_bias = module.bias.clone().half()
|
module.fp16_bias = module.bias.data.clone().cpu().half()
|
||||||
module.to(torch.float8_e4m3fn)
|
module.to(torch.float8_e4m3fn)
|
||||||
model.first_stage_model = first_stage
|
model.first_stage_model = first_stage
|
||||||
timer.record("apply fp8")
|
timer.record("apply fp8")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user