This repository explains how to accelerate image generation in ComfyUI using Pruna, an inference optimization engine that makes AI models faster, smaller, cheaper, and greener. ComfyUI is a popular node-based GUI for image generation models, for which we provide a custom compilation node that accelerates Stable Diffusion (SD) and Flux inference, while preserving output quality.
This repository explains how to accelerate image generation in ComfyUI using Pruna, an inference optimization engine that makes AI models faster, smaller, cheaper, and greener. ComfyUI is a popular node-based GUI for image generation models, for which we provide a custom compilation node that accelerates Stable Diffusion (SD) and Flux inference, while preserving output quality.
Here, you'll find:
custom_nodes
folder:cd <path_to_comfyui>/custom_nodes
git clone https://github.com/PrunaAI/ComfyUI_pruna.git
cd <path_to_comfyui> && python main.py --disable-cuda-malloc --gpu-only
The Pruna node will appear in the nodes menu in the Pruna
category.
Important note: The current implementation requires launching ComfyUI with the --disable-cuda-malloc
flag;
otherwise the node may not function properly. For optimal performance, we also recommend setting the
--gpu-only
flag.
We provide two example workflows: one using a Stable Diffusion model and another based on Flux.
To load the workflow:
Open
in the Workflow
tab, as shown here, and select the fileThrough the GUI, you can choose your preferred compilation mode. Currently, we support x-fast
and torch_compile
, with x-fast
set as the default.
You have two options for the base model:
<path_to_comfyui>/models/checkpoints
<path_to_comfyui>/models/diffusers
Load Checkpoint
node with a DiffusersLoader
nodeThe node is tested using the SafeTensors format, so for the sake of reproducibility, we recommend using that format. However, we don't expect any performance differences between the two.
Note: In this example, we use the Stable Diffusion v1.4 model. However, our node is compatible with any other SD model — feel free to use your favorite one!
To use Flux, you must separately download all model components—including the VAE, CLIP, and diffusion model weights—and place them in the appropriate folder.
Steps to set up Flux:
For the CLIP models: Get the following files:
Move them to <path_to_comfyui>/models/clip/
.
For the VAE model:
Get the VAE model, and move it to <path_to_comfyui>/models/vae/
directory.
For the Flux model:
You first need to request access to the model here. Once you have access, download the weights and move them to <path_to_comfyui>/models/diffusion_models/
.
The node was tested on an NVIDIA L40S GPU. Below, we compare the performance of the base model, with the models compiled with Pruna's x-fast
and torch_compile
compilation modes.
ComfyUI
.
For questions, feedback or community discussions, feel free to join our Discord.
For bug reports or technical issues, please open an issue in this repository.