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.

Reduce memory usage for fp8 scaled op. (#10531)

comfyanonymous1a58087ac2eb
diff --git a/comfy/quant_ops.py b/comfy/quant_ops.py
index b14e03084..fb35a0d40 100644
--- a/comfy/quant_ops.py
+++ b/comfy/quant_ops.py
@@ -358,7 +358,7 @@ class TensorCoreFP8Layout(QuantizedLayout):
scale = scale.to(device=tensor.device, dtype=torch.float32)
lp_amax = torch.finfo(dtype).max
- tensor_scaled = tensor.float() / scale
+ tensor_scaled = tensor * (1.0 / scale).to(tensor.dtype)
torch.clamp(tensor_scaled, min=-lp_amax, max=lp_amax, out=tensor_scaled)
qdata = tensor_scaled.to(dtype, memory_format=torch.contiguous_format)