Spaces:
Sleeping
Sleeping
Disable torch.compile for patcher wrapper functions
Browse filesPrevents excessive recompilations (hitting recompile_limit) in
WrapperExecutor.execute, new_executor, and new_class_executor.
These wrapper functions cause cache invalidations that trigger
unnecessary recompiles.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
comfy/patcher_extension.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
from typing import Callable
|
|
|
|
| 3 |
|
| 4 |
class CallbacksMP:
|
| 5 |
ON_CLONE = "on_clone"
|
|
@@ -103,6 +104,7 @@ class WrapperExecutor:
|
|
| 103 |
new_executor = self._create_next_executor()
|
| 104 |
return new_executor.execute(*args, **kwargs)
|
| 105 |
|
|
|
|
| 106 |
def execute(self, *args, **kwargs):
|
| 107 |
"""Used to initiate executor internally - DO NOT use this if you received executor in wrapper."""
|
| 108 |
args = list(args)
|
|
@@ -120,10 +122,12 @@ class WrapperExecutor:
|
|
| 120 |
return WrapperExecutor.new_class_executor(self.original, self.class_obj, self.wrappers, new_idx)
|
| 121 |
|
| 122 |
@classmethod
|
|
|
|
| 123 |
def new_executor(cls, original: Callable, wrappers: list[Callable], idx=0):
|
| 124 |
return cls(original, class_obj=None, wrappers=wrappers, idx=idx)
|
| 125 |
|
| 126 |
@classmethod
|
|
|
|
| 127 |
def new_class_executor(cls, original: Callable, class_obj: object, wrappers: list[Callable], idx=0):
|
| 128 |
return cls(original, class_obj, wrappers, idx=idx)
|
| 129 |
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
from typing import Callable
|
| 3 |
+
import torch
|
| 4 |
|
| 5 |
class CallbacksMP:
|
| 6 |
ON_CLONE = "on_clone"
|
|
|
|
| 104 |
new_executor = self._create_next_executor()
|
| 105 |
return new_executor.execute(*args, **kwargs)
|
| 106 |
|
| 107 |
+
@torch.compiler.disable
|
| 108 |
def execute(self, *args, **kwargs):
|
| 109 |
"""Used to initiate executor internally - DO NOT use this if you received executor in wrapper."""
|
| 110 |
args = list(args)
|
|
|
|
| 122 |
return WrapperExecutor.new_class_executor(self.original, self.class_obj, self.wrappers, new_idx)
|
| 123 |
|
| 124 |
@classmethod
|
| 125 |
+
@torch.compiler.disable
|
| 126 |
def new_executor(cls, original: Callable, wrappers: list[Callable], idx=0):
|
| 127 |
return cls(original, class_obj=None, wrappers=wrappers, idx=idx)
|
| 128 |
|
| 129 |
@classmethod
|
| 130 |
+
@torch.compiler.disable
|
| 131 |
def new_class_executor(cls, original: Callable, class_obj: object, wrappers: list[Callable], idx=0):
|
| 132 |
return cls(original, class_obj, wrappers, idx=idx)
|
| 133 |
|