Run ComfyUI Easily with InstaSD

Skip the complex setup. InstaSD helps creative professionals build workflows and deploy them to the world:

  • One-click deployment
  • Any model, any node
  • Powerful GPUs for rapid iteration
Get Started

Available Nodes

DiffusionModelLoaderKJ

Diffusion Model Loader KJ Node Documentation

Overview

The Diffusion Model Loader KJ node is an experimental node within the ComfyUI framework, designed to facilitate the loading and customization of diffusion models. Its primary function is to load a specified diffusion model with a variety of settings for compute and weight data types, along with options for patching models using specific computation techniques. This node is part of the KJNodes collection, which enhances user control over the model loading process in ComfyUI workflows.

Functionality

This node allows users to:

  • Load a diffusion model from a pre-defined set of available models.
  • Set the compute and weight data types for optimizing model performance on specific hardware.
  • Optionally patch the model to use advanced features like CublasLinear and SageAttn.
  • Enable or disable FP16 accumulation for compatibility with newer PyTorch versions.

Inputs

The Diffusion Model Loader KJ node accepts the following inputs:

  1. Model Name:

    • Specifies the diffusion model to load. The user can select a model from a list of available diffusion models.
  2. Weight Data Type:

    • Options: default, fp8_e4m3fn, fp8_e4m3fn_fast, fp8_e5m2, fp16, bf16, fp32.
    • Determines the data type used for model weights, enabling users to optimize performance based on their system capabilities.
  3. Compute Data Type:

    • Options: default, fp16, bf16, fp32.
    • Defines the data type for compute operations, allowing further customization of model execution.
  4. Patch Cublas Linear (Boolean):

    • Enables or disables the patching of linear layers using CublasLinear. This can enhance performance on systems that support such optimizations.
  5. Sage Attention:

    • Options: disabled, auto, sageattn_qk_int8_pv_fp16_cuda, sageattn_qk_int8_pv_fp16_triton, sageattn_qk_int8_pv_fp8_cuda.
    • Patches the model's attention mechanism to utilize the SageAttn framework, enhancing attention computation.
  6. Enable FP16 Accumulation (Boolean):

    • Enables the torch.backends.cuda.matmul.allow_fp16_accumulation setting, which requires PyTorch 2.7.0 or later.

Outputs

The Diffusion Model Loader KJ node outputs a single item:

  • MODEL: The initialized and possibly patched diffusion model ready for use in further ComfyUI operations.

Usage in ComfyUI Workflows

This node is particularly useful in workflows where users need to:

  • Load diffusion models with specific performance and optimization configurations tailored to their hardware capabilities.
  • Experiment with different model settings and optimizations for improved render quality or reduced computation times.
  • Integrate advanced features like CublasLinear and SageAttn into their models to explore new dimensions of computational efficiency and precision.

Special Features and Considerations

  • Experimental Status: As an experimental node, the Diffusion Model Loader KJ is subject to ongoing development and refinement. Users should be aware of potential updates and changes in functionality as enhancements are made.

  • Compatibility: Users must ensure compatibility with PyTorch and CUDA versions, especially when enabling features like FP16 accumulation and specific attention patches.

  • Advanced Optimization: This node offers significant potential for advanced users looking to optimize diffusion model performance on custom or high-performance hardware setups.

  • Edge-Case Handling: While configuring settings, users should be cautious with edge-case scenarios like excessive memory consumption, which may arise from certain dtype selections or large model configurations.

This documentation aims to provide you with a comprehensive understanding of the Diffusion Model Loader KJ node and how it can be effectively utilized in your ComfyUI setups. For further information and updates, consider checking the KJNodes GitHub repository.