Skip to main content

Overview

ComfyUI supports various model types for image generation, each serving a specific purpose in the pipeline. The model system handles loading, caching, memory management, and multi-model workflows.

Model Types

Diffusion Models

The core model for denoising latents:
Auto-detection: load_checkpoint_guess_config automatically detects the model architecture (SD 1.5, SDXL, SD3, Flux, etc.) from the checkpoint file.

VAE (Variational Autoencoder)

Encodes images to latent space and decodes latents back to images:

TAESD (Tiny AutoEncoder)

Lightweight VAE alternatives for fast preview:

CLIP (Text Encoder)

Encodes text prompts into conditioning:

Dual CLIP Models

Some models require two CLIP encoders:
SDXL: Requires CLIP-L and CLIP-G
SD3: Supports CLIP-L + CLIP-G or CLIP-L + T5 or CLIP-G + T5
Flux: Requires CLIP-L and T5

Model Paths

From folder_paths.py:22-53, ComfyUI organizes models in standard directories:

Supported File Extensions

SafeTensors Recommended: Use .safetensors format for security and reliability. Pickle-based formats (.ckpt, .pt, .pkl) can execute arbitrary code.

LoRA Models

Low-Rank Adaptation models modify base models:
LoRA Chaining: Multiple LoRA loaders can be chained together to apply multiple adaptations. Each LoRA modifies the model passed to it.

Model File Discovery

From folder_paths.py:303-343, ComfyUI recursively scans model directories:

Model Caching

ControlNet Models

Guidance models for spatial control:

Applying ControlNet

Model Configuration

Model Paths

Configure custom model directories in extra_model_paths.yaml:

Memory Management

Models are automatically loaded/unloaded based on VRAM:
  • --lowvram: Aggressive offloading
  • --normalvram: Moderate offloading
  • --highvram: Keep models in VRAM

Model Precision

Control memory usage with precision:
  • fp32: Full precision
  • fp16: Half precision
  • fp8_e4m3fn: 8-bit float

Safe Loading

Use safe_load=True to prevent code execution in pickle files

Advanced Model Loading

UNET-Only Loading

For separate component loading:

Model Validation

Best Practices

  • Use subdirectories within model folders
  • Name models descriptively
  • Keep model versions separate
  • Document custom model paths
  • Use fp16 or fp8 for large models
  • Enable LoRA caching for repeated use
  • Consider TAESD for preview workflows
  • Batch similar operations together
  • Check model architecture compatibility
  • Match VAE to checkpoint type
  • Verify CLIP encoder requirements
  • Test LoRA with base model
  • Prefer SafeTensors format
  • Use safe_load for pickle files
  • Verify model sources
  • Scan for malicious code

See Also

Nodes

Using models in node workflows

Execution

Model loading during execution

Workflows

Building workflows with models