fix: add torch.inference_mode to worker thread for Dynamic VRAM compat

Worker threads run outside ComfyUI's execution engine which wraps
everything in torch.inference_mode(). Without it, Dynamic VRAM's lazy
weight loading produces NaN during VAE decode, causing black images.
Matches ComfyUI's execution.py:703 pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
JasonHoku
2026-03-07 14:06:56 -08:00
co-authored by Claude Opus 4.6
parent 1830713bd2
commit 3003fb8193
+6
View File
@@ -434,6 +434,7 @@ class WorkerThread(threading.Thread):
print(f"[Worker {self.worker_id}] ⚠️ Claim failed: {e}")
return None
@torch.inference_mode()
def _process_job(self, job):
"""
Process a single job using local ComfyUI infrastructure.
@@ -451,6 +452,11 @@ class WorkerThread(threading.Thread):
Returns:
tuple: (image_bytes, metadata_dict)
Note: @torch.inference_mode() is required because worker threads run
outside ComfyUI's execution engine which wraps everything in
inference_mode. Without it, Dynamic VRAM's lazy weight loading can
produce NaN values during VAE decode.
"""
from .model_loader import (
load_checkpoint, load_loras, load_vae_by_name,