Skip to content

Commit

Permalink
Clamp output when rounding weight to prevent Nan.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Oct 19, 2024
1 parent 518c0dc commit 73e3a9e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions comfy/float.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 73e3a9e

Please sign in to comment.