From 73e3a9e67654d5b20054da02c6a77311af527364 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sat, 19 Oct 2024 19:07:10 -0400 Subject: [PATCH] Clamp output when rounding weight to prevent Nan. --- comfy/float.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/comfy/float.py b/comfy/float.py index 0c8f1d6c..521316fd 100644 --- a/comfy/float.py +++ b/comfy/float.py @@ -41,6 +41,8 @@ def manual_stochastic_round_to_float8(x, dtype, generator=None): (2.0 ** (-EXPONENT_BIAS + 1)) * abs_x ) + inf = torch.finfo(dtype) + torch.clamp(sign, min=inf.min, max=inf.max, out=sign) return sign