Repository navigation
v2.4.9 - Unify Model Patch Memory Cleaner into General Purge VRAM V2
| EN | 中文 |
Overview
In v2.4.9, the standalone Model Patch Memory Cleaner custom node has been deprecated and officially unregistered from ComfyUI's node catalog (NODE_CLASS_MAPPINGS and NODE_DISPLAY_NAME_MAPPINGS). Its complete functionality has been fully consolidated into General Purge VRAM V2 (DisTorchPurgeVRAMV2) under the clear_model_patches toggle, accompanied by immediate physical CUDA memory recovery.
Technical Details & Architecture
1. Problem & Architectural Rationale
Previously, users running specialized patch workflows—such as ModelPatchLoader (Z-Image ControlNet, QwenImage BlockWise ControlNet, SigLIP MultiFeat Proj, etc.)—required placing an extra standalone Model Patch Memory Cleaner node prior to upscaling stages to prevent out-of-memory (OOM) exceptions.
While DisTorchPurgeVRAMV2 already featured a clear_model_patches toggle, an architectural discrepancy existed:
- In the standalone node, unloading model patches was immediately followed by:
if clean_gpu and torch.cuda.is_available(): torch.cuda.empty_cache() torch.cuda.synchronize() if force_gc: gc.collect()
- In
DisTorchPurgeVRAMV2,purge_cache(which executestorch.cuda.empty_cache()) ran at the very top of the node execution flow—before model patches were unloaded. Consequently, if a user configuredpurge_models = False(intending to retain the base Diffusion/UNet checkpoint while discarding patch weights), the patch models were unhooked from ComfyUI's tracking, but their GPU cache memory was not immediately reclaimed by the caching allocator, delaying physical VRAM release.
2. Complete Functional Consolidation into DisTorchPurgeVRAMV2
In this release, DisTorchPurgeVRAMV2 (in both nodes/purge_vram.py and root purge_vram.py) now provides full functional parity with the standalone cleaner:
- ModelPatcher Inspection: Scans
current_loaded_modelsin reverse order forModelPatcherinstances with activeadditional_modelsorattachments. - Safe Unload & De-registration: Marks models as unused (
currently_used = False), executesmodel_unload(), and pops them fromcurrent_loaded_models. - ComfyUI GC: Calls
comfy.model_management.cleanup_models_gc(). - Instant Physical VRAM Release: Directly executes:
if torch.cuda.is_available(): torch.cuda.empty_cache() torch.cuda.synchronize() print("GPU memory cleared") gc.collect() print("Garbage collection completed") print("Model patch memory cleanup completed")
This guarantees immediate, deterministic physical VRAM recovery even when purge_models=False.
3. Node Unregistration & Catalog Cleanup
The standalone ModelPatchMemoryCleaner has been removed from NODE_CLASS_MAPPINGS and NODE_DISPLAY_NAME_MAPPINGS in __init__.py.
- ComfyUI's node search palette now exposes only the three primary nodes:
General Purge VRAM V2(DisTorchPurgeVRAMV2)Memory Manager (Advanced)(MemoryManager)Patch Sage Attention DM(PatchSageAttentionDM)
- Workflows that previously utilized
Model Patch Memory Cleanershould seamlessly transition toGeneral Purge VRAM V2withclear_model_patches: True.
Migration Guide for Workflows
- Previous Workflow:
[ModelPatchLoader] → [ControlNet Node] → [Model Patch Memory Cleaner] → [Upscaler] - Recommended Workflow (v2.4.9+):
(To keep your base diffusion model loaded while discarding patch weights, set
[ModelPatchLoader] → [ControlNet Node] → [General Purge VRAM V2 (clear_model_patches=True)] → [Upscaler]clear_model_patches=Trueandpurge_models=False).