Repository navigation
| EN | 中文 |
1. What changed, and why
1.1 Background: ComfyUI v0.38 introduced fast_disk
From ComfyUI v0.38 on, fast-disk (aimdo virtual VRAM) is enabled by default for every model loader. ModelPatcher.clone() now unconditionally passes a new keyword when re-instantiating the patcher class:
# comfy/model_patcher.py (v0.38.x, clone())
n = class_(model_override[0], self.load_device, self.offload_device, self.model_size(),
weight_inplace_update=self.weight_inplace_update, fast_disk=self.fast_disk)The base ModelPatcher.__init__ declares fast_disk=False, but the subclass ZImageModelPatcher never followed its signature.
1.2 The symptom
ComfyUI-nunchaku (upstream development has stopped) defines, in model_patcher/zimage.py:
class ZImageModelPatcher(ModelPatcher):
def __init__(self, model, load_device, offload_device, size=0, weight_inplace_update=False):
super().__init__(model, load_device, offload_device, size, weight_inplace_update=False)
self.svdq_backup = {}Every node that calls model.clone() on a nunchaku Z-Image model (e.g. the EasyCache node inside the sampling chain) dies with:
TypeError: ZImageModelPatcher.__init__() got an unexpected keyword argument 'fast_disk'
The failed clone also triggers a follow-up AttributeError: 'ZImageModelPatcher' object has no attribute 'pinned' when the half-constructed object is garbage-collected (__del__ -> unpin_all_weights).
2. The fix: an in-memory runtime wrapper (nunchaku files untouched)
patches/nunchaku_patch.py gains apply_nunchaku_zimage_fast_disk_patch():
- Wraps
ZImageModelPatcher.__init__with a shim that accepts and stores thefast_diskkeyword (self.fast_disk = ...) and forwards everything else to the original__init__. - Idempotent: the wrapper carries a
_qwen_lora_loader_zimage_fast_disk_patchtag; repeated calls short-circuit. - Future-proof: if a later nunchaku build already declares
fast_diskin its signature, the patch no-ops automatically. sys.modulesscan only, never re-importing: ComfyUI loads packs under names likecustom_nodes.ComfyUI-nunchaku.model_patcher.zimage; importing the module again would create a second module instance and patch a class nobody uses.- Load-order safe: this package often loads before ComfyUI-nunchaku (folder name order). The patch shares the existing retry timer (0.25 s x 24 attempts) already used for the fuse-patch and applies as soon as the nunchaku module shows up.
- No new entry point: it runs inside
apply_nunchaku_patch()(called from this package's__init__.py), next to the rotary shim, lazy-Linear and copy_params patches.
3. Repository state after this release
| Path | Change | Note |
|---|---|---|
patches/nunchaku_patch.py |
+79 / -3 | new apply_nunchaku_zimage_fast_disk_patch(), wired into apply_nunchaku_patch() and the retry timer |
| ComfyUI-nunchaku package files | unchanged | the fix lives entirely in this package's runtime patch |
pyproject.toml / __init__.py |
version | 2.6.6 -> 2.6.7 |
4. What was verified
- Standalone construction test: before the patch the
fast_diskparameter is absent; after the patch, v0.38-styleclone()calls (positional args +weight_inplace_update=+fast_disk=True) succeed,fast_diskis stored, andsvdq_backup/pinnedremain intact. - Legacy calls (no
fast_diskkeyword) are unaffected and default toFalse. - Idempotency: a second call returns success without double-wrapping.
- Real end-to-end: the full mixed workflow on ComfyUI v0.38.1 - HSWQ ConvRot NVFP4 UNet + INT8 ConvRot ControlNet (180 runtime patches) + EasyCache - completed (7/7 and 5/5 sampling passes, zero exceptions).
5. Action required
- Update this package to v2.6.7 (ComfyUI Manager / git pull) and restart ComfyUI.
- No workflow edits and no nunchaku changes are needed.
6. Notes
- This issue surfaced while validating a ComfyUI v0.38.1 upgrade. The other problems from the same investigation (fast-disk native read serialization, the quantized-weight requantize crash, and migrating the DiT quant-lock guard from comfy/ops.py into the node side) were fixed in the ComfyUI-HSWQ-Loader-and-Tools repository and are not part of this package.