Skip to content

Commit 73e3a9e

Browse files
Clamp output when rounding weight to prevent Nan.
1 parent 518c0dc commit 73e3a9e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

comfy/float.py

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def manual_stochastic_round_to_float8(x, dtype, generator=None):
4141
(2.0 ** (-EXPONENT_BIAS + 1)) * abs_x
4242
)
4343

44+
inf = torch.finfo(dtype)
45+
torch.clamp(sign, min=inf.min, max=inf.max, out=sign)
4446
return sign
4547

4648

0 commit comments

Comments
 (0)