Performance & Optimization
Modern ComfyUI manages VRAM, asynchronous weight streaming, RAM pressure caching, and CUDA graphs automatically out of the box. Understanding what runs by default (and which legacy flags hurt performance) matters far more than copying old flag lists.
#Dynamic VRAM and async weight streaming
ComfyUI uses Dynamic VRAM and asynchronous weight offloading (--async-offload, enabled by default with 2 offload streams on NVIDIA GPUs):
- Active layers stream onto VRAM only as needed instead of blocking when a full diffusion model exceeds card memory.
- Even large open-source models can run on as little as 4 GB VRAM + 8 GB system RAM without manual layer-splitting flags.
- Keep 32 GB+ system RAM on desktop rigs running 12B+ diffusion or video models so streamed layers stay pinned in fast RAM instead of paging to disk.
#Launch flags: start with zero flags
Run python main.py cleanly first, then add targeted flags only when solving a specific need:
| Flag | Purpose |
|---|---|
--vram-headroom <GB> |
Extra free VRAM buffer Dynamic VRAM keeps untouched for games, browsers, or monitors (or use --reserve-vram <GB>) |
--fast-disk |
Forces disk-backed dynamic loading/offload over unpinned RAM when system memory is limited on a fast NVMe SSD |
--cache-ram [active] [inactive] |
Controls RAM pressure node caching (enabled by default); use --cache-none to trade rerun speed for minimum RAM |
--preview-method auto |
Enables sampler previews (--preview-method taesd uses high-quality TAESD decoders from models/vae_approx/) |
--offline |
Disables paid Partner Nodes and sets a strict frontend Content Security Policy blocking external network calls (--disable-partner-nodes hides API nodes alone) |
--disable-all-custom-nodes |
Cleanly boots core ComfyUI without custom node packs (--whitelist-custom-nodes <folders> isolates one pack while testing) |
Only workstations with plentiful VRAM running dedicated batch jobs should test --highvram or --gpu-only to keep weights resident and bypass Dynamic VRAM.
#Attention, Comfy Kitchen, and --fast
- Automatic defaults: ComfyUI automatically selects PyTorch SDPA / optimal attention kernels and enables the Comfy model compiler with CUDA graphs (
--disable-cuda-graphsor--disable-comfy-compilerare only for debugging graph breaks). - Comfy Kitchen (
--use-ck-attention): native high-speed quantized kernels for FP8, NVFP4, INT8, and attention (also selectable per model via embeddedcomfy_attention.config). - Optional external backends (
--use-sage-attention,--use-flash-attention): only enable if you installed the matching kernel packages and verified both speed and visual parity against default SDPA on your GPU. --fast [features...]: explicitly marked untested and potentially quality-degrading (fp16_accumulation,fp8_matrix_mult,cublas_ops,autotune). Never enable--fastwhile troubleshooting black outputs, NaNs, or subtle artifacts.
#Native quantization and Tiled VAE
- Use native quantization instead of GGUF: swap heavy 16-bit weights for native
.safetensorsquantization (convrot int8,w6a8,FP8, orNVFP4on RTX 50-series GPUs). Native formats run more than 2x faster than GGUF and integrate cleanly with Dynamic VRAM and LoRAs. - Tiled VAE for large pixels: if generation finishes sampling cleanly and crashes at 100% during decode, switch
VAE DecodetoVAE Decode (Tiled)(andVAE EncodetoVAE Encode (Tiled)for large Img2Img inputs) withtile_size: 512(256 - 384if tight) andoverlap: 64.
#Built-in step caching and torch.compile
ComfyUI includes native step-caching and compilation nodes without needing third-party forks:
EasyCacheandLazyCache: built-in nodes that skip redundant transformer work across middle steps when output residuals barely change. AttachEasyCacheafter your model loader for fast speedups across modern DiT and video models (LazyCachetrades a bit of efficiency for universal node compatibility).- Architecture-specific caches: use
Flux KV Cache(FluxKVCache) for multi-reference Flux edits andQwen Image 2.1 Cache(QwenImage21Cache) on Qwen-Image 2.1 workflows. TorchCompileModel: compiles the diffusion graph withtorch.compilefor higher steady-state throughput on repeated runs and batches (expect 30-90 seconds of compile warmup on the very first run).
#Workflow caching and organization
ComfyUI automatically caches every unchanged node output in memory:
- Keep loaders upstream: never connect changing seeds ahead of
Load CheckpointorCLIP Text Encode (Prompt). When only theKSamplerseed changes, ComfyUI skips reloading weights and re-encoding prompts completely. - Save intermediate latents (
Save Latent/Load Latent): cache heavy Pass 1 latents so you can tune Pass 2 upscaling or detailers without repeating base generation. - Use Subgraphs (
Ctrl + Shift + E) and Bypass (Ctrl + B): encapsulate clean reusable modules with Subgraphs, and bypass heavy upscalers while iterating on composition.
#Batching and parameter sweeps
- Latent batching: set
batch_sizeon your empty latent node to2 - 4when you have spare VRAM; GPUs compute small batches faster per image than sequential single runs. - Sequential queue count: when VRAM is tight, keep
batch_size = 1and increase the queue Batch count in the top bar so variations render cleanly one after another. - Systematic testing: lock
control_after_generate: fixedwhile tuningcfg,steps, or LoRA strengths one variable at a time.
Hit an error? Check Troubleshooting & FAQ.