Spaces:
Running
on
Zero
Running
on
Zero
Update comfy/float.py
Browse files- comfy/float.py +3 -2
comfy/float.py
CHANGED
@@ -60,8 +60,9 @@ def stochastic_rounding(value, dtype, seed=0):
|
|
60 |
output = torch.empty_like(value, dtype=dtype)
|
61 |
num_slices = max(1, (value.numel() / (4096 * 4096)))
|
62 |
slice_size = max(1, round(value.shape[0] / num_slices))
|
63 |
-
|
64 |
-
|
|
|
65 |
return output
|
66 |
|
67 |
return value.to(dtype=dtype)
|
|
|
60 |
output = torch.empty_like(value, dtype=dtype)
|
61 |
num_slices = max(1, (value.numel() / (4096 * 4096)))
|
62 |
slice_size = max(1, round(value.shape[0] / num_slices))
|
63 |
+
with torch.no_grad():
|
64 |
+
for i in range(0, value.shape[0], slice_size):
|
65 |
+
output[i:i+slice_size].copy_(manual_stochastic_round_to_float8(value[i:i+slice_size], dtype, generator=generator))
|
66 |
return output
|
67 |
|
68 |
return value.to(dtype=dtype)
|