Add fp8 for sd unet

This commit is contained in:
Kohaku-Blueleaf
2023-10-19 13:56:17 +08:00
parent 861cbd5636
commit 7c128bbdac
11 changed files with 36 additions and 32 deletions

View File

@@ -391,6 +391,9 @@ def load_model_weights(model, checkpoint_info: CheckpointInfo, state_dict, timer
devices.dtype_unet = torch.float16
timer.record("apply half()")
if shared.cmd_opts.opt_unet_fp8_storage:
model.model.diffusion_model = model.model.diffusion_model.to(torch.float8_e4m3fn)
timer.record("apply fp8 unet")
devices.unet_needs_upcast = shared.cmd_opts.upcast_sampling and devices.dtype == torch.float16 and devices.dtype_unet == torch.float16