# ComfyUI Guide (complete) Every page of ComfyUI Guide (https://comfytut.mooshieblob.com) in one plain-ASCII Markdown document. Updated: 2026-12-01 Repository: https://github.com/Mooshieblob1/comfyui-site.github.io --- # Installation ComfyUI runs locally on Windows, Linux, and Apple Silicon macOS. Choose the path that fits your hardware and comfort level. > [!TIP] > Want a beginner-friendly interface without managing Python environments or node graphs by hand? [MooshieUI](https://mooshieui.com) wraps ComfyUI in a desktop or browser app with a one-click setup wizard for Windows, Linux, and Apple Silicon macOS. ## System Requirements | Component | Minimum | Recommended | | --- | --- | --- | | GPU (Windows / Linux) | NVIDIA RTX 20-series+ with 4-6 GB VRAM (Dynamic VRAM and async weight streaming run large models on 4 GB VRAM + 8 GB RAM), AMD ROCm (Linux / Windows 11), or Intel Arc XPU | NVIDIA RTX with 12 GB+ VRAM for fast iteration | | Apple Silicon | M1 / M2 / M3 / M4 with 16 GB unified memory | M2/M3/M4 Pro or Max with 32 GB+ unified memory | | System RAM | 8-16 GB (pair with Dynamic VRAM for weight streaming) | 32 GB+ (essential for multi-billion-parameter DiT and video models) | | Storage | 20 GB free SSD | 100 GB+ NVMe SSD for checkpoints and video weights | | Software | Python 3.12-3.14 (3.13 recommended), PyTorch 2.7+, CUDA `cu130`+ (NVIDIA RTX 20+), Git | Python 3.13 venv + current PyTorch (`cu130`+) + built-in ComfyUI-Manager | ## Desktop App The official [ComfyUI Desktop App](https://www.comfy.org/download) (Windows and macOS) is the recommended setup for most users. It bundles Python, Git, unified model/input/output folders, automatic update snapshots, built-in Apps, and **ComfyUI-Manager already set up**. 1. Download the Windows or macOS Apple Silicon installer from `comfy.org/download`. 2. Pick an install folder with plenty of free SSD space (avoid OneDrive-synced folders). 3. Launch ComfyUI Desktop, let it install PyTorch for your GPU, and open the workflow templates browser. If you prefer a command-line installer for local environments, install **`comfy-cli`** (`pip install comfy-cli && comfy install`). Want to run without local hardware setup? Comfy-Org also offers hosted [Comfy Cloud](https://www.comfy.org) workflows in your browser. ## Windows ### Windows Portable (standalone 7-Zip bundle) Official docs recommend the Desktop App for regular users, while Windows Portable gives you a self-contained folder you can move or back up easily without touching system Python. 1. Install [7-Zip](https://www.7-zip.org/) and [Git for Windows](https://git-scm.com/downloads/win). 2. Download the matching archive from the [ComfyUI Releases page](https://github.com/Comfy-Org/ComfyUI/releases): * **NVIDIA (RTX 20-series and newer, Python 3.13 + CUDA 13.0):** `ComfyUI_windows_portable_nvidia.7z` * **AMD Radeon (ROCm):** `ComfyUI_windows_portable_amd.7z` * **Intel Arc (XPU):** `ComfyUI_windows_portable_intel.7z` * **NVIDIA legacy (GTX 10-series and older, Python 3.12 + CUDA 12.6):** `ComfyUI_windows_portable_nvidia_cu126.7z` 3. Extract with 7-Zip directly to a short path such as `D:\ComfyUI` (avoid `Program Files` or paths with spaces). If Windows blocks extraction, right-click the archive -> **Properties** -> **Unblock**. 4. Run `run_nvidia_gpu.bat` (or `advanced\run_cpu.bat` on NVIDIA builds to run CPU-only; AMD/Intel portable users can launch CPU mode with `.\python_embeded\python.exe -s ComfyUI\main.py --cpu --windows-standalone-build`). 5. Open `http://127.0.0.1:8188` in your browser. Update your NVIDIA driver first if CUDA fails to initialize. > [!NOTE] > Use `update\update_comfyui.bat` to update ComfyUI inside the portable build without breaking its bundled Python environment. ### Manual Windows venv (for developers) ```powershell # Python 3.13 is recommended (3.12 works if an older custom node needs it; 3.14 is supported with occasional node incompatibilities) git clone https://github.com/Comfy-Org/ComfyUI.git cd ComfyUI # Create and activate a Python virtual environment py -3.13 -m venv .venv .\.venv\Scripts\Activate.ps1 # 1) NVIDIA RTX 20-series+ (PyTorch CUDA 13.0 stable; cu132 nightly also available) pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu130 # 2) OR AMD Windows 11 (ROCm 10.0 multi-architecture PyTorch; no separate HIP SDK needed) # Use a specific target like device-gfx1201 (RX 9070) or device-gfx1100 (RX 7900) instead of device-all to save disk space # pip install --index-url https://stable.repo.amd.com/rocm/whl-next/ "torch[device-all]==2.13.0+rocm10.0.0" "torchvision[device-all]==0.28.0+rocm10.0.0" "torchaudio==2.11.0.2+rocm10.0.0" # 3) OR Intel Arc GPUs (PyTorch XPU) # pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/xpu # Install ComfyUI dependencies and start pip install -r requirements.txt python main.py ``` ## Linux ### 1. Install system packages and GPU drivers #### Debian / Ubuntu / Linux Mint / Pop!_OS ```bash sudo apt update && sudo apt upgrade -y sudo apt install python3 python3-pip python3-venv git build-essential -y # NVIDIA driver (install the latest open/recommended driver package for your distro) sudo apt install nvidia-driver-570-open -y ``` #### Fedora / RHEL / Rocky Linux / AlmaLinux ```bash sudo dnf update -y sudo dnf install python3.13 python3-pip python3-devel git gcc gcc-c++ -y # Fedora NVIDIA drivers (with RPM Fusion enabled) sudo dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda -y ``` #### Arch Linux / Manjaro / EndeavourOS ```bash sudo pacman -Syu sudo pacman -S python python-pip git base-devel # NVIDIA drivers sudo pacman -S nvidia nvidia-utils ``` #### openSUSE Leap / Tumbleweed ```bash sudo zypper refresh && sudo zypper update sudo zypper install python313 python313-pip git gcc gcc-c++ # NVIDIA drivers sudo zypper install nvidia-video-G06 nvidia-compute-G06 ``` Reboot after installing or updating GPU kernel drivers so `nvidia-smi` (or `rocm-smi`) reports your device cleanly. ### 2. Create a venv and launch ComfyUI ```bash python3 -m venv ~/comfyui-env source ~/comfyui-env/bin/activate git clone https://github.com/Comfy-Org/ComfyUI.git cd ComfyUI # NVIDIA GPUs (CUDA 13.0 stable; update PyTorch if older than 6 months) pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu130 # AMD GPUs on Linux (ROCm 7.2) # pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm7.2 # Intel Arc GPUs (XPU) # pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/xpu pip install -r requirements.txt python main.py ``` For older AMD cards not officially listed in ROCm, launch with `HSA_OVERRIDE_GFX_VERSION=10.3.0 python main.py` (RDNA2 like RX 6600/6700) or `HSA_OVERRIDE_GFX_VERSION=11.0.0 python main.py` (RX 7600 / RDNA3). Setting `PYTORCH_TUNABLEOP_ENABLED=1` can also improve AMD throughput after a slower first warmup run. Open `http://127.0.0.1:8188` in your browser once the terminal prints `To see the GUI go to: http://127.0.0.1:8188`. ## macOS Apple Silicon Macs (M1 through M4) run ComfyUI via PyTorch Metal (`mps`). Intel Macs do not have Metal acceleration for modern diffusion models and are too slow for regular use. ```bash # Install Homebrew if missing, then Python 3.13 and Git brew install python@3.13 git git clone https://github.com/Comfy-Org/ComfyUI.git cd ComfyUI python3.13 -m venv .venv source .venv/bin/activate # Install the latest PyTorch nightly for Apple Silicon MPS (see https://developer.apple.com/metal/pytorch/) pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu pip install -r requirements.txt python main.py ``` > [!NOTE] > On Apple Silicon, unified memory is shared between macOS and the GPU. Stick to native quantized formats such as `FP8` or `convrot int8` on 16 GB Macs instead of unquantized BF16 checkpoints. ## Docker Docker keeps Python, CUDA, and custom nodes isolated from your host OS. 1. Install Docker Engine (or Docker Desktop on Windows with WSL 2) and the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html) so containers can see your GPU. 2. Create persistent folders on your host so models and outputs survive container updates: ```bash mkdir -p ~/comfyui-data/models ~/comfyui-data/output ~/comfyui-data/custom_nodes ``` 3. Pull and run a ComfyUI container image with GPU passthrough: ```bash docker pull yanwk/comfyui-boot:latest docker run -d \ --name comfyui \ --gpus all \ -p 127.0.0.1:8188:8188 \ -v ~/comfyui-data:/root/ComfyUI \ yanwk/comfyui-boot:latest ``` > [!WARNING] > Binding `-p 127.0.0.1:8188:8188` keeps ComfyUI reachable only from your own machine. For LAN or remote access, enable HTTPS with `--tls-keyfile` and `--tls-certfile` or place ComfyUI behind an authenticated reverse proxy. ## ComfyUI-Manager [ComfyUI-Manager v4](https://github.com/Comfy-Org/ComfyUI-Manager/tree/manager-v4) is now integrated into ComfyUI for installing custom nodes, running security checks, updating packages, and managing extensions. * **Desktop App:** ComfyUI-Manager is already enabled out of the box. * **Manual venv and Windows Portable:** install the manager requirements once and start ComfyUI with `--enable-manager`: ```bash pip install -r manager_requirements.txt python main.py --enable-manager ``` Useful manager launch flags (see [docs.comfy.org/manager/overview](https://docs.comfy.org/manager/overview)): * `--enable-manager`: enables built-in ComfyUI-Manager. * `--enable-manager-legacy-ui`: uses the classic manager dialog instead of the newer UI (implies `--enable-manager`). * `--disable-manager-ui`: disables manager web UI endpoints while keeping background security checks and scheduled installs active (requires `--enable-manager`). ## First models to download Before queuing your first prompt, place at least one model in `ComfyUI/models/`: * **All-in-one SDXL / Illustrious / Pony checkpoint:** put `.safetensors` files in `ComfyUI/models/checkpoints/`. * **Split-weight models (Flux.2, Qwen-Image 2.1, Z-Image, Krea 2, Anima, SD 3.5, Wan 2.2, LTX-Video 2):** put the diffusion model in `ComfyUI/models/diffusion_models/`, text encoders in `ComfyUI/models/text_encoders/`, and the matching VAE in `ComfyUI/models/vae/`. Continue to [Interface & Core Concepts](./core-concepts.md) or build a graph in [Your First Workflow](./first-workflow.md). --- # Interface & Core Concepts ComfyUI is a visual node-graph editor for AI pipelines. Instead of hiding steps behind tabs and checkboxes, every step (loading a model, encoding text, sampling noise, decoding pixels) is an explicit node wired left to right. ## Anatomy of a node Every node has three parts: * **Inputs (left sockets):** data entering the node (`MODEL`, `CLIP`, `LATENT`, `IMAGE`). * **Widgets (inside the card):** inline parameters like `steps`, `cfg`, `seed`, `width`, and `height`. Right-click a widget and choose **Convert to input** to drive it from another node. * **Outputs (right sockets):** data produced by the node for downstream nodes. ## Data types and wire colors ComfyUI prevents invalid connections automatically: you can only connect sockets of the same type. Dragging from a socket into empty canvas space opens a filtered menu of nodes that accept that exact type. | Color / Type | What it carries | Common producer -> consumer | | --- | --- | --- | | Lavender (`MODEL`) | Diffusion weights | `Load Checkpoint` / `Load Diffusion Model` -> `Load LoRA` -> `KSampler` | | Yellow (`CLIP`) | Text encoder weights | `Load Checkpoint` / `Load CLIP` -> `CLIP Text Encode (Prompt)` | | Orange (`CONDITIONING`) | Encoded prompt guidance | `CLIP Text Encode (Prompt)` -> `Apply ControlNet` -> `KSampler` | | Pink (`LATENT`) | Compressed latent tensor | `Empty Latent Image` / `VAE Encode` -> `KSampler` -> `VAE Decode` | | Blue (`IMAGE`) | Decoded RGB pixel tensor | `VAE Decode` -> `Upscale Image` -> `Save Image` | | Red (`VAE`) | Variational autoencoder | `Load Checkpoint` / `Load VAE` -> `VAE Decode` / `VAE Encode` | | Green (`MASK`) | Grayscale selection mask | `Load Image (MaskEditor)` -> `Set Latent Noise Mask` | Beyond image sockets, multimodal ComfyUI workflows also pass typed `AUDIO`, `VIDEO`, and `3D` mesh or point-cloud sockets between loaders, samplers, and savers. ## Nodes 2.0, Subgraphs, and App Mode ComfyUI's frontend has evolved beyond static canvas cards: * **Nodes 2.0:** ComfyUI's web-native Vue component renderer replaces legacy canvas drawing with interactive controls, inline error badges, curve and crop widgets, and smoother panning on large graphs (a toggle for the legacy renderer remains in Settings). * **Subgraphs (`Ctrl + Shift + E`):** collapse a cluster of nodes into a single modular node with clean exposed inputs and outputs, then save reusable patterns as blueprints across projects. * **App Mode (`Alt + M`):** hides the node graph behind a clean form view showing only the prompts, sliders, and upload widgets a workflow author chooses to expose. * **Partner Nodes and offline mode:** ComfyUI includes optional paid cloud Partner Nodes alongside local open-source nodes. Launch with `--disable-partner-nodes` to hide paid API nodes, or `--offline` to disable Partner Nodes and lock down frontend network requests with a strict Content Security Policy. ## Embedded workflows in outputs By default, ComfyUI's saver nodes embed the full workflow JSON graph inside generated **images, videos, audio, and 3D output files**. * **Reload any output:** drag and drop a ComfyUI-generated image, video, audio, or 3D file directly onto the ComfyUI canvas to recreate the exact graph, prompts, seeds, and model names. * **JSON export:** use **Workflow > Export** (or **Export (API)** for headless scripts) to save lightweight `.json` graphs without media payloads. * **Privacy note:** pass `--disable-metadata` at launch if you want to turn off metadata embedding globally, or strip metadata before posting publicly so prompts and local filenames are not shared. > [!NOTE] > Social platforms that re-encode uploads to WebP or compressed JPEG usually strip embedded workflow chunks, so keep original outputs or export `.json` copies for workflows you want to reuse. ## Organizing large graphs As workflows grow beyond 10 nodes, keep them readable: * **Groups (`Ctrl + G`):** wrap related nodes (Model Loader, Prompting, Upscaler) in a labeled container you can drag as one unit. * **Subgraphs (`Ctrl + Shift + E`):** turn a multi-node branch into a clean reusable sub-node instead of leaving wires tangled across the canvas. * **Bypass vs Mute:** * **Bypass (`Ctrl + B`):** passes compatible inputs straight through the node as if it were skipped (ideal for toggling an Upscale or ControlNet branch without rewiring). * **Mute (`Ctrl + M`):** stops the node and everything downstream from executing at all. * **Collapse, Pin, and Reroute:** collapse noisy cards with `Alt + C`, pin key nodes in place with `P`, and insert Reroute dots to keep long wires neat. ## Essential keyboard shortcuts Check or customize all bindings anytime in **Settings (`Ctrl + ,`) > Keybinding** or open the shortcuts drawer with `Ctrl + Shift + K`. | Shortcut | Action | | --- | --- | | `Double-click` canvas | Open quick node search box | | `Ctrl + Enter` / `Ctrl + Shift + Enter` | Queue workflow / queue at front of queue | | `Ctrl + Alt + Enter` | Interrupt current generation | | `R` | Refresh node definitions and newly added model files | | `W` / `N` / `M` / `A` | Toggle Workflows / Node Library / Model Library / Assets sidebar tabs | | `Ctrl + G` / `Ctrl + Shift + E` | Group selected nodes / convert selected nodes to Subgraph | | `Ctrl + B` / `Ctrl + M` | Bypass / Mute selected node(s) | | `Alt + C` / `P` | Collapse / Pin selected node(s) | | `Alt + M` / `Alt + Shift + M` | Toggle App Mode / toggle Minimap | | `.` / `Alt + =` / `Alt + -` | Fit workflow to screen / Zoom in / Zoom out | | `` Ctrl + ` `` | Toggle bottom Logs / Terminal panel | | `Ctrl + S` / `Ctrl + O` | Save / Open workflow `.json` | Next: wire your first complete pipeline in [Your First Workflow](./first-workflow.md). --- # Your First Workflow ComfyUI supports two main loading styles depending on the model family you choose: **classic all-in-one checkpoints** (SDXL, Illustrious, Pony, SD 1.5) and **modern split-weight models** (Flux.2 / Flux.2 Klein, Qwen-Image 2.1, Z-Image, Krea 2, Anima, SD 3.5, Wan 2.2, LTX-Video 2). ## Classic checkpoint workflow (SDXL / Illustrious / SD 1.5) An all-in-one checkpoint bundles the diffusion `MODEL`, `CLIP` text encoder, and `VAE` inside a single `.safetensors` file. 1. Press **Workflow > Browse Templates** (or build from an empty canvas with double-click search) and verify these 7 nodes: * `Load Checkpoint` * Two `CLIP Text Encode (Prompt)` nodes (one positive, one negative) * `Empty Latent Image` * `KSampler` * `VAE Decode` * `Save Image` (or `Preview Image` while testing) 2. Wire them left to right: * `Load Checkpoint` **MODEL** -> `KSampler` **model** * `Load Checkpoint` **CLIP** -> both `CLIP Text Encode (Prompt)` **clip** sockets * Positive `CLIP Text Encode (Prompt)` **CONDITIONING** -> `KSampler` **positive** * Negative `CLIP Text Encode (Prompt)` **CONDITIONING** -> `KSampler` **negative** * `Empty Latent Image` **LATENT** -> `KSampler` **latent_image** * `KSampler` **LATENT** -> `VAE Decode` **samples** * `Load Checkpoint` **VAE** -> `VAE Decode` **vae** * `VAE Decode` **IMAGE** -> `Save Image` **images** 3. Set `Empty Latent Image` to `1024 x 1024` for SDXL/Illustrious (`512 x 512` for SD 1.5). 4. Press `Ctrl + Enter` (or click **Run**) to queue generation. > [!TIP] > Use `Preview Image` instead of `Save Image` while tuning prompts or seeds so your `ComfyUI/output/` folder does not fill up with test drafts. ## Modern split-weight workflow Newer architectures keep the diffusion model, text encoders, and VAE in separate files because modern encoders (such as Qwen3, Qwen3-VL, Gemma, UMT5, or T5-XXL) are shared across checkpoints and often ship as native quantized `.safetensors` (`FP8`, `convrot int8`, `w6a8`, `NVFP4`). Instead of a single `Load Checkpoint` node, wire dedicated loaders: 1. **Diffusion model:** `Load Diffusion Model` (`UNETLoader`) loading your weights from `ComfyUI/models/diffusion_models/`. 2. **Text encoder(s):** `Load CLIP` (`CLIPLoader`) or `Load CLIP (Dual)` (`DualCLIPLoader`) loading from `ComfyUI/models/text_encoders/`. Set `type` to match the architecture (for example `flux2`, `flux3`, `qwen_image`, `sd3`, `krea2`, `wan`, `ltxv`, `cosmos`, `lumina2`, or `ace` on `Load CLIP`; `flux` on `Load CLIP (Dual)` for Flux.1). 3. **VAE:** `Load VAE` loading from `ComfyUI/models/vae/`. 4. **Latent node:** match the channel count to the model: * `Empty SD3 Latent Image` (16-channel): Flux.1, SD 3.5, Z-Image, Anima, Wan. * `Empty Flux 2 Latent` (32-channel): Flux.2 and Flux.2 Klein. * Built-in encoder outputs: models such as `Text Encode Qwen Image 2.1` output their matching 64-channel `latent` directly. 5. **Guidance:** * **Distilled / Turbo / Qwen-Image 2.1:** `Flux.2 Klein` Distilled, `Qwen-Image 2.1` (Base and Turbo), `Flux.1 Schnell`, and `Z-Image Turbo` run at `cfg = 1.0` (`4-8` steps for distilled/Turbo models, `~25` steps for Qwen-Image 2.1 Base). * **Embedded guidance (`Flux.1 Dev`):** keep sampler `cfg = 1.0` and set `guidance: 3.5` in `FluxGuidance`. * **CFG split models (`Flux.2 Klein Base`, `Anima`, `SD 3.5`):** use sampler `cfg` around `4.0 - 5.5` with a negative prompt. > [!NOTE] > The fastest way to get exact node wiring, encoder types, and latent dimensions for any new image, edit, video, audio, or 3D model is **Workflow > Browse Templates** inside ComfyUI (or [comfy.org/workflows](https://www.comfy.org/workflows)). ## KSampler settings explained | Parameter | What it does | Typical starting range | | --- | --- | --- | | `seed` | Initial random noise pattern | Fixed number to iterate; `randomize` for new variations | | `steps` | Number of denoising iterations | `20-30` standard; `4-8` for Distilled / Turbo / Lightning models | | `cfg` | Classifier-Free Guidance (prompt strictness) | `1.0` (Flux.1 Dev w/ FluxGuidance, Flux.2 Klein Distilled, Qwen-Image 2.1); `4.0-5.5` (Klein Base, Anima, SD 3.5); `5.0-7.5` (SDXL / Illustrious) | | `sampler_name` | Numerical solver used per step | `euler`, `dpmpp_2m`, `res_multistep`, `uni_pc` | | `scheduler` | Noise schedule curve across steps | `simple`, `sgm_uniform`, `karras`, `beta`, `normal` | | `denoise` | How much original image is replaced | `1.00` for txt2img; `0.25-0.75` for img2img / Hi-Res Fix | ## Saving and sharing workflows * **Automatic output embedding:** ComfyUI saver nodes embed the workflow JSON inside generated images, videos, audio, and 3D files. Drop any output onto a ComfyUI canvas later to restore the exact graph. * **Standalone templates:** use **Workflow > Save** to store workflows in `ComfyUI/user/default/workflows/` so they show up in your left sidebar. * **Clean output filenames:** change `filename_prefix` on `Save Image` to `%date:yyyy-MM-dd%/portrait` to sort outputs into dated subfolders automatically. Next: organize your model files and add LoRAs in [Models, Checkpoints & LoRAs](./models-and-loras.md). --- # Models, Checkpoints & LoRAs Keeping weights in the right directory and matching native quantization formats to your GPU prevents most loading errors and bottlenecks before they start. ## Model directory map (`ComfyUI/models/`) | Folder | Loader node / usage | What goes here | | --- | --- | --- | | `checkpoints/` | `Load Checkpoint` | All-in-one `.safetensors` models (SDXL, Illustrious, Pony, SD 1.5) | | `diffusion_models/` | `Load Diffusion Model` | Standalone base diffusion weights (legacy alias: `unet/`) | | `text_encoders/` | `Load CLIP` / `Load CLIP (Dual)` | Standalone text encoders (legacy alias: `clip/`): `qwen_3`, `qwen3vl`, `gemma`, `umt5`, `t5xxl`, `clip_l` | | `vae/` | `Load VAE` | Standalone VAEs (Flux, Qwen-Image 2.1, SDXL, Wan, LTX) | | `loras/` | `Load LoRA` / `Load LoRA (Model and CLIP)` | Style, character, edit, and distillation (Turbo/Lightning) LoRAs | | `controlnet/` | `Load ControlNet Model` | Canny, Depth, Pose, Lineart, Tile, and Union ControlNets (alias: `t2i_adapter/`) | | `upscale_models/` | `Load Upscale Model` | Pixel upscalers (`4x-UltraSharp`, `4x_NMKD-Siax`, `RealESRGAN_x4plus`) | | `latent_upscale_models/` | Latent upscaler loaders | Learned latent-space upscaler weights | | `model_patches/` | `ModelPatchLoader` | Lightweight model-patch adapters (such as Anima LLLite or Z-Image patches) | | `clip_vision/` | `Load CLIP Vision` | Visual encoders for IP-Adapter, Flux Redux, and image-to-video | | `style_models/` | `Load Style Model` | Style adapter weights such as `flux1-redux-dev.safetensors` | | `embeddings/` | Referenced via `embedding:name` | Textual inversion embeddings | | `audio_encoders/` | `Load Audio Encoder` | Encoders for audio and audio-video generation models | | `background_removal/` | `Load Background Removal Model` | Segmentation weights such as BiRefNet | | `geometry_estimation/` | `Load Depth Anything 3` | Depth and geometry estimation models | | `detection/` | Detection / SAM3 loaders | Object detection and SAM3 segmentation models | | `frame_interpolation/` | Frame interpolation loaders | Video frame interpolation weights | | `vae_approx/` | `--preview-method taesd` | TAESD fast latent preview decoders (`taesd_decoder.pth`, `taef1_decoder.pth`, etc.) | > [!WARNING] > Always prefer `.safetensors` files over legacy `.ckpt` or `.pt` pickle files. Pickle checkpoints can execute arbitrary Python code when deserialized, whereas `.safetensors` stores tensor data safely. ## Checkpoint vs split weights * **Checkpoints (`checkpoints/`):** combine `MODEL`, `CLIP`, and `VAE` inside one file and load with `Load Checkpoint`. * **Split weights (`diffusion_models/` + `text_encoders/` + `vae/`):** keep each component separate so you can pair a lighter native quantized diffusion model with a quantized text encoder without re-downloading duplicates. ## Native Comfy quantization (and why to skip GGUF) Modern DiT models (8B to 20B+ parameters) and vision-language text encoders are heavy in raw 16-bit weights. ComfyUI supports native `comfy_quant` checkpoints stored in standard `.safetensors` files with native fast kernels and Dynamic VRAM compatibility: | Format | Storage & precision | Hardware & usage notes | | --- | --- | --- | | `BF16` / `FP16` | 16-bit floating point | Reference precision; highest VRAM requirement | | `FP8` (`float8_e4m3fn` / `mxfp8`) | 8-bit floating point | Roughly half the VRAM of 16-bit with strong visual fidelity; fast on RTX 40/50 GPUs | | `convrot int8` (`int8_tensorwise` w/ Hadamard rotation) | 8-bit integer + per-row scales | High-accuracy native 8-bit format used across modern diffusion models and encoders (such as `qwen3vl_8b_int8_convrot.safetensors`) | | `w6a8` (`w6a8_int8`) / `w4a8` / `w4a4` | 6-bit and 4-bit packed integer | Compact native formats for 8-12 GB GPUs running large modern models | | `NVFP4` (`nvfp4`) | 4-bit floating point | Hardware-accelerated via Comfy Kitchen on RTX 50-series Blackwell GPUs | > [!WARNING] > Do not use GGUF models or third-party GGUF custom-node packs. ComfyUI's official troubleshooting guidance recommends removing all GGUF nodes and models and using native `.safetensors` quantization such as `convrot int8`, `w6a8`, `FP8`, or `NVFP4`, which load through built-in nodes, work seamlessly with Dynamic VRAM and LoRAs, and run **more than 2x faster** than GGUF. > [!TIP] > If a split-weight model barely spills out of VRAM, switch your text encoder (`text_encoders/`) to `FP8` or `convrot int8` first before stepping down the diffusion weights to 6-bit or 4-bit. ## Using and chaining LoRAs A LoRA (Low-Rank Adaptation) patches a base model's weights to add a character, art style, editing skill, or few-step distillation. 1. Place `.safetensors` LoRA files in `ComfyUI/models/loras/`. 2. Insert **`Load LoRA (Model and CLIP)`** (`LoraLoader`) between your model loader and both your text encoders and `KSampler`. 3. If a LoRA only patches the diffusion model (common on modern DiT models without CLIP weights), use **`Load LoRA`** (`LoraLoaderModelOnly`) so you do not have to route `CLIP` wires through every node. For independent patching, ComfyUI also provides **`Load LoRA (Model)`** and **`Load LoRA (Text Encoder)`**. 4. **Chaining multiple LoRAs:** connect `MODEL` and `CLIP` out of `LoRA 1` into `LoRA 2`, then into `KSampler`. 5. **Strength guidelines:** * **Single style/character LoRA:** `0.6 - 1.0`. * **Stacked LoRAs (2 to 4):** lower each to `0.4 - 0.75` so weights do not fight and burn highlights. * **Trigger words:** check the creator's model card and include exact trigger tags in your positive prompt. ## Sharing models with `extra_model_paths.yaml` If you already store models for MooshieUI or another local UI, share one library on disk instead of duplicating 10 GB+ files. 1. In your ComfyUI root folder, copy `extra_model_paths.yaml.example` to `extra_model_paths.yaml` (or pass `--extra-model-paths-config` / `--models-directory` at launch). 2. Edit the base path and subfolders (`is_default: true` lets ComfyUI save newly downloaded assets there too): ```yaml shared_models: base_path: D:/AI-Models/ is_default: true checkpoints: checkpoints/ diffusion_models: diffusion_models/ text_encoders: text_encoders/ vae: vae/ loras: loras/ controlnet: controlnet/ upscale_models: upscale_models/ latent_upscale_models: latent_upscale_models/ model_patches: model_patches/ clip_vision: clip_vision/ audio_encoders: audio_encoders/ ``` 3. Save the file and restart ComfyUI (or press `R` in the UI to refresh node dropdowns). Next: master prompt syntax, CFG, samplers, and resolutions in [Prompting, Samplers & Schedulers](./prompting-and-samplers.md). --- # Prompting, Samplers & Schedulers Different model families understand prompts, CFG scale, and samplers very differently. Matching your settings to the architecture matters far more than hunting for magic quality buzzwords. ## Natural language vs tag prompting | Model family | Prompt style that works best | Negative prompt usage | | --- | --- | --- | | **Flux.2 / Flux.2 Klein / Flux.1 / Qwen-Image 2.1 / Z-Image / Krea 2 / SD 3.5 / Wan 2.2** | Clear natural-language sentences describing subject, composition, lighting, materials, and camera | Unused on distilled / guidance-free models (`cfg = 1.0`); light cleanup on CFG-based variants | | **SDXL** | Descriptive phrases or comma-separated visual clauses | Short cleanup tags (`blurry, deformed, watermark`) | | **Illustrious / Pony / Anima** | Structured Danbooru/booru tags (`1girl, solo, blue_jacket, golden_hour`) + checkpoint quality tags | Important for anime checkpoints; follow model card recommendations | For Anima artist style discovery, you can also browse and copy visual style tags in [Anima Style Explorer](https://anima.mooshieblob.com). ## Prompt syntax: weighting, wildcards, embeddings, and comments ComfyUI's frontend and `CLIP Text Encode (Prompt)` support several built-in syntax features with no extensions needed: * **Token weighting:** * Increase weight with `(golden_hour:1.25)`. Keep most weights between `0.8` and `1.35`; pushing above `1.5` easily fries contrast or distorts faces. * Decrease weight with `(fog:0.7)`. * Shorthand parentheses without a colon apply `1.1x` (`(glow)` = `(glow:1.1)`, `((glow))` = `(glow:1.21)`). * Escape literal parentheses in tags with backslashes: `hatsune_miku_\(cosplay\)`. * **Weight shortcut:** select text inside a prompt widget and press `Ctrl + ArrowUp` or `Ctrl + ArrowDown` to adjust its weight in `0.05` steps. * **Inline dynamic prompts (wildcards):** wrap random options in braces like `{red|blue|emerald} coat` (nested choices `{warm {gold|amber}|cool blue}` and empty options `{|light fog}` work too). Escape literal braces or pipes with `\{`, `\}`, and `\|`. * **Comments:** use `// single-line comment` or `/* block comment */` inside prompt boxes to temporarily disable phrases or leave notes. ComfyUI strips C-style comments automatically when queuing. * **Embeddings (Textual Inversion):** reference files in `ComfyUI/models/embeddings/` directly in your prompt with `embedding:filename` (without the file extension). ## CFG scale by model family CFG (Classifier-Free Guidance) controls how strongly sampling pushes away from the negative/unconditional prediction toward your prompt. | Model family | Recommended CFG | Notes | | --- | --- | --- | | **Distilled / guidance-free (`Flux.2 Klein` Distilled, `Qwen-Image 2.1` Base & Turbo, `Flux.1 Schnell`, `Z-Image Turbo`, `Lightning / LCM`)** | `1.0` | Do not raise CFG; use `4 - 8` steps for distilled/Turbo models (`~25` steps for Qwen-Image 2.1 Base) | | **Embedded guidance (`Flux.1 Dev`)** | Sampler `cfg = 1.0` | Set guidance (`2.5 - 4.0`) in a `FluxGuidance` node | | **CFG split models (`Flux.2 Klein Base`, `Anima`, `SD 3.5`, `Qwen-Image 1`)** | `3.5 - 5.5` | Supports negative prompts; pushing past `7` creates harsh contrast | | **Classic checkpoints (`SDXL`, `Illustrious`, `Pony`)** | `4.5 - 7.5` | Balanced anatomy, color, and prompt adherence | ## Samplers and schedulers ComfyUI ships built-in deterministic and stochastic solvers inside `KSampler`: | Sampler (`sampler_name`) | Best paired scheduler(s) | Behavior | | --- | --- | --- | | `euler` | `simple`, `normal`, `beta`, `sgm_uniform` | Clean, reliable default across nearly every architecture (Flux.2, Qwen, Z-Image, Anima, SDXL) | | `euler_ancestral` | `normal`, `karras` | Injects fresh noise each step; good creative variation on anime/SDXL, never converges identically | | `dpmpp_2m` | `karras`, `sgm_uniform`, `beta` | Fast, sharp convergence in `20 - 30` steps on SDXL and SD 1.5 | | `dpmpp_2m_sde` | `karras`, `exponential` | Richer surface texture in `25 - 35` steps; slightly slower per step | | `res_multistep` / `er_sde` | `simple`, `beta` | High-precision solvers suited to modern flow-matching models | | `uni_pc` / `sa_solver` | `simple`, `normal`, `karras` | Fast convergence in `12 - 20` steps | Built-in `scheduler` choices include `simple`, `sgm_uniform`, `karras`, `beta`, `normal`, `exponential`, `ddim_uniform`, `linear_quadratic`, and `kl_optimal` (plus architecture nodes such as `Flux2Scheduler` for Flux.2 sigma schedules). > [!TIP] > When testing an unfamiliar model, start with the architecture's bundled workflow template (`euler` + `simple` for most modern DiTs, or `dpmpp_2m` + `karras` for SDXL checkpoints) and adjust one variable at a time. ## Native resolutions and aspect ratios Every model family is trained around a target pixel area. Generating far below or far above native resolution causes duplicated heads, extra limbs, or soft textures. | Architecture | Target pixel area | Common aspect presets | | --- | --- | --- | | **SD 1.5** | `~512 x 512` (0.26 MP) | `512x512`, `512x768`, `768x512` | | **SDXL / Illustrious / Anima** | `~1024 x 1024` (1.0 MP) | `1024x1024`, `896x1152`, `832x1216`, `1152x896`, `1216x832`, `1344x768` | | **Flux.2 / Flux.1 / Qwen-Image 2.1 / Z-Image / Krea 2 / SD 3.5** | `~1024 x 1024` to `1328 x 1328` (1.0-1.7 MP) | `1024x1024`, `1024x1536`, `1328x1328`, `1664x928` | Keep width and height divisible by `16` (or `64` for broad VAE/patch compatibility), and upscale high-resolution targets in a second pass instead of sampling at 2K+ from scratch. ## Managing seeds * **`control_after_generate: fixed`:** repeats the exact image whenever upstream settings stay identical. Use this while tuning CFG, scheduler, or small prompt changes. * **`control_after_generate: randomize`:** picks a fresh random seed after every run for exploration. * **`control_after_generate: increment`:** steps `seed + 1` sequentially, useful when comparing reproducible batches. Next: edit existing images and upscale cleanly in [Img2Img, Inpainting & Upscaling](./img2img-inpainting-upscaling.md). --- # Img2Img, Inpainting & Upscaling Once you move past text-to-image, ComfyUI lets you restyle existing pictures, make instruction-based edits, repaint masked regions, extend canvases, and upscale cleanly in multiple passes. ## Image-to-Image (Img2Img) Img2Img replaces `Empty Latent Image` with `Load Image` -> `VAE Encode` so the `KSampler` starts from encoded pixels instead of pure noise. 1. Add `Load Image` and upload or drop your source picture. 2. Connect `Load Image` **IMAGE** -> `VAE Encode` **pixels** (plus your **VAE** input). 3. Connect `VAE Encode` **LATENT** -> `KSampler` **latent_image**. 4. Lower `denoise` below `1.00` to keep parts of the original structure: | `denoise` range | Effect on the input image | Best use case | | --- | --- | --- | | `0.15 - 0.30` | Crisp texture/lighting polish while preserving layout | Second-pass refinement and subtle cleanup | | `0.35 - 0.55` | Restyles brushwork, lighting, or details while holding pose | Style shifts and Hi-Res Fix passes | | `0.60 - 0.80` | Heavy reimagining while roughly honoring color/composition | Turning rough sketches into finished renders | | `0.85 - 1.00` | Replaces almost everything | Effectively a fresh generation | ## Instruction-based editing (native edit models) Modern unified and edit-trained models let you describe edits in plain language ("replace the red jacket with a weathered leather coat", "shift lighting to sunset") without manually painting masks: * **Reference-latent edit models (`Flux.2 Klein`, `Flux.1 Kontext`, `Krea 2`):** encode one or more input images with `VAE Encode` and inject them into conditioning via **`Set Reference Latent`** (`ReferenceLatent`) or **`Set Reference Multi Latent`** (`ReferenceMultiLatent`). Use `FluxKontextImageScale` when preparing Flux.1 Kontext inputs. * **Qwen-Image 2.1 (`Text Encode Qwen Image 2.1`):** handles both text-to-image and multi-reference image editing inside one model, accepting up to 16 reference images directly in its conditioning node while outputting a matched 64-channel `latent`. Check **Workflow > Browse Templates** inside ComfyUI for each model family's exact reference-conditioning graph. ## Inpainting (selective masked edits) When you want surgical control over exactly which pixels change, use ComfyUI's built-in **MaskEditor** on `Load Image`: 1. Right-click a `Load Image` node and click **Open in MaskEditor**. 2. Paint over the exact region you want to change (clothing, hand, background object), adjust brush hardness/opacity, and click **Save**. 3. Wire your mask using one of three built-in paths: * **General models:** connect `VAE Encode` and `Load Image` **MASK** into **`Set Latent Noise Mask`** -> `KSampler`. Add **`Differential Diffusion`** on `MODEL` for smooth feathered blending at moderate denoise values. * **Conditioning-masked / Flux-style inpaint:** use **`InpaintModelConditioning`** so masked latents and unmasked pixels stay locked together cleanly. * **Dedicated inpaint checkpoints:** use **`VAE Encode (for Inpainting)`** with `grow_mask_by` set to `6 - 12` pixels so borders blend smoothly. 4. For tiny faces or hands on large canvases, crop around the subject before sampling (for example with `Crop Image` / `Mask` helpers or community crop-and-stitch nodes) and paste back so small details receive full native resolution. > [!TIP] > If inpainting produces visible square seams, use `InpaintModelConditioning` or `Differential Diffusion` with soft brush edges and `grow_mask_by` around `8`. ## Outpainting (extending borders) To reveal more scenery around an existing crop: 1. Insert **`Pad Image for Outpainting`** after `Load Image`. 2. Enter pixel padding on `left`, `top`, `right`, or `bottom`, plus `feathering` (`32 - 64` px) to blend the seam. 3. Connect its `IMAGE` and `MASK` outputs into `VAE Encode (for Inpainting)` (or `Set Latent Noise Mask`) and describe the wider scene in your prompt. 4. Keep `denoise` at `1.0` so newly padded gray regions synthesize fresh detail cleanly while masked border feathering smooths the transition. ## Hi-Res Fix (two-pass upscale) Generating directly at 2048x2048 causes repeated faces and distorted anatomy because base models are trained near 1 MP (`1024x1024`). Instead, generate at native size first, then upscale and refine. 1. Run Pass 1 at native resolution (`1024x1024` for SDXL/Flux/Anima) and decode with `VAE Decode`. 2. Upscale the decoded RGB image with `Load Upscale Model` (for example `4x-UltraSharp` or `4x_NMKD-Siax_200k`) -> `Upscale Image (using Model)`. 3. Optionally downscale slightly with **`Upscale Image By`** (`0.5` after a `4x` upscaler gives a crisp `2x` output at `2048x2048`). 4. Encode back to latent with `VAE Encode` (or `VAE Encode (Tiled)` on 8-12 GB GPUs). 5. Run Pass 2 through a second `KSampler` with `denoise` between `0.25` and `0.45` and `12 - 20` steps, then `VAE Decode` to `Save Image`. ## Upscaling methods compared | Method | Pros | Cons | | --- | --- | --- | | **Pixel model upscale + Pass 2 (`4x-UltraSharp`)** | Preserves sharp edges, eyes, and fabric before re-denoising; lets Pass 2 use lower denoise (`0.25 - 0.40`) | Extra VRAM/compute for the ESRGAN model | | **Latent upscale (`Upscale Latent` / `models/latent_upscale_models/`)** | Fast with low memory overhead; learned latent upscalers avoid simple interpolation blur | Simple interpolation upscalers need higher denoise (`0.50+`) to sharpen textures | | **Diffusion restoration (`SeedVR2`, built-in)** | Strong generative texture recovery for degraded photos and video; includes **`Split SeedVR2 Latent`** and **`Merge SeedVR2 Latents`** for chunked video upscaling | Heavier compute than single-pass ESRGAN models | ## Tiled passes for 4K+ and low VRAM When decoding or refining images above `2048 x 2048`: * Replace `VAE Decode` with `VAE Decode (Tiled)` (built into ComfyUI) to avoid sudden out-of-memory crashes right at the finish line. * For ultra-high resolutions or seamless multi-tile refinement, use tiled diffusion or `Ultimate SD Upscale` (keeping tile overlap at `64 - 128` px and moderate denoise `0.20 - 0.35`). Next: lock pose, depth, edges, and style references in [ControlNet & Style References](./controlnet-and-references.md). --- # ControlNet & Style References ControlNet, model patches, and reference adapters let you lock composition, depth geometry, character poses, or visual style from existing images instead of relying on prompt wording alone. ## How ControlNet fits into a graph Unlike LoRAs (which patch `MODEL`), standard ControlNet nodes intercept `CONDITIONING` between your text encoders and `KSampler`. 1. Download matching ControlNet weights into `ComfyUI/models/controlnet/` (ControlNet weights must match your base architecture: SD 1.5 ControlNets do not work on SDXL or Flux). 2. Load an image with `Load Image` and extract a control map with a **Preprocessor** node (or load a ready-made depth or edge image directly). 3. Wire `Load ControlNet Model` + Preprocessor `IMAGE` + positive/negative `CONDITIONING` into **`Apply ControlNet`** (`ControlNetApplyAdvanced`). 4. Connect the modified `positive` and `negative` conditioning outputs to `KSampler`. ## Common ControlNet types and preprocessors ComfyUI includes native built-in vision and preprocessor nodes for edges, depth, segmentation, and background removal, while optional community packs such as [comfyui_controlnet_aux](https://github.com/Fannovel16/comfyui_controlnet_aux) add pose and lineart extractors: | Control type | Preprocessor / loader | Best used for | Typical `strength` | | --- | --- | --- | --- | | **Canny edges** | `Detect Edges (Canny)` (built-in) | Strict silhouettes, architecture lines, product contours | `0.65 - 0.90` | | **Depth** | `Load Depth Anything 3` -> `Run Depth Anything 3` -> `Render Depth Anything 3` (built-in, `models/geometry_estimation/`) | Preserving 3D scene layout, room geometry, and camera depth | `0.50 - 0.80` | | **Segmentation / Masking** | `SAM3 Detect` / `Run SAM3 Video Track` (built-in, `models/detection/`) | Isolating specific objects or characters across frames | Mask / Control region | | **Foreground cutout** | `Load Background Removal Model` -> `Remove Background` (built-in BiRefNet, `models/background_removal/`) | Clean subject cutouts for compositing or reference edits | Mask / Cutout | | **OpenPose / Lineart / Scribble** | `DWPose Estimator`, `Lineart Standard`, `HED / PiDiNet` (`comfyui_controlnet_aux`) | Body pose skeletons, clean inked lineart, rough sketch guidance | `0.65 - 1.00` | | **Tile / Blur** | Direct reference image | Upscaling details while stopping the model from hallucinating new objects | `0.40 - 0.70` | > [!NOTE] > Always attach a `Preview Image` node to your preprocessor output while building a workflow. If the Canny edges are pure noise or the pose skeleton missed fingers, tune thresholds before queuing the sampler. ## Strength and step scheduling (`start_percent` / `end_percent`) `Apply ControlNet` (`ControlNetApplyAdvanced`) exposes three main controls: * **`strength` (`0.0 - 1.5`):** how strictly pixels must follow the control map. Above `1.0` often washes out textures or leaves harsh outlines. * **`start_percent` (`0.0`):** when ControlNet begins steering denoising steps. * **`end_percent` (`0.60 - 0.90`):** when ControlNet stops acting. Ending ControlNet around `0.70` lets the final 30% of steps refine natural hair, cloth folds, and lighting without looking traced onto stiff lines. ## Chaining multiple ControlNets You can combine structural cues (for example **DWPose** for character pose + **Depth Anything 3** for room geometry): 1. Feed text conditioning into `Apply ControlNet` #1 (Pose, strength `0.85`, `end_percent: 0.80`). 2. Wire `Apply ControlNet` #1 outputs (`positive`, `negative`) directly into `Apply ControlNet` #2 (Depth, strength `0.50`, `end_percent: 0.60`). 3. Feed `Apply ControlNet` #2 outputs into `KSampler`. Lower individual strengths slightly when stacking multiple ControlNets so conditioning vectors do not over-constrain the sampler. ## Union ControlNets and Model Patches * **Union ControlNets:** many SDXL and Flux ControlNets ship as multi-mode **Union** checkpoints handling Canny, Depth, Pose, Tile, and SoftEdge in one file. Load with `Load ControlNet Model`, insert **`Set Union ControlNet Type`** (`SetUnionControlNetType`), and pick the matching mode (`openpose`, `depth`, `canny/lineart`, `tile`). * **Model Patch control adapters (`models/model_patches/`):** newer lightweight control adapters (such as Z-Image or Anima ControlNet-LLLite) load via `ModelPatchLoader` and attach to `MODEL` instead of conditioning. ## Style and character references ControlNet locks geometry; **reference conditioning and style adapters** transfer identity, outfits, palette, or rendering style without tracing exact edges. * **Native multi-reference edit conditioning (built-in):** modern models such as **Flux.2 Klein** (optionally accelerated with `Flux KV Cache`), **Flux.1 Kontext**, and **Qwen-Image 2.1** (`Text Encode Qwen Image 2.1`) take reference images natively via **`Set Reference Latent`** or **`Set Reference Multi Latent`**. This preserves character identity, products, and style directly from reference frames without training a LoRA. * **Flux Redux (built-in for Flux.1):** load `Load Style Model` + `Load CLIP Vision`, run `CLIP Vision Encode` -> `Apply Style Model`, and merge the visual tokens into `CONDITIONING` before `KSampler`. * **IP-Adapter (`ComfyUI_IPAdapter_plus`):** pairs an IP-Adapter weight and CLIP Vision model with `MODEL` to blend style, composition, or faces across SDXL and SD 1.5 checkpoints. Lower `weight` (`0.40 - 0.75`) to avoid copying the reference image verbatim. Next: tune Dynamic VRAM, built-in caching, and workflow hygiene in [Performance & Optimization](./tips-and-optimization.md). --- # 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). --- # Troubleshooting & FAQ Quick fixes for the errors you will run into most often when setting up PyTorch, models, custom nodes, and large workflows. > [!IMPORTANT] > **Check these 4 official fixes first before deep debugging:** > 1. **Update PyTorch:** NVIDIA RTX 20-series and newer GPUs require CUDA `cu130` or higher (if your PyTorch install is more than 6 months old, update it). > 2. **Remove all GGUF files and nodes:** delete GGUF models and third-party GGUF node packs, and switch to native Comfy formats (`convrot int8`, `w6a8`, `FP8`, `NVFP4`) for more than 2x faster performance. > 3. **Isolate custom nodes:** launch with `python main.py --disable-all-custom-nodes` to check whether a third-party extension is causing crashes or slowdowns. > 4. **Remove extra CLI flags:** strip old "performance" launch flags (`--lowvram`, `--novram`, `--fast`, `--force-fp16`) and test clean defaults first. ## CUDA out of memory `Allocation on device` or `CUDA out of memory` means a node tried to allocate more GPU memory than Dynamic VRAM can fit alongside your OS. 1. **Remove legacy flags:** clear `--highvram`, `--gpu-only`, or `--disable-dynamic-vram` so Dynamic VRAM and async weight streaming can offload layers automatically. 2. **Lower resolution or batch size:** verify your empty latent node is near native training size (`1024 x 1024`, `batch_size = 1`) rather than `2048 x 2048`. 3. **Switch to Tiled VAE:** if sampling hits 100% and crashes right during decode, replace `VAE Decode` with `VAE Decode (Tiled)` (`tile_size: 512`, `overlap: 64`). 4. **Use native quantized weights:** swap unquantized 16-bit diffusion models and text encoders for native `convrot int8`, `w6a8`, `FP8`, or `NVFP4` `.safetensors` files (do not use GGUF). 5. **Leave OS headroom and clear cache:** launch with `--vram-headroom 1.0` if other GPU apps (browsers, games) stay open, add `--fast-disk` on fast NVMe SSDs if system RAM is low, and click **Unload Models / Free Memory** in ComfyUI's top menu. ## Missing custom nodes Opening someone else's PNG or JSON workflow often shows red-bordered nodes and a `Missing Node Types` modal. 1. Make sure [ComfyUI-Manager](./installation.md#comfyui-manager) is active (pre-installed on Desktop App, or enabled with `pip install -r manager_requirements.txt` and `python main.py --enable-manager`). 2. Open **Manager -> Install Missing Custom Nodes** inside ComfyUI. 3. Review the list, click **Install** on the matching packages, and **Restart** ComfyUI completely. 4. If a node still shows red after restarting, check the ComfyUI console or bottom Logs panel (`` Ctrl + ` ``) for `ModuleNotFoundError` tracebacks and install its dependencies inside your ComfyUI environment: ```bash # Run from inside your ComfyUI virtual environment (or python_embeded on Windows Portable) pip install -r custom_nodes//requirements.txt ``` > [!WARNING] > Custom nodes execute arbitrary Python code on your machine. Only install node packs from repositories and Comfy Registry publishers you recognize and trust. ## Black or NaN outputs If images render solid black, neon noise, or trigger `NaN` / `invalid value` errors: * **Wrong VAE:** SDXL, SD 1.5, Flux (`ae.safetensors` vs Flux.2 VAE), Qwen-Image 2.1, Wan, and SD 3.5 each require their own matching VAE. Mixing VAEs causes black images or distorted colors. * **Wrong latent node:** match the channel count to the architecture (`Empty Flux 2 Latent` 32-ch for Flux.2, `Empty SD3 Latent Image` 16-ch for Flux.1 / SD 3.5 / Z-Image / Anima, `Empty Latent Image` 4-ch for SDXL / SD 1.5). * **SDXL FP16 VAE overflow:** older SDXL 1.0 VAEs can overflow in FP16. Use `sdxl_vae_fp16fix` or pass `--bf16-vae` / `--fp32-vae`. * **Excessive CFG or LoRA strength:** check model-specific CFG (`1.0` for distilled/Turbo models and `Qwen-Image 2.1`; `1.0` + `FluxGuidance` for Flux.1 Dev), and keep stacked LoRA weights balanced. * **Precision / compiler flags:** remove `--fast` flags, test `--force-upcast-attention` if black outputs persist on older GPUs, or test `--disable-cuda-graphs` only to check for kernel bugs. ## PyTorch and launch issues ### `Torch not compiled with CUDA enabled` Your Python environment installed CPU-only PyTorch instead of the CUDA build. Reinstall PyTorch with `cu130` (for NVIDIA RTX 20-series+) inside your active venv: ```bash pip uninstall -y torch torchvision torchaudio pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu130 ``` If you are on a legacy GTX 10-series or older card, use the `cu126` index instead. ### `Address already in use` on port `8188` Another ComfyUI instance (or orphaned background `python` process) is still bound to port `8188`: ```bash python main.py --port 8189 ``` Or close the previous terminal window / terminate the leftover `python` process first. ### Slow model loading on every run * Store `ComfyUI/models/` on an internal NVMe SSD instead of a spinning HDD or external USB drive. * Make sure you are using native `.safetensors` quantized weights rather than GGUF files or bloated unquantized FP32 checkpoints. * Add sufficient system RAM (32 GB+ recommended for 12B+ models) or try `--fast-disk` on fast NVMe storage if system RAM is constrained. ### Recovering from a broken custom node update If ComfyUI fails to boot or freezes after installing or updating a custom node pack: 1. Test core ComfyUI first with `python main.py --disable-all-custom-nodes`. 2. Bring back packs selectively with `--whitelist-custom-nodes pack_a pack_b` (or list broken node IDs in `--disabled-nodes-config path.yaml`). 3. Alternatively, open `ComfyUI/custom_nodes/` and append `.disabled` to the problem folder name so ComfyUI skips it on startup. ### Disabling Partner Nodes or running fully offline * **Hide paid API nodes only:** start ComfyUI with `--disable-partner-nodes` while keeping frontend features such as Manager and template updates online. * **Strict air-gapped mode:** start with `--offline` to disable Partner Nodes and apply a restrictive Content Security Policy blocking external frontend network access. Ready to build your own nodes in Python? Read [Custom Node Development](./custom-nodes.md). --- # Custom Node Development Every node in ComfyUI is a Python class. ComfyUI's modern **V3 Custom Node API (`comfy_api.latest`)** replaces scattered class attributes and dict schemas with typed `io.Schema` definitions, structured `io.NodeOutput` returns, and async extension entrypoints. ## Folder structure Create a subfolder inside `ComfyUI/custom_nodes/` (for example `ComfyUI/custom_nodes/my_custom_nodes/`): ```text ComfyUI/custom_nodes/my_custom_nodes/ |-- __init__.py # Exports comfy_entrypoint() returning a ComfyExtension |-- nodes.py # V3 io.ComfyNode subclasses |-- requirements.txt # Extra pip packages (only if needed beyond ComfyUI deps) \-- pyproject.toml # Metadata for Comfy Registry publishing ``` In `__init__.py`, register your node classes through a `ComfyExtension` and `comfy_entrypoint()`: ```python from typing_extensions import override from comfy_api.latest import ComfyExtension, io from .nodes import ConditionalImageBlend, ImageBlur, SimpleTextProcessor class MyNodesExtension(ComfyExtension): @override async def get_node_list(self) -> list[type[io.ComfyNode]]: return [ SimpleTextProcessor, ImageBlur, ConditionalImageBlend, ] async def comfy_entrypoint() -> MyNodesExtension: return MyNodesExtension() ``` > [!NOTE] > `node_id` values inside `io.Schema` are stored inside exported workflows and output metadata. Keep `node_id` globally unique (add a short prefix/suffix for your pack) and never rename it after publishing. ## V3 node anatomy (`comfy_api.latest`) Every V3 node inherits from `io.ComfyNode` and implements two `@classmethod` methods: * **`define_schema(cls) -> io.Schema`:** declares `node_id`, `display_name`, `category`, optional `description` and `search_aliases`, typed `inputs=[...]` and `outputs=[...]`, and optional flags like `is_output_node=True` or `is_experimental=True`. * **`execute(cls, ...) -> io.NodeOutput`:** receives socket values and widget arguments by name and returns `io.NodeOutput(...)` matching the declared `outputs` order. ## Example 1: Basic text processor (V3) ```python from comfy_api.latest import io class SimpleTextProcessor(io.ComfyNode): @classmethod def define_schema(cls) -> io.Schema: return io.Schema( node_id="MyPack_SimpleTextProcessor", display_name="Simple Text Processor", category="text/processing", description="Uppercases and repeats text lines.", inputs=[ io.String.Input("text", multiline=True, default="Hello ComfyUI"), io.Boolean.Input("uppercase", default=False), io.Int.Input("repeat_count", default=1, min=1, max=10), ], outputs=[ io.String.Output(display_name="processed_text"), ], ) @classmethod def execute(cls, text: str, uppercase: bool, repeat_count: int) -> io.NodeOutput: processed = text.upper() if uppercase else text result = "\n".join([processed] * repeat_count) return io.NodeOutput(result) ``` ## Example 2: Working with PyTorch image tensors (V3) In ComfyUI, `IMAGE` sockets pass PyTorch `float32` tensors with shape **`[B, H, W, C]`** (`Batch, Height, Width, Channels`) and pixel values normalized to **`0.0 .. 1.0`** in RGB order. `MASK` tensors use shape **`[B, H, W]`** (or `[H, W]`) in `0.0 .. 1.0`. ```python import numpy as np import torch from PIL import Image, ImageFilter from comfy_api.latest import io class ImageBlur(io.ComfyNode): @classmethod def define_schema(cls) -> io.Schema: return io.Schema( node_id="MyPack_ImageBlur", display_name="Simple Image Blur", category="image/filters", search_aliases=["gaussian blur", "soften"], inputs=[ io.Image.Input("image"), io.Float.Input("blur_radius", default=2.0, min=0.0, max=25.0, step=0.5), ], outputs=[ io.Image.Output(display_name="image"), ], ) @classmethod def execute(cls, image: torch.Tensor, blur_radius: float) -> io.NodeOutput: results = [] for i in range(image.shape[0]): # Convert [H, W, C] float32 (0..1) -> uint8 PIL Image img_np = np.clip(image[i].cpu().numpy() * 255.0, 0, 255).astype(np.uint8) pil_img = Image.fromarray(img_np) blurred = pil_img.filter(ImageFilter.GaussianBlur(radius=blur_radius)) # Convert back to [H, W, C] float32 (0..1) out_np = np.array(blurred).astype(np.float32) / 255.0 results.append(torch.from_numpy(out_np)) return io.NodeOutput(torch.stack(results, dim=0)) ``` > [!IMPORTANT] > Always return tensors on CPU (or preserve the input device safely) with batch dimension `B` intact so downstream nodes like `VAE Encode` and `Save Image` can process batched inputs without crashing. ## Example 3: Optional inputs, combos, and multiple outputs (V3) Pass `optional=True` for sockets users do not need to wire up, use `io.Combo.Input` for dropdowns, and return multiple outputs inside `io.NodeOutput(...)`. For dynamic graphs, V3 also provides `io.DynamicCombo.Input` (conditional sub-inputs per choice) and `io.Autogrow.Input` (expandable socket lists). ```python import torch from comfy_api.latest import io class ConditionalImageBlend(io.ComfyNode): @classmethod def define_schema(cls) -> io.Schema: return io.Schema( node_id="MyPack_ConditionalImageBlend", display_name="Conditional Image Blend", category="image/adjustments", inputs=[ io.Image.Input("image"), io.Combo.Input( "operation", options=["darken", "lighten", "invert"], default="darken", ), io.Float.Input("strength", default=0.5, min=0.0, max=1.0, step=0.05), io.Mask.Input("mask", optional=True), ], outputs=[ io.Image.Output(display_name="image"), io.String.Output(display_name="summary"), ], ) @classmethod def execute(cls, image: torch.Tensor, operation: str, strength: float, mask=None) -> io.NodeOutput: if operation == "invert": modified = 1.0 - image elif operation == "lighten": modified = torch.clamp(image + strength * 0.25, 0.0, 1.0) else: modified = torch.clamp(image * (1.0 - strength * 0.25), 0.0, 1.0) if mask is not None: m = mask if mask.ndim == 3 else mask.unsqueeze(0) m = m.unsqueeze(-1).to(image.device) output = image * (1.0 - m) + modified * m else: output = image * (1.0 - strength) + modified * strength return io.NodeOutput(output, f"Applied {operation} at strength {strength:.2f}") ``` ## Caching, validation, and lazy evaluation V3 `io.ComfyNode` subclasses support optional `@classmethod` lifecycle hooks: * **Cache fingerprinting (`fingerprint_inputs(cls, **kwargs)`):** replaces V1 `IS_CHANGED`. Return a changing token (such as a file mtime hash) only when reading external mutable state. Never return `float("nan")` unless you genuinely want to bypass downstream workflow caching every run. * **Pre-flight validation (`validate_inputs(cls, **kwargs) -> bool | str`):** replaces V1 `VALIDATE_INPUTS`. Return `True` if valid or a clear error string to fail cleanly before GPU execution begins. * **Lazy evaluation (`check_lazy_status(cls, **kwargs) -> list[str]`):** with `lazy=True` on optional inputs, return only the input names that still need upstream evaluation so unused branches stay skipped. * **Terminal output nodes:** set `is_output_node=True` inside `io.Schema(...)` on saver or preview nodes with no downstream outputs. ## Legacy V1 API reference Older community packs still use the V1 dictionary format, which ComfyUI continues to load for backwards compatibility: | V1 convention | V3 replacement (`comfy_api.latest`) | | --- | --- | | `NODE_CLASS_MAPPINGS` / `NODE_DISPLAY_NAME_MAPPINGS` | `ComfyExtension.get_node_list()` + `comfy_entrypoint()` | | `INPUT_TYPES`, `RETURN_TYPES`, `RETURN_NAMES`, `CATEGORY` | `@classmethod def define_schema(cls) -> io.Schema` | | `FUNCTION = "method_name"` | `@classmethod def execute(cls, ...) -> io.NodeOutput` | | `OUTPUT_NODE = True` | `is_output_node=True` on `io.Schema` | | `IS_CHANGED` / `VALIDATE_INPUTS` | `fingerprint_inputs` / `validate_inputs` classmethods | ## Testing and publishing 1. Test your pack in isolation with `python main.py --disable-all-custom-nodes --whitelist-custom-nodes my_custom_nodes`. 2. Verify `batch_size = 1`, `batch_size > 1`, non-square dimensions, optional `None` sockets, and edge bounds (`0.0`, max values). 3. Avoid mutating `sys.path` or pinning conflicting `torch` / `numpy` versions inside `requirements.txt`. 4. Add a `pyproject.toml` and publish to the [Comfy Registry](https://registry.comfy.org/) so users can install and update your pack safely through ComfyUI-Manager.