Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions comfy/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import comfy.rmsnorm
import contextlib

def run_every_op():
comfy.model_management.throw_exception_if_processing_interrupted()

def scaled_dot_product_attention(q, k, v, *args, **kwargs):
return torch.nn.functional.scaled_dot_product_attention(q, k, v, *args, **kwargs)
Expand Down Expand Up @@ -109,6 +111,7 @@ def forward_comfy_cast_weights(self, input):
return torch.nn.functional.linear(input, weight, bias)

def forward(self, *args, **kwargs):
run_every_op()
if self.comfy_cast_weights or len(self.weight_function) > 0 or len(self.bias_function) > 0:
return self.forward_comfy_cast_weights(*args, **kwargs)
else:
Expand All @@ -123,6 +126,7 @@ def forward_comfy_cast_weights(self, input):
return self._conv_forward(input, weight, bias)

def forward(self, *args, **kwargs):
run_every_op()
if self.comfy_cast_weights or len(self.weight_function) > 0 or len(self.bias_function) > 0:
return self.forward_comfy_cast_weights(*args, **kwargs)
else:
Expand All @@ -137,6 +141,7 @@ def forward_comfy_cast_weights(self, input):
return self._conv_forward(input, weight, bias)

def forward(self, *args, **kwargs):
run_every_op()
if self.comfy_cast_weights or len(self.weight_function) > 0 or len(self.bias_function) > 0:
return self.forward_comfy_cast_weights(*args, **kwargs)
else:
Expand All @@ -151,6 +156,7 @@ def forward_comfy_cast_weights(self, input):
return self._conv_forward(input, weight, bias)

def forward(self, *args, **kwargs):
run_every_op()
if self.comfy_cast_weights or len(self.weight_function) > 0 or len(self.bias_function) > 0:
return self.forward_comfy_cast_weights(*args, **kwargs)
else:
Expand All @@ -165,6 +171,7 @@ def forward_comfy_cast_weights(self, input):
return torch.nn.functional.group_norm(input, self.num_groups, weight, bias, self.eps)

def forward(self, *args, **kwargs):
run_every_op()
if self.comfy_cast_weights or len(self.weight_function) > 0 or len(self.bias_function) > 0:
return self.forward_comfy_cast_weights(*args, **kwargs)
else:
Expand All @@ -183,6 +190,7 @@ def forward_comfy_cast_weights(self, input):
return torch.nn.functional.layer_norm(input, self.normalized_shape, weight, bias, self.eps)

def forward(self, *args, **kwargs):
run_every_op()
if self.comfy_cast_weights or len(self.weight_function) > 0 or len(self.bias_function) > 0:
return self.forward_comfy_cast_weights(*args, **kwargs)
else:
Expand All @@ -202,6 +210,7 @@ def forward_comfy_cast_weights(self, input):
# return torch.nn.functional.rms_norm(input, self.normalized_shape, weight, self.eps)

def forward(self, *args, **kwargs):
run_every_op()
if self.comfy_cast_weights or len(self.weight_function) > 0 or len(self.bias_function) > 0:
return self.forward_comfy_cast_weights(*args, **kwargs)
else:
Expand All @@ -223,6 +232,7 @@ def forward_comfy_cast_weights(self, input, output_size=None):
output_padding, self.groups, self.dilation)

def forward(self, *args, **kwargs):
run_every_op()
if self.comfy_cast_weights or len(self.weight_function) > 0 or len(self.bias_function) > 0:
return self.forward_comfy_cast_weights(*args, **kwargs)
else:
Expand All @@ -244,6 +254,7 @@ def forward_comfy_cast_weights(self, input, output_size=None):
output_padding, self.groups, self.dilation)

def forward(self, *args, **kwargs):
run_every_op()
if self.comfy_cast_weights or len(self.weight_function) > 0 or len(self.bias_function) > 0:
return self.forward_comfy_cast_weights(*args, **kwargs)
else:
Expand All @@ -262,6 +273,7 @@ def forward_comfy_cast_weights(self, input, out_dtype=None):
return torch.nn.functional.embedding(input, weight, self.padding_idx, self.max_norm, self.norm_type, self.scale_grad_by_freq, self.sparse).to(dtype=output_dtype)

def forward(self, *args, **kwargs):
run_every_op()
if self.comfy_cast_weights or len(self.weight_function) > 0 or len(self.bias_function) > 0:
return self.forward_comfy_cast_weights(*args, **kwargs)
else:
Expand Down