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.

Fix issue with bypass loras and fused paths. (#16862)

comfyanonymousd91ed5f5b7fa
diff --git a/comfy/ops.py b/comfy/ops.py
index 3ae8722b2..4fdbc0dac 100644
--- a/comfy/ops.py
+++ b/comfy/ops.py
@@ -500,6 +500,7 @@ class CastBiasWeightContext:
class CastWeightBiasOp:
comfy_cast_weights = False
+ comfy_force_forward = False
weight_function = []
bias_function = []
@@ -1019,7 +1020,7 @@ def linear_input_act(linear, x, input_act, act_weight=None, act_eps=0.0,
run_every_op()
weight = linear.weight
quantized = isinstance(weight, QuantizedTensor)
- if (comfy.model_management.in_training or getattr(linear, "_full_precision_mm", False)
+ if (comfy.model_management.in_training or getattr(linear, "comfy_force_forward", False) or getattr(linear, "_full_precision_mm", False)
or not ((quantized and weight._layout_cls == "TensorWiseINT8Layout"
and not getattr(weight._params, "transposed", False))
or (not quantized and _fp16_linear_wanted(x)))):
diff --git a/comfy/weight_adapter/bypass.py b/comfy/weight_adapter/bypass.py
index b9d5ec7d9..f97bd2c81 100644
--- a/comfy/weight_adapter/bypass.py
+++ b/comfy/weight_adapter/bypass.py
@@ -199,6 +199,8 @@ class BypassForwardHook:
self._move_adapter_weights_to_device(device, dtype)
self.original_forward = self.module.forward
+ self.original_force_forward = getattr(self.module, "comfy_force_forward", False)
+ self.module.comfy_force_forward = True
self.module.forward = self._bypass_forward
logging.debug(
f"[BypassHook] Injected bypass forward for {type(self.module).__name__} (adapter={type(self.adapter).__name__})"
@@ -255,6 +257,7 @@ class BypassForwardHook:
return # Not injected
self.module.forward = self.original_forward
+ self.module.comfy_force_forward = self.original_force_forward
self.original_forward = None
logging.debug(
f"[BypassHook] Ejected bypass forward for {type(self.module).__name__}"