# 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 > [!WARNING] > **Remove all folklore "performance" CLI flags copied from old tutorials.** Official ComfyUI troubleshooting explicitly warns that most third-party performance flag combinations do the opposite and trigger bugs or slower runs. When Dynamic VRAM is active, `--lowvram` does nothing, and forcing `--novram`, `--force-fp16`, or `--disable-smart-memory` degrades speed and stability. Run `python main.py` cleanly first, then add targeted flags only when solving a specific need: | Flag | Purpose | | --- | --- | | `--vram-headroom ` | Extra free VRAM buffer Dynamic VRAM keeps untouched for games, browsers, or monitors (or use `--reserve-vram `) | | `--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 ` 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-graphs` or `--disable-comfy-compiler` are 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 embedded `comfy_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 `--fast` while 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 `.safetensors` quantization (`convrot int8`, `w6a8`, `FP8`, or `NVFP4` on 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 Decode` to **`VAE Decode (Tiled)`** (and `VAE Encode` to **`VAE Encode (Tiled)`** for large Img2Img inputs) with `tile_size: 512` (`256 - 384` if tight) and `overlap: 64`. ## Built-in step caching and `torch.compile` ComfyUI includes native step-caching and compilation nodes without needing third-party forks: * **`EasyCache` and `LazyCache`:** built-in nodes that skip redundant transformer work across middle steps when output residuals barely change. Attach `EasyCache` after your model loader for fast speedups across modern DiT and video models (`LazyCache` trades a bit of efficiency for universal node compatibility). * **Architecture-specific caches:** use **`Flux KV Cache`** (`FluxKVCache`) for multi-reference Flux edits and **`Qwen Image 2.1 Cache`** (`QwenImage21Cache`) on Qwen-Image 2.1 workflows. * **`TorchCompileModel`:** compiles the diffusion graph with `torch.compile` for 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 Checkpoint` or `CLIP Text Encode (Prompt)`. When only the `KSampler` seed 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_size` on your empty latent node to `2 - 4` when 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 = 1` and increase the queue **Batch count** in the top bar so variations render cleanly one after another. * **Systematic testing:** lock `control_after_generate: fixed` while tuning `cfg`, `steps`, or LoRA strengths one variable at a time. Hit an error? Check [Troubleshooting & FAQ](./troubleshooting.md).