diff options
author | Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> | 2023-10-19 05:56:17 +0000 |
---|---|---|
committer | Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> | 2023-10-19 05:56:17 +0000 |
commit | 7c128bbdac0da1767c239174e91af6f327845372 (patch) | |
tree | c7c8b1271c17bab0f5e71ea1d97a21bbbc85332e /modules | |
parent | 861cbd56363ffa0df3351cf1162f507425a178cd (diff) | |
download | stable-diffusion-webui-gfx803-7c128bbdac0da1767c239174e91af6f327845372.tar.gz stable-diffusion-webui-gfx803-7c128bbdac0da1767c239174e91af6f327845372.tar.bz2 stable-diffusion-webui-gfx803-7c128bbdac0da1767c239174e91af6f327845372.zip |
Add fp8 for sd unet
Diffstat (limited to 'modules')
-rw-r--r-- | modules/cmd_args.py | 1 | ||||
-rw-r--r-- | modules/sd_models.py | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/modules/cmd_args.py b/modules/cmd_args.py index 4e602a84..0f14c71e 100644 --- a/modules/cmd_args.py +++ b/modules/cmd_args.py @@ -118,3 +118,4 @@ parser.add_argument('--timeout-keep-alive', type=int, default=30, help='set time parser.add_argument("--disable-all-extensions", action='store_true', help="prevent all extensions from running regardless of any other settings", default=False)
parser.add_argument("--disable-extra-extensions", action='store_true', help="prevent all extensions except built-in from running regardless of any other settings", default=False)
parser.add_argument("--skip-load-model-at-start", action='store_true', help="if load a model at web start, only take effect when --nowebui", )
+parser.add_argument("--opt-unet-fp8-storage", action='store_true', help="use fp8 for SD UNet to save vram", default=False)
diff --git a/modules/sd_models.py b/modules/sd_models.py index 3b6cdea1..3b8ff820 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -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
|