ComfyUI keeps loading models on every prompt change
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 158
Description
### Custom Node Testing
- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)
### Expected Behavior
When changing a prompt, editing text in the prompt, on clicking RUN, Comfy should process the prompt and create the image.
Once the model is in memory, and the Text encoder is loaded, it should remain in memory unless the user requests other models.
### Actual Behavior
ComfyUI runs inference
If the prompt is not changed, the disk does not read again.
If the user changes anything in the prompt, the application reads from the disk and takes time to process and then renders the image.
### Steps to Reproduce
Create a simple workflow
- Add a diffusion model loader node (In this example - Krea2)
- Add a prompt to the CLIP Text Encode box
- Run and preview the image
- - Run again, and the inference is noticeably faster.
- Change the prompt to something else
- - ComfyUI takes time to load the model
- - Comfyui then starts the inference after loading the model again
### Debug Logs
```powershell
C:\ComfyUI>call C:\ComfyUI\venv\Scripts\activate.bat
[INFO] Adding extra search path checkpoints C:\ComfyUI\path\to\stable-diffusion-webui\models\Stable-diffusion
[INFO] Adding extra search path configs C:\ComfyUI\path\to\stable-diffusion-webui\models\Stable-diffusion
[INFO] Adding extra search path vae C:\ComfyUI\path\to\stable-diffusion-webui\models\VAE
[INFO] Adding extra search path loras C:\ComfyUI\path\to\stable-diffusion-webui\models\Lora
[INFO] Adding extra search path loras C:\ComfyUI\path\to\stable-diffusion-webui\models\LyCORIS
[INFO] Adding extra search path upscale_models C:\ComfyUI\path\to\stable-diffusion-webui\models\ESRGAN
[INFO] Adding extra search path upscale_models C:\ComfyUI\path\to\stable-diffusion-webui\models\RealESRGAN
[INFO] Adding extra search path upscale_models C:\ComfyUI\path\to\stable-diffusion-webui\models\SwinIR
[INFO] Adding extra search path embeddings C:\ComfyUI\path\to\stable-diffusion-webui\embeddings
[INFO] Adding extra search path hypernetworks C:\ComfyUI\path\to\stable-diffusion-webui\models\hypernetworks
[INFO] Adding extra search path controlnet C:\ComfyUI\path\to\stable-diffusion-webui\models\ControlNet
[INFO] Adding extra search path checkpoints C:\AI\Models
[INFO] Adding extra search path clip C:\AI\Clip
[INFO] Adding extra search path clip_vision C:\AI\Clip_Vision
[INFO] Adding extra search path controlnet C:\AI\ControlNet
[INFO] Adding extra search path embeddings C:\AI\Styles
[INFO] Adding extra search path loras C:\AI\Lora
[INFO] Adding extra search path upscale_models C:\AI\Scaling Models
[INFO] Adding extra search path vae C:\AI\VAE
[INFO] Adding extra search path animatediff_models C:\AI\Animatediff
[INFO] Adding extra search path animatediff_motion_lora C:\AI\Lora\Animatediff
[INFO] Adding extra search path ipadapter C:\AI\ControlNet
[INFO] Adding extra search path checkpoints D:\AI\ComfyUI\models\diffusion_models
[INFO] Adding extra search path checkpoints D:\AI\ComfyUI\models\unet
[INFO] Adding extra search path checkpoints C:\ComfyUI\models\diffusion_models
[INFO] Adding extra search path checkpoints C:\ComfyUI\models\unet
C:\ComfyUI\venv\lib\site-packages\triton\knobs.py:212: UserWarning: Failed to find cuobjdump.exe
warnings.warn(f"Failed to find {binary}")
C:\ComfyUI\venv\lib\site-packages\triton\knobs.py:212: UserWarning: Failed to find nvdisasm.exe
warnings.warn(f"Failed to find {binary}")
[WARNING] WARNING: You need pytorch with cu130 or higher to use optimized CUDA operations.
[INFO] Found comfy_kitchen backend triton: {'available': True, 'disabled': True, 'unavailable_reason': None, 'capabilities': ['apply_rope', 'apply_rope1', 'apply_rope_split_half', 'apply_rope_split_half1', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8']}
[INFO] Found comfy_kitchen backend eager: {'available': True, 'disabled': False, 'unavailable_reason': None, 'capabilities': ['apply_rope', 'apply_rope1', 'apply_rope_split_half', 'apply_rope_split_half1', 'dequantize_mxfp8', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'gemv_awq_w4a16', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'quantize_svdquant_w4a4', 'scaled_mm_mxfp8', 'scaled_mm_nvfp4', 'scaled_mm_svdquant_w4a4', 'stochastic_rounding_fp8']}
[INFO] Found comfy_kitchen backend cuda: {'available': True, 'disabled': True, 'unavailable_reason': None, 'capabilities': ['apply_rope', 'apply_rope1', 'apply_rope_split_half', 'apply_rope_split_half1', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'gemv_awq_w4a16', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'quantize_svdquant_w4a4', 'scaled_mm_svdquant_w4a4', 'stochastic_rounding_fp8']}
[INFO] Checkpoint files will always be loaded safely.
[INFO] Total VRAM 12287 MB, total RAM 32751 MB
[INFO] pytorch version: 2.9.0+cu126
[INFO] Set vram state to: NORMAL_VRAM
[INFO] Device: cuda:0 NVIDIA GeForce RTX 3060 : cudaMallocAsync
[INFO] Using async weight offloading with 2 streams
[INFO] Enabled pinned memory 13100.0
[INFO] working around nvidia conv3d memory bug.
[INFO] Using pytorch attention
aimdo: src-win/cuda-detour.c:38:INFO:aimdo_setup_hooks: installing 6 hooks
aimdo: src-win/cuda-detour.c:28:DEBUG:install_hook_entries: hooks successfully installed
aimdo: src-win/shmem-detect.c:80:INFO:comfy-aimdo WDDM adapter match: NVIDIA GeForce RTX 3060 runtime_luid=00000000:00010306 dxgi_luid=00000000:00010306
aimdo: src/control.c:248:INFO:comfy-aimdo inited for GPU: NVIDIA GeForce RTX 3060 (VRAM: 12287 MB)
[INFO] DynamicVRAM support detected and enabled
[INFO] Python version: 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)]
[INFO] ComfyUI version: 0.26.0
[INFO] comfy-aimdo version: 0.4.10
[INFO] comfy-kitchen version: 0.2.10
[INFO] comfyui-frontend-package version: 1.45.19
[INFO] comfyui-workflow-templates version: 0.10.2
[INFO] comfyui-embedded-docs version: 0.5.5
[INFO] comfy-kitchen version: 0.2.10
[INFO] comfy-aimdo version: 0.4.10
[INFO] [Prompt Server] web root: C:\ComfyUI\venv\lib\site-packages\comfyui_frontend_package\static
[INFO] Asset seeder disabled
[INFO] Skipping loading of custom nodes
[INFO] Context impl SQLiteImpl.
[INFO] Will assume non-transactional DDL.
[INFO] Using RAM pressure cache.
[INFO] Starting server
[INFO] To see the GUI go to: http://127.0.0.1:8188
[INFO] got prompt
[INFO] Using pytorch attention in VAE
[INFO] Using pytorch attention in VAE
[INFO] VAE load device: cuda:0, offload device: cpu, dtype: torch.bfloat16
[INFO] CLIP/text encoder model load device: cuda:0, offload device: cpu, current: cpu, dtype: torch.float16
[INFO] Requested to load Krea2TEModel_
[INFO] Model Krea2TEModel_ prepared for dynamic VRAM loading. 8463MB Staged. 0 patches attached. Force pre-loaded 249 weights: 627 KB.
[INFO] Found quantization metadata version 1
[INFO] Detected mixed precision quantization
[INFO] Using mixed precision operations
[INFO] Native ops: , emulated ops: float8_e5m2, mxfp8, float8_e4m3fn, nvfp4
[INFO] model weight dtype torch.bfloat16, manual cast: torch.bfloat16
[INFO] model_type FLUX
[WARNING] unet unexpected: ['last.down.weight_scale', 'last.up.weight_scale', 'last.down.weight', 'last.up.weight', 'last.down.comfy_quant', 'last.up.comfy_quant']
[INFO] Requested to load Krea2
[INFO] Model Krea2 prepared for dynamic VRAM loading. 12225MB Staged. 0 patches attached. Force pre-loaded 160 weights: 2824 KB.
100%|████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:51<00:00, 6.42s/it]
[INFO] Requested to load WanVAE
[INFO] 0 models unloaded.
[INFO] Model WanVAE prepared for dynamic VRAM loading. 241MB Staged. 0 patches attached. Force pre-loaded 60 weights: 61 KB.
[INFO] Prompt executed in 103.64 seconds
[INFO] got prompt
[INFO] Model Krea2 prepared for dynamic VRAM loading. 12225MB Staged. 0 patches attached. Force pre-loaded 160 weights: 2824 KB.
100%|████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:48<00:00, 6.01s/it]
[INFO] 0 models unloaded.
[INFO] Model WanVAE prepared for dynamic VRAM loading. 241MB Staged. 0 patches attached. Force pre-loaded 60 weights: 61 KB.
[INFO] Prompt executed in 49.14 seconds
[INFO] got prompt
[INFO] Model Krea2 prepared for dynamic VRAM loading. 12225MB Staged. 0 patches attached. Force pre-loaded 160 weights: 2824 KB.
100%|████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:50<00:00, 6.29s/it]
[INFO] 0 models unloaded.
[INFO] Model WanVAE prepared for dynamic VRAM loading. 241MB Staged. 0 patches attached. Force pre-loaded 60 weights: 61 KB.
[INFO] Prompt executed in 51.82 seconds
[INFO] got prompt
[INFO] Prompt executed in 0.03 seconds
[INFO] got prompt
[INFO] Model Krea2 prepared for dynamic VRAM loading. 12225MB Staged. 0 patches attached. Force pre-loaded 160 weights: 2824 KB.
100%|████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:51<00:00, 6.42s/it]
[INFO] 0 models unloaded.
[INFO] Model WanVAE prepared for dynamic VRAM loading. 241MB Staged. 0 patches attached. Force pre-loaded 60 weights: 61 KB.
[INFO] Prompt executed in 52.40 seconds
[INFO] got prompt
[INFO] Model Krea2TEModel_ prepared for dynamic VRAM loading. 8463MB Staged. 0 patches attached. Force pre-loaded 249 weights: 627 KB.
[INFO] 0 models unloaded.
[INFO] Model Krea2 prepared for dynamic VRAM loading. 12225MB Staged. 0 patches attached. Force pre-loaded 160 weights: 2824 KB.
100%|████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:56<00:00, 7.01s/it]
[INFO] 0 models unloaded.
[INFO] Model WanVAE prepared for dynamic VRAM loading. 241MB Staged. 0 patches attached. Force pre-loaded 60 weights: 61 KB.
[INFO] Prompt executed in 98.34 seconds
[INFO] got prompt
[INFO] Model Krea2 prepared for dynamic VRAM loading. 12225MB Staged. 0 patches attached. Force pre-loaded 160 weights: 2824 KB.
100%|████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:56<00:00, 7.05s/it]
[INFO] 0 models unloaded.
[INFO] Model WanVAE prepared for dynamic VRAM loading. 241MB Staged. 0 patches attached. Force pre-loaded 60 weights: 61 KB.
[INFO] Prompt executed in 58.72 seconds
```
### Other
This happened after some recent updates. I'm unsure of when this started happening. However, previously, everything was cached in memory, and the disk didn't keep reading. Right now, even though I have free memory, the memory is not used, and the disk is used on every change.
While I have an SSD, if this kept happening on a hard disk, the inference time would be very slow.
The model I've tested in this case is Krea2. This happens with most other models as well.
Contributor guide
Research direction
Start by reproducing the simple workflow with a diffusion model loader, CLIP Text Encode node, and Krea2 while watching the prompt-execution logs. Compare runs with an unchanged prompt and with edited prompt text, focusing on the reported dynamic VRAM loading and disk reads. Done means changing the prompt does not reload models that remain eligible in memory, while inference still completes correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100