aboutsummaryrefslogtreecommitdiffstats
path: root/modules/devices.py
diff options
context:
space:
mode:
authorKohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com>2024-01-09 15:23:40 +0000
committerKohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com>2024-01-09 15:23:40 +0000
commit58d5b042cd02f287faabef399134b97d323691f2 (patch)
tree951a6ed341910c493805531da0055f1caf164bb8 /modules/devices.py
parent1fd69655fe340325863cbd7bf5297e034a6a3a0a (diff)
downloadstable-diffusion-webui-gfx803-58d5b042cd02f287faabef399134b97d323691f2.tar.gz
stable-diffusion-webui-gfx803-58d5b042cd02f287faabef399134b97d323691f2.tar.bz2
stable-diffusion-webui-gfx803-58d5b042cd02f287faabef399134b97d323691f2.zip
Apply the correct behavior of precision='full'
Diffstat (limited to 'modules/devices.py')
-rw-r--r--modules/devices.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/modules/devices.py b/modules/devices.py
index ad36f656..29a270d1 100644
--- a/modules/devices.py
+++ b/modules/devices.py
@@ -185,11 +185,14 @@ def autocast(disable=False):
if fp8 and device==cpu:
return torch.autocast("cpu", dtype=torch.bfloat16, enabled=True)
- if dtype == torch.float32:
- return contextlib.nullcontext()
-
if has_xpu() or has_mps() or cuda_no_autocast():
- return manual_cast(dtype_inference)
+ return manual_cast(dtype)
+
+ if fp8 and dtype_inference == torch.float32:
+ return manual_cast(dtype)
+
+ if dtype == torch.float32 or dtype_inference == torch.float32:
+ return contextlib.nullcontext()
return torch.autocast("cuda")