Skip to content

Commit cf95194

Browse files
1
1 parent 280688c commit cf95194

File tree

95 files changed

+1438
-584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1438
-584
lines changed

custom_nodes/onediff_comfy_nodes/README.md

Lines changed: 74 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
---
88

9-
Performance of Community Edition
9+
Performance of Community Edition
1010

1111
Updated on January 23, 2024. Device: RTX 3090
1212

1313

1414
<div align="center">
15-
15+
1616
**SDXL End2End Time** , Image Size 1024x1024 , Batch Size 1 , steps 20
1717

1818
<a href="https://github.com/siliconflow/onediff/tree/main" target="_blank">
@@ -39,148 +39,125 @@ Updated on January 23, 2024. Device: RTX 3090
3939
- [OneDiff ComfyUI Nodes](#onediff-comfyui-nodes)
4040
- [Documentation](#documentation)
4141
- [Installation Guide](#installation-guide)
42-
- [Setup Community Edition](#setup-community-edition)
43-
- [Setup Enterprise Edition](#setup-enterprise-edition)
4442
- [Basic Node Usage](#basic-node-usage)
43+
- [Model Speedup](#model-speedup)
4544
- [Load Checkpoint - OneDiff](#load-checkpoint---onediff)
46-
- [Quantization](#quantization)
4745
- [Compiler Cache](#compiler-cache)
48-
- [Avoid compilation time for online serving](#avoid-compilation-time-for-online-serving)
49-
- [OneDiff Community Examples](#onediff-community-examples)
50-
- [IPAdapter](#ipadapter)
51-
- [LoRA](#lora)
52-
- [ControlNet](#controlnet)
53-
- [SVD](#svd)
54-
- [DeepCache](#deepcache)
55-
- [InstantID](#instantid)
46+
- [Quantization](#quantization)
47+
- [Tutorials](#tutorials)
5648
- [Contact](#contact)
5749

5850

5951
### Installation Guide
60-
61-
Please install and set up [ComfyUI](https://github.com/comfyanonymous/ComfyUI) first, and then:
62-
63-
#### Setup Community Edition
52+
This guide provides two methods to install ComfyUI and integrate it with the OneDiff library: via the Comfy CLI or directly from GitHub.
6453

6554
<details close>
66-
<summary>Setup Community Edition</summary>
67-
68-
1. Install OneFlow Community
69-
* Install OneFlow Community(CUDA 11.x)
70-
71-
```bash
72-
pip install --pre oneflow -f https://oneflow-pro.oss-cn-beijing.aliyuncs.com/branch/community/cu118
73-
```
74-
75-
* Install OneFlow Community(CUDA 12.x)
76-
77-
```bash
78-
pip install --pre oneflow -f https://oneflow-pro.oss-cn-beijing.aliyuncs.com/branch/community/cu121
79-
```
80-
2. Install OneDiff
81-
```bash
82-
git clone https://github.com/siliconflow/onediff.git
83-
cd onediff && pip install -e .
84-
```
55+
<summary> Option 1: Installing via Comfy CLI </summary>
8556

86-
3. Install onediff_comfy_nodes for ComfyUI
57+
1. **Install Comfy CLI**:
58+
```shell
59+
pip install comfy-cli
60+
```
8761

88-
```bash
89-
cd onediff
90-
ln -s $(pwd)/onediff_comfy_nodes path/to/ComfyUI/custom_nodes/
91-
# or
92-
# cp -r onediff_comfy_nodes path/to/ComfyUI/custom_nodes/
93-
```
62+
2. **Install ComfyUI**:
63+
```shell
64+
comfy install
65+
```
9466

95-
</details>
96-
97-
#### Setup Enterprise Edition
98-
99-
1. [Install OneDiff Enterprise](../README_ENTERPRISE.md#install-onediff-enterprise)
100-
101-
2. Install onediff_comfy_nodes for ComfyUI
102-
```bash
103-
git clone https://github.com/siliconflow/onediff.git
104-
cd onediff
105-
cp -r onediff_comfy_nodes path/to/ComfyUI/custom_nodes/
106-
```
67+
3. **Install OneDiff Comfy Nodes**:
68+
```shell
69+
comfy node install onediff_comfy_nodes
70+
```
71+
By default, this installs the oneflow backend. You can add other backends if needed; please refer to the OneDiff GitHub repository [here](https://github.com/siliconflow/onediff?tab=readme-ov-file#install-a-compiler-backend).
10772

10873
</details>
10974

75+
<details close>
76+
<summary> Option 2: Installing via GitHub </summary>
11077

111-
### Basic Node Usage
112-
113-
**Note** All the images in this section can be loaded directly into ComfyUI. You can load them in ComfyUI to get the full workflow.
114-
115-
#### Load Checkpoint - OneDiff
116-
117-
"Load Checkpoint - OneDiff" is the optimized version of "LoadCheckpoint", designed to accelerate the inference speed without any awareness required. It maintains the same input and output as the original node.
78+
First, install and set up [ComfyUI](https://github.com/comfyanonymous/ComfyUI), and then follow these steps:
11879

119-
![](workflows/model-speedup.png)
80+
1. **Clone OneDiff Repository**:
81+
```shell
82+
git clone https://github.com/siliconflow/onediff.git
83+
```
12084

121-
The "Load Checkpoint - OneDiff" node set `vae_speedup` : `enable` to enable VAE acceleration.
85+
2. **Install OneDiff**:
86+
```shell
87+
cd onediff && pip install -e .
88+
```
12289

90+
3. **Integrate OneDiff Comfy Nodes with ComfyUI**:
91+
- **Symbolic Link (Recommended)**:
92+
```shell
93+
ln -s $(pwd)/onediff_comfy_nodes path/to/ComfyUI/custom_nodes/
94+
```
95+
- **Copy Directory**:
96+
```shell
97+
cp -r onediff_comfy_nodes path/to/ComfyUI/custom_nodes/
98+
```
12399

124-
### Quantization
125-
126-
**Note**: Quantization feature is only supported by **OneDiff Enterprise**.
127-
128-
OneDiff Enterprise offers a quantization method that reduces memory usage, increases speed, and maintains quality without any loss.
100+
4. **Install a Compiler Backend**
129101

130-
If you possess a OneDiff Enterprise license key, you can access instructions on OneDiff quantization and related models by visiting [Online Quantization for ComfyUI](./ComfyUI_Online_Quantization.md). Alternatively, you can [contact](#contact) us to inquire about purchasing the OneDiff Enterprise license.
102+
For instructions on installing a compiler backend for OneDiff, please refer to the OneDiff GitHub repository [here](https://github.com/siliconflow/onediff?tab=readme-ov-file#install-a-compiler-backend).
131103

132-
![](workflows/onediff_quant_base.png)
133104

134-
### Compiler Cache
135-
#### Avoid compilation time for online serving
136-
The `"Load Checkpoint - OneDiff"` node automatically caches compiled results locally in the default directory `ComfyUI/input/graphs`. To save graphs in a custom directory, utilize `export COMFYUI_ONEDIFF_SAVE_GRAPH_DIR="/path/to/save/graphs"`.
105+
</details>
137106

138-
## OneDiff Community Examples
139107

140-
### IPAdapter
141-
> doc link: [Accelerating cubiq/ComfyUI_IPAdapter_plus with OneDiff](./modules/oneflow/hijack_ipadapter_plus/README.md)
142108

143-
### LoRA
144109

145-
This example demonstrates how to utilize LoRAs. You have the flexibility to modify the LoRA models or adjust their strength without the need for recompilation.
146110

147-
[Lora Speedup](workflows/model-speedup-lora.png)
111+
### Basic Node Usage
148112

149-
### ControlNet
113+
**Note** All the images in this section can be loaded directly into ComfyUI. You can load them in ComfyUI to get the full workflow.
150114

151-
> doc link: [ControlNet](https://github.com/siliconflow/onediff/tree/main/onediff_comfy_nodes/workflows/ControlNet)
115+
#### Model Speedup
116+
![](./docs/model_speedup_basic.png)
152117

118+
#### Load Checkpoint - OneDiff
153119

154-
While there is an example demonstrating OpenPose ControlNet, it's important to note that OneDiff seamlessly supports a wide range of ControlNet types, including depth mapping, canny, and more.
120+
"Load Checkpoint - OneDiff" is the optimized version of "LoadCheckpoint", designed to accelerate the inference speed without any awareness required. It maintains the same input and output as the original node.
155121

156-
[ControlNet Speedup](workflows/ControlNet/controlnet_onediff.png)
122+
![](./docs/model-speedup.png)
157123

158-
### SVD
159-
> doc link: [SVD](https://github.com/siliconflow/onediff/tree/main/onediff_comfy_nodes/workflows/SVD)
124+
The "Load Checkpoint - OneDiff" node set `vae_speedup` : `enable` to enable VAE acceleration.
160125

161-
This example illustrates how OneDiff can be used to enhance the performance of a video model, specifically in the context of text-to-video generation using SVD. Furthermore, it is compatible with [SVD 1.1](https://huggingface.co/stabilityai/stable-video-diffusion-img2vid-xt-1-1).
162126

163-
[SVD Speedup](workflows/text-to-video-speedup.png)
164127

165-
### DeepCache
128+
### Compiler Cache
129+
**Avoid compilation time for online serving**
166130

167-
DeepCache is an innovative algorithm that substantially boosts the speed of diffusion models, achieving an approximate 2x improvement. When used in conjunction with OneDiff, it further accelerates the diffusion model to approximately 3x.
131+
```shell
132+
# Set custom directory for saving graphs in ComfyUI with OneFlow backend
133+
export COMFYUI_ONEDIFF_SAVE_GRAPH_DIR="/path/to/save/graphs"
168134
169-
Here are the example of applying DeepCache to SD and SVD models.
135+
# Enable graph cache for faster compilation
136+
export TORCHINDUCTOR_FX_GRAPH_CACHE=1
170137
171-
[Module DeepCache SpeedUp on SD](workflows/deep-cache.png)
138+
# Specify persistent cache directory for Torchinductor
139+
export TORCHINDUCTOR_CACHE_DIR=~/.torchinductor_cache
140+
```
172141

173-
[Module DeepCache SpeedUp on SVD](workflows/svd-deepcache.png)
142+
### Quantization
174143

175-
[Module DeepCache SpeedUp on LoRA](workflows/lora_deepcache/README.md)
144+
**Note**: Quantization feature is only supported by **OneDiff Enterprise**.
176145

146+
OneDiff Enterprise offers a quantization method that reduces memory usage, increases speed, and maintains quality without any loss.
177147

178-
### InstantID
148+
If you possess a OneDiff Enterprise license key, you can access instructions on OneDiff quantization and related models by visiting [Online Quantization for ComfyUI](./docs/ComfyUI_Online_Quantization.md). Alternatively, you can [contact](#contact) us to inquire about purchasing the OneDiff Enterprise license.
179149

180-
> doc link: [Accelerating cubiq/ComfyUI_InstantID with OneDiff](./modules/oneflow/hijack_comfyui_instantid/README.md)
181150

182-
> doc link: [Accelerating ZHO-ZHO-ZHO/ComfyUI-InstantID with OneDiff](./workflows/ComfyUI_InstantID_OneDiff.md)
151+
## Tutorials
183152

153+
- [Accelerate SD3 with onediff](./docs/sd3/README.md)
154+
- [First Switch Lora](./docs/lora.md)
155+
- [Accelerate cubiq/PuLID_ComfyUI](./docs/README.md)
156+
- [Accelerate cubiq/ComfyUI_IPAdapter_plus](./docs/README.md)
157+
- [Accelerate cubiq/ComfyUI_InstantID](./docs/README.md)
158+
- [Accelerate ControlNet](./docs/ControlNet/README.md)
159+
- [SVD](./docs/SVD/README.md)
160+
- [DeepCache](./docs/lora_deepcache/README.md)
184161

185162
## Contact
186163

custom_nodes/onediff_comfy_nodes/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""OneDiff ComfyUI Speedup Module"""
22
from onediff.utils.import_utils import is_nexfort_available, is_oneflow_available
3+
34
from ._config import is_disable_oneflow_backend
45
from ._nodes import (
56
ControlnetSpeedup,
@@ -51,7 +52,9 @@ def lazy_load_extra_nodes():
5152
update_node_mappings(nodes_nexfort_booster)
5253

5354
from .extras_nodes import nodes_prompt_styler
55+
5456
update_node_mappings(nodes_prompt_styler)
5557

58+
5659
# Lazy load all extra nodes when needed
5760
lazy_load_extra_nodes()

custom_nodes/onediff_comfy_nodes/_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import os
22
import sys
3-
import torch
3+
44
import folder_paths
5+
import torch
56

67
__all__ = [
78
"is_default_using_oneflow_backend",
89
"is_default_using_nexfort_backend",
910
"is_disable_oneflow_backend",
1011
]
1112

12-
1313
# https://github.com/comfyanonymous/ComfyUI/blob/master/folder_paths.py#L9
1414
os.environ["COMFYUI_ROOT"] = folder_paths.base_path
1515
_default_backend = os.environ.get("ONEDIFF_COMFY_NODES_DEFAULT_BACKEND", "oneflow")

0 commit comments

Comments
 (0)