KJNodes/model_loadersgenerated

Diffusion Model Loader KJ(DiffusionModelLoaderKJ)

This node provides fine-grained control over weight data types and computational data types when loading models, supporting various precision formats from fp8 to fp32.

Diffusion Model Loader KJ

MODEL
model_name
COMBO
weight_dtype
COMBO
compute_dtype
default
patch_cublaslinear
sage_attention
0
enable_fp16_accumulation
extra_state_dict
STRING
KJNodes

The Diffusion Model Loader KJ node provides fine-grained control over weight data types and computation data types when loading models, supporting various precision formats from fp8 to fp32.

Diffusion Model Loader KJ is a node for loading and configuring diffusion models (such as Stable Diffusion). Its core function is to load model files from a specified path and allows users to adjust the numerical precision and computational behavior of the model at runtime to optimize performance or compatibility.

Node Features

This node provides fine-grained control over weight data types and computation data types when loading models, supporting various precision formats from fp8 to fp32. Its key technical features include an optional CublasLinear patch to leverage specific GPU acceleration libraries, integration capability for the SageAttention mechanism, and support for merging or enhancing model functionality via additional state dictionaries (e.g., adding a VACE module to a video model).

Node Parameter Description - Diffusion Model Loader KJ

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
model_nameCOMBOYes--Select the diffusion model file to load. This parameter lists all available models from the model directories managed by ComfyUI.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
weight_dtypeCOMBOYesdefaultdefault, fp8_e4m3fn, fp8_e4m3fn_fast, fp8_e5m2, fp16, bf16, fp32Used to balance memory usage and computational precision.
compute_dtypeCOMBOYesdefaultdefault, fp16, bf16, fp32Affecting computation speed and numerical stability.
patch_cublaslinearBOOLEANYesFalse-Enable or disable the cublas_ops arg
sage_attentionCOMBOYesFalsefalse, truePatch comfy attention to use sageattn.
enable_fp16_accumulationBOOLEANYesFalse-Enable torch.backends.cuda.matmul.allow_fp16_accumulation, requires pytorch 2.7.0 nightly.
extra_state_dictSTRINGNo--The full path to an additional state dict to load, this will be merged with the main state dict. Useful for example to add VACE module to a WanVideoModel. You can use DiffusionModelSelector to easily get the path.

Output

Parameter NameData TypeDescription
MODELMODELOutputs the loaded and configured model for use by subsequent nodes.

Usage Scenarios

This node is very useful in workflows that require loading a base model and applying specific optimizations or functional extensions. For example, you can first use this node to load a WanVideoModel, then merge a state dictionary for a VACE module via the extra_state_dict parameter, thereby constructing a functionally enhanced video generation model.

Notes

This node belongs to the experimental category. Some features (such as enable_fp16_accumulation) require specific versions of PyTorch (e.g., 2.7.0 nightly) to function properly. Before using advanced data types (like fp8) or patch features, please ensure your hardware and software environment supports them.

The Diffusion Model Loader KJ node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…