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.

Respect the dtype the op was initialized in for non quant mixed op. (#11282)

comfyanonymous5495589db384
diff --git a/comfy/ops.py b/comfy/ops.py
index 6f34d50fc..6ae6e791a 100644
--- a/comfy/ops.py
+++ b/comfy/ops.py
@@ -497,8 +497,10 @@ def mixed_precision_ops(quant_config={}, compute_dtype=torch.bfloat16, full_prec
) -> None:
super().__init__()
- self.factory_kwargs = {"device": device, "dtype": MixedPrecisionOps._compute_dtype}
- # self.factory_kwargs = {"device": device, "dtype": dtype}
+ if dtype is None:
+ dtype = MixedPrecisionOps._compute_dtype
+
+ self.factory_kwargs = {"device": device, "dtype": dtype}
self.in_features = in_features
self.out_features = out_features
@@ -530,7 +532,10 @@ def mixed_precision_ops(quant_config={}, compute_dtype=torch.bfloat16, full_prec
layer_conf = json.loads(layer_conf.numpy().tobytes())
if layer_conf is None:
- self.weight = torch.nn.Parameter(weight.to(device=device, dtype=MixedPrecisionOps._compute_dtype), requires_grad=False)
+ dtype = self.factory_kwargs["dtype"]
+ self.weight = torch.nn.Parameter(weight.to(device=device, dtype=dtype), requires_grad=False)
+ if dtype != MixedPrecisionOps._compute_dtype:
+ self.comfy_cast_weights = True
else:
self.quant_format = layer_conf.get("format", None)
if not self._full_precision_mm: