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.

Comfy Aimdo 0.5.6 + Fix qwen 2.1 rogues in low VRAM conditions (#16870)

rattusb28cb564e3ab
diff --git a/comfy/ldm/wan/model_animate2.py b/comfy/ldm/wan/model_animate2.py
index cdcc1fbd7..ce6152850 100644
--- a/comfy/ldm/wan/model_animate2.py
+++ b/comfy/ldm/wan/model_animate2.py
@@ -11,6 +11,7 @@ import torch
import comfy.ldm.common_dit
import comfy.model_management
+import comfy.model_prefetch
import comfy.quant_ops
import comfy.utils
from comfy.ldm.flux.math import apply_rope1
@@ -200,16 +201,17 @@ class PoseBranchCache:
stream = None
r = None
if t.device != device:
- stream = comfy.model_management.get_offload_stream(device)
- cs = comfy.model_management.current_stream(device)
- if stream is not None and cs is not None:
- # the handed-out stream last waited on the main stream a full rotation ago, which does not cover the previous consumer's reads of this slot; wait now so the copy cannot overwrite a slot still being read
- stream.wait_stream(cs)
# two persistent staging buffers per tensor shape instead of a fresh allocation per block (~29 GB of churn per pass at 720p); windows of different lengths get their own pair
buf_key = (tuple(t.shape), cast_dtype if cast_dtype is not None else t.dtype)
if buf_key not in self._staging:
- self._staging[buf_key] = [torch.empty(t.shape, dtype=buf_key[1], device=device) for _ in range(2)]
+ with comfy.model_prefetch.pause_malloc_graph():
+ self._staging[buf_key] = [torch.empty(t.shape, dtype=buf_key[1], device=device) for _ in range(2)]
r = self._staging[buf_key][i % 2]
+ stream = comfy.model_management.get_offload_stream(device)
+ cs = comfy.model_management.current_stream(device)
+ if stream is not None and cs is not None:
+ # Wait for staging allocation and the previous consumer's reads before overwriting the buffer.
+ stream.wait_stream(cs)
self._pending[i] = (comfy.model_management.cast_to(t, cast_dtype, device, non_blocking=True, stream=stream, r=r), stream)
def take(self, i, device, dtype, batch_size):
diff --git a/requirements.txt b/requirements.txt
index 88843965e..7276a8d2a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -22,7 +22,7 @@ SQLAlchemy>=2.0.0
filelock
av>=17.0.0
comfy-kitchen==0.2.37
-comfy-aimdo==0.5.5
+comfy-aimdo==0.5.6
requests
simpleeval>=1.0.0
blake3