Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Clamp output when rounding weight to prevent Nan.

comfyanonymous73e3a9e67654
diff --git a/comfy/float.py b/comfy/float.py
index 0c8f1d6cf..521316fd2 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