xfuser 0.2__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {xfuser-0.2 → xfuser-0.3.2}/LICENSE.txt +1 -1
- {xfuser-0.2/xfuser.egg-info → xfuser-0.3.2}/PKG-INFO +175 -86
- xfuser-0.2/PKG-INFO → xfuser-0.3.2/README.md +161 -98
- xfuser-0.3.2/comfyui-xdit/__init__.py +2 -0
- xfuser-0.3.2/comfyui-xdit/host.py +253 -0
- xfuser-0.3.2/comfyui-xdit/launch_host.py +45 -0
- xfuser-0.3.2/comfyui-xdit/nodes.py +176 -0
- xfuser-0.3.2/comfyui-xdit/utils.py +7 -0
- xfuser-0.3.2/setup.py +57 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/__init__.py +10 -2
- xfuser-0.3.2/xfuser/__version__.py +1 -0
- xfuser-0.3.2/xfuser/config/args.py +317 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/config/config.py +97 -66
- xfuser-0.3.2/xfuser/core/__init__.py +15 -0
- xfuser-0.3.2/xfuser/core/cache_manager/__init__.py +5 -0
- xfuser-0.3.2/xfuser/core/cache_manager/cache_manager.py +228 -0
- {xfuser-0.2/xfuser → xfuser-0.3.2/xfuser/core}/distributed/__init__.py +12 -3
- {xfuser-0.2/xfuser → xfuser-0.3.2/xfuser/core}/distributed/group_coordinator.py +458 -197
- {xfuser-0.2/xfuser → xfuser-0.3.2/xfuser/core}/distributed/parallel_state.py +197 -253
- xfuser-0.3.2/xfuser/core/distributed/runtime_state.py +525 -0
- xfuser-0.3.2/xfuser/core/distributed/utils.py +188 -0
- xfuser-0.3.2/xfuser/core/long_ctx_attention/__init__.py +13 -0
- xfuser-0.3.2/xfuser/core/long_ctx_attention/hybrid/__init__.py +11 -0
- xfuser-0.3.2/xfuser/core/long_ctx_attention/hybrid/attn_layer.py +327 -0
- xfuser-0.3.2/xfuser/core/long_ctx_attention/hybrid/utils.py +11 -0
- xfuser-0.3.2/xfuser/core/long_ctx_attention/ring/__init__.py +5 -0
- xfuser-0.3.2/xfuser/core/long_ctx_attention/ring/ring_flash_attn.py +187 -0
- xfuser-0.3.2/xfuser/core/long_ctx_attention/ulysses/__init__.py +5 -0
- xfuser-0.3.2/xfuser/core/long_ctx_attention/ulysses/attn_layer.py +160 -0
- xfuser-0.3.2/xfuser/core/utils/__init__.py +1 -0
- xfuser-0.3.2/xfuser/core/utils/timer.py +19 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/envs.py +38 -39
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/base_wrapper.py +18 -6
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/layers/__init__.py +2 -0
- xfuser-0.3.2/xfuser/model_executor/layers/attention_processor.py +1152 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/layers/conv.py +18 -8
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/layers/embeddings.py +71 -8
- xfuser-0.3.2/xfuser/model_executor/layers/feedforward.py +69 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/models/base_model.py +40 -14
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/models/transformers/__init__.py +6 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/models/transformers/base_transformer.py +18 -8
- xfuser-0.3.2/xfuser/model_executor/models/transformers/cogvideox_transformer_3d.py +125 -0
- xfuser-0.3.2/xfuser/model_executor/models/transformers/hunyuan_transformer_2d.py +264 -0
- xfuser-0.3.2/xfuser/model_executor/models/transformers/latte_transformer_3d.py +250 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/models/transformers/pixart_transformer_2d.py +42 -21
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/models/transformers/transformer_flux.py +56 -15
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/models/transformers/transformer_sd3.py +61 -29
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/pipelines/__init__.py +6 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/pipelines/base_pipeline.py +151 -46
- xfuser-0.3.2/xfuser/model_executor/pipelines/pipeline_cogvideox.py +423 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/pipelines/pipeline_flux.py +62 -66
- xfuser-0.3.2/xfuser/model_executor/pipelines/pipeline_hunyuandit.py +920 -0
- xfuser-0.3.2/xfuser/model_executor/pipelines/pipeline_latte.py +380 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/pipelines/pipeline_pixart_alpha.py +9 -5
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/pipelines/pipeline_pixart_sigma.py +9 -5
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/pipelines/pipeline_stable_diffusion_3.py +16 -24
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/schedulers/__init__.py +8 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/schedulers/base_scheduler.py +14 -7
- xfuser-0.3.2/xfuser/model_executor/schedulers/scheduling_ddim.py +62 -0
- xfuser-0.3.2/xfuser/model_executor/schedulers/scheduling_ddim_cogvideox.py +57 -0
- xfuser-0.3.2/xfuser/model_executor/schedulers/scheduling_ddpm.py +53 -0
- xfuser-0.3.2/xfuser/model_executor/schedulers/scheduling_dpm_cogvideox.py +57 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/schedulers/scheduling_dpmsolver_multistep.py +54 -22
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/schedulers/scheduling_flow_match_euler_discrete.py +14 -8
- xfuser-0.3.2/xfuser/parallel.py +54 -0
- xfuser-0.2/README.md → xfuser-0.3.2/xfuser.egg-info/PKG-INFO +187 -77
- {xfuser-0.2 → xfuser-0.3.2}/xfuser.egg-info/SOURCES.txt +35 -7
- xfuser-0.3.2/xfuser.egg-info/requires.txt +14 -0
- xfuser-0.3.2/xfuser.egg-info/top_level.txt +2 -0
- xfuser-0.2/setup.py +0 -37
- xfuser-0.2/xfuser/__version__.py +0 -1
- xfuser-0.2/xfuser/config/args.py +0 -198
- xfuser-0.2/xfuser/distributed/runtime_state.py +0 -328
- xfuser-0.2/xfuser/model_executor/layers/attention_processor.py +0 -748
- xfuser-0.2/xfuser/modules/__init__.py +0 -0
- xfuser-0.2/xfuser/modules/long_context_attention.py +0 -396
- xfuser-0.2/xfuser/parallel.py +0 -52
- xfuser-0.2/xfuser.egg-info/requires.txt +0 -8
- xfuser-0.2/xfuser.egg-info/top_level.txt +0 -1
- {xfuser-0.2 → xfuser-0.3.2}/setup.cfg +0 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/config/__init__.py +0 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/logger.py +0 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/__init__.py +0 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/layers/base_layer.py +0 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/layers/register.py +0 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/models/__init__.py +0 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/models/transformers/register.py +0 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/pipelines/register.py +0 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser/model_executor/schedulers/register.py +0 -0
- {xfuser-0.2 → xfuser-0.3.2}/xfuser.egg-info/dependency_links.txt +0 -0
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
same "printed page" as the copyright notice for easier
|
|
188
188
|
identification within third-party archives.
|
|
189
189
|
|
|
190
|
-
Copyright [2024] [
|
|
190
|
+
Copyright [2024] [xDiT Team]
|
|
191
191
|
|
|
192
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
193
|
you may not use this file except in compliance with the License.
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: xfuser
|
|
3
|
-
Version: 0.2
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: xDiT: A Scalable Inference Engine for Diffusion Transformers (DiTs) on multi-GPU Clusters
|
|
5
5
|
Home-page: https://github.com/xdit-project/xDiT.
|
|
6
|
-
Author:
|
|
6
|
+
Author: xDiT Team
|
|
7
7
|
Author-email: fangjiarui123@gmail.com
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: Operating System :: OS Independent
|
|
10
10
|
Requires-Python: >=3.10
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
License-File: LICENSE.txt
|
|
13
|
-
Requires-Dist: torch>=2.
|
|
14
|
-
Requires-Dist:
|
|
15
|
-
Requires-Dist:
|
|
16
|
-
Requires-Dist:
|
|
17
|
-
Requires-Dist:
|
|
18
|
-
Requires-Dist: beautifulsoup4
|
|
13
|
+
Requires-Dist: torch>=2.1.0
|
|
14
|
+
Requires-Dist: accelerate>=0.33.0
|
|
15
|
+
Requires-Dist: diffusers>=0.30.3
|
|
16
|
+
Requires-Dist: transformers>=4.39.1
|
|
17
|
+
Requires-Dist: sentencepiece>=0.1.99
|
|
18
|
+
Requires-Dist: beautifulsoup4>=4.12.3
|
|
19
19
|
Requires-Dist: distvae
|
|
20
|
-
Requires-Dist:
|
|
20
|
+
Requires-Dist: yunchang>=0.3.0
|
|
21
|
+
Requires-Dist: pytest
|
|
22
|
+
Requires-Dist: flask
|
|
23
|
+
Requires-Dist: opencv-python
|
|
24
|
+
Provides-Extra: flash-attn
|
|
25
|
+
Requires-Dist: flash_attn>=2.6.3; extra == "flash-attn"
|
|
21
26
|
|
|
22
27
|
<div align="center">
|
|
23
28
|
<!-- <h1>KTransformers</h1> -->
|
|
@@ -25,12 +30,15 @@ Requires-Dist: ftfy
|
|
|
25
30
|
|
|
26
31
|
<picture>
|
|
27
32
|
<img alt="xDiT" src="./assets/XDiTlogo.png" width=50%>
|
|
28
|
-
|
|
29
33
|
</picture>
|
|
30
34
|
|
|
31
35
|
</p>
|
|
32
36
|
<h3>A Scalable Inference Engine for Diffusion Transformers (DiTs) on multi-GPU Clusters</h3>
|
|
33
37
|
<strong><a href="https://arxiv.org/abs/2405.14430">📃 Paper</a> | <a href="#QuickStart">🚀 Quick Start</a> | <a href="#support-dits">🎯 Supported DiTs</a> | <a href="#dev-guide">📚 Dev Guide </a> | <a href="https://github.com/xdit-project/xDiT/discussions">📈 Discussion </a> </strong>
|
|
38
|
+
<p></p>
|
|
39
|
+
|
|
40
|
+
[](https://discord.gg/YEWzWfCF9S)
|
|
41
|
+
|
|
34
42
|
</div>
|
|
35
43
|
|
|
36
44
|
<h2 id="agenda">Table of Contents</h2>
|
|
@@ -39,13 +47,20 @@ Requires-Dist: ftfy
|
|
|
39
47
|
- [📢 Updates](#updates)
|
|
40
48
|
- [🎯 Supported DiTs](#support-dits)
|
|
41
49
|
- [📈 Performance](#perf)
|
|
50
|
+
- [Flux.1](#perf_flux)
|
|
51
|
+
- [HunyuanDiT](#perf_hunyuandit)
|
|
52
|
+
- [SD3](#perf_sd3)
|
|
53
|
+
- [Pixart](#perf_pixart)
|
|
54
|
+
- [Latte](#perf_latte)
|
|
42
55
|
- [🚀 QuickStart](#QuickStart)
|
|
43
|
-
- [✨
|
|
44
|
-
- [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
- [✨ xDiT's Arsenal](#secrets)
|
|
57
|
+
- [Parallel Methods](#parallel)
|
|
58
|
+
- [1. PipeFusion](#PipeFusion)
|
|
59
|
+
- [2. Unified Sequence Parallel](#USP)
|
|
60
|
+
- [3. Hybrid Parallel](#hybrid_parallel)
|
|
61
|
+
- [4. CFG Parallel](#cfg_parallel)
|
|
62
|
+
- [5. Parallel VAE](#parallel_vae)
|
|
63
|
+
- [Compilation Acceleration](#compilation)
|
|
49
64
|
- [📚 Develop Guide](#dev-guide)
|
|
50
65
|
- [🚧 History and Looking for Contributions](#history)
|
|
51
66
|
- [📝 Cite Us](#cite-us)
|
|
@@ -53,13 +68,14 @@ Requires-Dist: ftfy
|
|
|
53
68
|
|
|
54
69
|
<h2 id="meet-xdit">🔥 Meet xDiT</h2>
|
|
55
70
|
|
|
56
|
-
Diffusion Transformers (DiTs)
|
|
57
|
-
With the escalating input
|
|
58
|
-
Consequently, multi-GPU and multi-machine deployments are essential to
|
|
71
|
+
Diffusion Transformers (DiTs) are driving advancements in high-quality image and video generation.
|
|
72
|
+
With the escalating input context length in DiTs, the computational demand of the Attention mechanism grows **quadratically**!
|
|
73
|
+
Consequently, multi-GPU and multi-machine deployments are essential to meet the **real-time** requirements in online services.
|
|
59
74
|
|
|
60
75
|
To meet real-time demand for DiTs applications, parallel inference is a must.
|
|
61
76
|
xDiT is an inference engine designed for the parallel deployment of DiTs on large scale.
|
|
62
|
-
xDiT provides a suite of efficient parallel
|
|
77
|
+
xDiT provides a suite of efficient parallel approaches for Diffusion Models, as well as GPU kernel accelerations.
|
|
78
|
+
|
|
63
79
|
|
|
64
80
|
1. Sequence Parallelism, [USP](https://arxiv.org/abs/2405.07719) is a unified sequence parallel approach combining DeepSpeed-Ulysses, Ring-Attention.
|
|
65
81
|
|
|
@@ -71,44 +87,30 @@ xDiT provides a suite of efficient parallel inference approaches for Diffusion M
|
|
|
71
87
|
|
|
72
88
|
The four parallel methods in xDiT can be configured in a hybrid manner, optimizing communication patterns to best suit the underlying network hardware.
|
|
73
89
|
|
|
74
|
-
xDiT offers a set of APIs to adapt DiT models in [huggingface/diffusers](https://github.com/huggingface/diffusers) to hybrid parallel implementation through simple wrappers.
|
|
90
|
+
As shown in the following picture, xDiT offers a set of APIs to adapt DiT models in [huggingface/diffusers](https://github.com/huggingface/diffusers) to hybrid parallel implementation through simple wrappers.
|
|
75
91
|
If the model you require is not available in the model zoo, developing it yourself is straightforward; please refer to our [Dev Guide](#dev-guide).
|
|
76
92
|
|
|
77
|
-
|
|
78
93
|
We also have implemented the following parallel stategies for reference:
|
|
79
94
|
|
|
80
95
|
1. Tensor Parallelism
|
|
81
96
|
2. [DistriFusion](https://arxiv.org/abs/2402.19481)
|
|
82
97
|
|
|
83
|
-
The communication and memory costs associated with the aforementioned parallelism, except for the CFG and DP, in DiTs are detailed in the table below. (* denotes that communication can be overlapped with computation.)
|
|
84
|
-
|
|
85
98
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
𝒑: Number of pixels;
|
|
89
|
-
𝒉𝒔: Model hidden size;
|
|
90
|
-
𝑳: Number of model layers;
|
|
91
|
-
𝑷: Total model parameters;
|
|
92
|
-
𝑵: Number of parallel devices;
|
|
93
|
-
𝑴: Number of patch splits;
|
|
94
|
-
𝑸𝑶: Query and Output parameter count;
|
|
95
|
-
𝑲𝑽: KV Activation parameter count;
|
|
96
|
-
𝑨 = 𝑸 = 𝑶 = 𝑲 = 𝑽: Equal parameters for Attention, Query, Output, Key, and Value;
|
|
99
|
+
Optimization orthogonal to parallelization focuses on accelerating single GPU performance.
|
|
100
|
+
In addition to utilizing well-known Attention optimization libraries, we leverage compilation acceleration technologies such as `torch.compile` and `onediff`.
|
|
97
101
|
|
|
98
|
-
|
|
102
|
+
The overview of xDiT is shown as follows.
|
|
99
103
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
| DistriFusion* | stale | $2O(p \times hs)L$ | $P$ | $\frac{2}{N}A = \frac{1}{N}QO$ | $2AL = (KV)L$ |
|
|
104
|
-
| Ring Sequence Parallel* | fresh | $2O(p \times hs)L$ | $P$ | $\frac{2}{N}A = \frac{1}{N}QO$ | $\frac{2}{N}A = \frac{1}{N}KV$ |
|
|
105
|
-
| Ulysses Sequence Parallel | fresh | $\frac{4}{N}O(p \times hs)L$ | $P$ | $\frac{2}{N}A = \frac{1}{N}QO$ | $\frac{2}{N}A = \frac{1}{N}KV$ |
|
|
106
|
-
| PipeFusion* | stale- | $2O(p \times hs)$ | $\frac{1}{N}P$ | $\frac{2}{M}A = \frac{1}{M}QO$ | $\frac{2L}{N}A = \frac{1}{N}(KV)L$ |
|
|
104
|
+
<picture>
|
|
105
|
+
<img alt="xDiT" src="./assets/methods/xdit_overview.png">
|
|
106
|
+
</picture>
|
|
107
107
|
|
|
108
|
-
</div>
|
|
109
108
|
|
|
110
109
|
<h2 id="updates">📢 Updates</h2>
|
|
111
110
|
|
|
111
|
+
* ⚙️**August 30, 2024**: Supporting(WIP) CogVideoX. The inference scripts are [examples/latte_example](examples/cogvideox_example.py).
|
|
112
|
+
* 🎉**August 26, 2024**: We apply torch.compile and [onediff](https://github.com/siliconflow/onediff) nexfort backend to accelerate GPU kernels speed.
|
|
113
|
+
* 🎉**August 9, 2024**: Support Latte sequence parallel version. The inference scripts are [examples/latte_example](examples/latte_example.py).
|
|
112
114
|
* 🎉**August 8, 2024**: Support Flux sequence parallel version. The inference scripts are [examples/flux_example](examples/flux_example.py).
|
|
113
115
|
* 🎉**August 2, 2024**: Support Stable Diffusion 3 hybrid parallel version. The inference scripts are [examples/sd3_example](examples/sd3_example.py).
|
|
114
116
|
* 🎉**July 18, 2024**: Support PixArt-Sigma and PixArt-Alpha. The inference scripts are [examples/pixartsigma_example.py](examples/pixartsigma_example.py), [examples/pixartalpha_example.py](examples/pixartalpha_example.py).
|
|
@@ -120,60 +122,76 @@ As we can see, PipeFusion and Sequence Parallel achieve lowest communication cos
|
|
|
120
122
|
|
|
121
123
|
<h2 id="support-dits">🎯 Supported DiTs</h2>
|
|
122
124
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
<div align="center">
|
|
126
|
+
|
|
127
|
+
| Model Name | CFG | SP | PipeFusion |
|
|
128
|
+
| --- | --- | --- | --- |
|
|
129
|
+
| [🎬 CogVideoX](https://huggingface.co/THUDM/CogVideoX-2b) | ❎ | ❎ | ❎ |
|
|
130
|
+
| [🎬 Latte](https://huggingface.co/maxin-cn/Latte-1) | ❎ | ✔️ | ❎ |
|
|
131
|
+
| [🔵 HunyuanDiT-v1.2-Diffusers](https://huggingface.co/Tencent-Hunyuan/HunyuanDiT-v1.2-Diffusers) | ✔️ | ✔️ | ✔️ |
|
|
132
|
+
| [🟠 Flux](https://huggingface.co/black-forest-labs/FLUX.1-schnell) | NA | ✔️ | ❎ |
|
|
133
|
+
| [🔴 PixArt-Sigma](https://huggingface.co/PixArt-alpha/PixArt-Sigma-XL-2-1024-MS) | ✔️ | ✔️ | ✔️ |
|
|
134
|
+
| [🟢 PixArt-alpha](https://huggingface.co/PixArt-alpha/PixArt-alpha) | ✔️ | ✔️ | ✔️ |
|
|
135
|
+
| [🟠 Stable Diffusion 3](https://huggingface.co/stabilityai/stable-diffusion-3-medium-diffusers) | ✔️ | ✔️ | ✔️ |
|
|
136
|
+
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
### Supported by legacy version only, including DistriFusion and Tensor Parallel as the standalong parallel strategies:
|
|
140
|
+
|
|
141
|
+
<div align="center">
|
|
129
142
|
|
|
143
|
+
[🔴 DiT-XL](https://huggingface.co/facebook/DiT-XL-2-256)
|
|
144
|
+
</div>
|
|
130
145
|
|
|
131
146
|
<h2 id="perf">📈 Performance</h2>
|
|
132
147
|
|
|
133
|
-
|
|
148
|
+
<h3 id="perf_flux">Flux.1</h3>
|
|
134
149
|
|
|
135
|
-
|
|
150
|
+
1. [Flux Performance Report](./docs/performance/flux.md)
|
|
136
151
|
|
|
137
|
-
|
|
152
|
+
<h3 id="perf_hunyuandit">HunyuanDiT</h3>
|
|
138
153
|
|
|
139
|
-
|
|
140
|
-
<img src="./assets/latency-A100-PCIe.png" alt="A100 PCIe latency">
|
|
141
|
-
</div>
|
|
154
|
+
2. [HunyuanDiT Performance Report](./docs/performance/hunyuandit.md)
|
|
142
155
|
|
|
143
|
-
|
|
156
|
+
<h3 id="perf_sd3">SD3</h3>
|
|
144
157
|
|
|
145
|
-
|
|
146
|
-
<img src="./assets/latency-L20.png" alt="L20 latency">
|
|
147
|
-
</div>
|
|
158
|
+
3. [Stable Diffusion 3 Performance Report](./docs/performance/sd3.md)
|
|
148
159
|
|
|
149
|
-
|
|
160
|
+
<h3 id="perf_pixart">Pixart</h3>
|
|
150
161
|
|
|
151
|
-
|
|
152
|
-
<img src="./assets/latency-A100-NVLink.png" alt="latency-A100-NVLink">
|
|
153
|
-
</div>
|
|
162
|
+
4. [Pixart-Alpha Performance Report (legacy)](./docs/performance/pixart_alpha_legacy.md)
|
|
154
163
|
|
|
155
|
-
|
|
164
|
+
<h3 id="perf_latte">Pixart</h3>
|
|
156
165
|
|
|
157
|
-
|
|
158
|
-
<img src="./assets/latency-T4.png"
|
|
159
|
-
alt="latency-T4">
|
|
160
|
-
</div>
|
|
166
|
+
5. [Latte Performance Report](./docs/performance/latte.md)
|
|
161
167
|
|
|
162
168
|
|
|
163
169
|
<h2 id="QuickStart">🚀 QuickStart</h2>
|
|
164
170
|
|
|
165
|
-
1. Install
|
|
171
|
+
### 1. Install from pip (current [version](./xfuser/__version__.py))
|
|
166
172
|
|
|
167
|
-
|
|
168
|
-
|
|
173
|
+
```
|
|
174
|
+
pip install xfuser
|
|
175
|
+
# Or optionally, with flash_attn
|
|
176
|
+
pip install "xfuser[flash_attn]"
|
|
177
|
+
```
|
|
169
178
|
|
|
170
|
-
2. Install
|
|
179
|
+
### 2. Install from source
|
|
171
180
|
|
|
172
181
|
```
|
|
173
|
-
|
|
182
|
+
pip install -e .
|
|
183
|
+
# Or optionally, with flash_attn
|
|
184
|
+
pip install -e ".[flash_attn]"
|
|
174
185
|
```
|
|
175
186
|
|
|
176
|
-
|
|
187
|
+
Note that we use two self-maintained packages:
|
|
188
|
+
|
|
189
|
+
1. [yunchang](https://github.com/feifeibear/long-context-attention)
|
|
190
|
+
2. [DistVAE](https://github.com/xdit-project/DistVAE)
|
|
191
|
+
|
|
192
|
+
The [flash_attn](https://github.com/Dao-AILab/flash-attention) used for yunchang should be >= 2.6.0
|
|
193
|
+
|
|
194
|
+
### 3. Usage
|
|
177
195
|
|
|
178
196
|
We provide examples demonstrating how to run models with xDiT in the [./examples/](./examples/) directory.
|
|
179
197
|
You can easily modify the model type, model directory, and parallel options in the [examples/run.sh](examples/run.sh) within the script to run some already supported DiT models.
|
|
@@ -204,13 +222,15 @@ Runtime Options:
|
|
|
204
222
|
--warmup_steps WARMUP_STEPS
|
|
205
223
|
Warmup steps in generation.
|
|
206
224
|
--use_parallel_vae
|
|
225
|
+
--use_torch_compile Enable torch.compile to accelerate inference in a single card
|
|
207
226
|
--seed SEED Random seed for operations.
|
|
208
227
|
--output_type OUTPUT_TYPE
|
|
209
228
|
Output type of the pipeline.
|
|
229
|
+
--enable_sequential_cpu_offload
|
|
230
|
+
Offloading the weights to the CPU.
|
|
210
231
|
|
|
211
232
|
Parallel Processing Options:
|
|
212
|
-
--
|
|
213
|
-
--use_split_batch Use split batch in classifier_free_guidance. cfg_degree will be 2 if set
|
|
233
|
+
--use_cfg_parallel Use split batch in classifier_free_guidance. cfg_degree will be 2 if set
|
|
214
234
|
--data_parallel_degree DATA_PARALLEL_DEGREE
|
|
215
235
|
Data parallel degree.
|
|
216
236
|
--ulysses_degree ULYSSES_DEGREE
|
|
@@ -255,40 +275,102 @@ examples/pixartalpha_example.py \
|
|
|
255
275
|
--num_inference_steps 20 \
|
|
256
276
|
--warmup_steps 0 \
|
|
257
277
|
--prompt "A small dog" \
|
|
258
|
-
--
|
|
278
|
+
--use_cfg_parallel
|
|
259
279
|
```
|
|
260
280
|
|
|
261
|
-
|
|
262
281
|
⚠️ Applying PipeFusion requires setting `warmup_steps`, also required in DistriFusion, typically set to a small number compared with `num_inference_steps`.
|
|
263
282
|
The warmup step impacts the efficiency of PipeFusion as it cannot be executed in parallel, thus degrading to a serial execution.
|
|
264
283
|
We observed that a warmup of 0 had no effect on the PixArt model.
|
|
265
284
|
Users can tune this value according to their specific tasks.
|
|
266
285
|
|
|
267
286
|
|
|
268
|
-
<h2 id="secrets">✨ The xDiT's Secret Weapons</h2>
|
|
269
287
|
|
|
270
|
-
|
|
288
|
+
### 4. Launch a Http Service
|
|
271
289
|
|
|
272
|
-
|
|
290
|
+
[Launching a Text-to-Image Http Service](./docs/developer/Http_Service.md)
|
|
291
|
+
|
|
292
|
+
### 5. Launch ComfyUI
|
|
293
|
+
|
|
294
|
+
[Launching ComfyUI](./docs/developer/ComfyUI_xdit.md)
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
<h2 id="secrets">✨ The xDiT's Arsenal</h2>
|
|
298
|
+
|
|
299
|
+
The remarkable performance of xDiT is attributed to two key facets.
|
|
300
|
+
Firstly, it leverages parallelization techniques, pioneering innovations such as USP, PipeFusion, and hybrid parallelism, to scale DiTs inference to unprecedented scales.
|
|
301
|
+
|
|
302
|
+
Secondly, we employ compilation technologies to enhance execution on GPUs, integrating established solutions like `torch.compile` and `onediff` to optimize xDiT's performance.
|
|
303
|
+
|
|
304
|
+
<h3 id="parallel">1. Parallel Methods</h3>
|
|
305
|
+
|
|
306
|
+
As illustrated in the accompanying images, xDiTs offer a comprehensive set of parallelization techniques. For the DiT backbone, the foundational methods—Data, USP, PipeFusion, and CFG parallel—operate in a hybrid fashion. Additionally, the distinct methods, Tensor and DistriFusion parallel, function independently.
|
|
307
|
+
For the VAE module, xDiT offers a parallel implementation, [DistVAE](https://github.com/xdit-project/DistVAE), designed to prevent out-of-memory (OOM) issues.
|
|
308
|
+
The (<span style="color: red;">xDiT</span>) highlights the methods first proposed by use.
|
|
309
|
+
|
|
310
|
+
<div align="center">
|
|
311
|
+
<img src="assets/methods/xdit_method.png" alt="xdit methods">
|
|
312
|
+
</div>
|
|
313
|
+
|
|
314
|
+
The communication and memory costs associated with the aforementioned intra-image parallelism, except for the CFG and DP (they are inter-image parallel), in DiTs are detailed in the table below. (* denotes that communication can be overlapped with computation.)
|
|
315
|
+
|
|
316
|
+
As we can see, PipeFusion and Sequence Parallel achieve lowest communication cost on different scales and hardware configurations, making them suitable foundational components for a hybrid approach.
|
|
317
|
+
|
|
318
|
+
𝒑: Number of pixels;
|
|
319
|
+
𝒉𝒔: Model hidden size;
|
|
320
|
+
𝑳: Number of model layers;
|
|
321
|
+
𝑷: Total model parameters;
|
|
322
|
+
𝑵: Number of parallel devices;
|
|
323
|
+
𝑴: Number of patch splits;
|
|
324
|
+
𝑸𝑶: Query and Output parameter count;
|
|
325
|
+
𝑲𝑽: KV Activation parameter count;
|
|
326
|
+
𝑨 = 𝑸 = 𝑶 = 𝑲 = 𝑽: Equal parameters for Attention, Query, Output, Key, and Value;
|
|
327
|
+
|
|
328
|
+
<div align="center">
|
|
329
|
+
|
|
330
|
+
| | attn-KV | communication cost | param memory | activations memory | extra buff memory |
|
|
331
|
+
|:--------:|:-------:|:-----------------:|:-----:|:-----------:|:----------:|
|
|
332
|
+
| Tensor Parallel | fresh | $4O(p \times hs)L$ | $\frac{1}{N}P$ | $\frac{2}{N}A = \frac{1}{N}QO$ | $\frac{2}{N}A = \frac{1}{N}KV$ |
|
|
333
|
+
| DistriFusion* | stale | $2O(p \times hs)L$ | $P$ | $\frac{2}{N}A = \frac{1}{N}QO$ | $2AL = (KV)L$ |
|
|
334
|
+
| Ring Sequence Parallel* | fresh | $2O(p \times hs)L$ | $P$ | $\frac{2}{N}A = \frac{1}{N}QO$ | $\frac{2}{N}A = \frac{1}{N}KV$ |
|
|
335
|
+
| Ulysses Sequence Parallel | fresh | $\frac{4}{N}O(p \times hs)L$ | $P$ | $\frac{2}{N}A = \frac{1}{N}QO$ | $\frac{2}{N}A = \frac{1}{N}KV$ |
|
|
336
|
+
| PipeFusion* | stale- | $2O(p \times hs)$ | $\frac{1}{N}P$ | $\frac{2}{M}A = \frac{1}{M}QO$ | $\frac{2L}{N}A = \frac{1}{N}(KV)L$ |
|
|
337
|
+
|
|
338
|
+
</div>
|
|
339
|
+
|
|
340
|
+
<h4 id="PipeFusion">1.1. PipeFusion</h4>
|
|
273
341
|
|
|
274
342
|
[PipeFusion: Displaced Patch Pipeline Parallelism for Diffusion Models](./docs/methods/pipefusion.md)
|
|
275
343
|
|
|
276
|
-
<
|
|
344
|
+
<h4 id="USP">1.2. USP: Unified Sequence Parallelism</h4>
|
|
277
345
|
|
|
278
346
|
[USP: A Unified Sequence Parallelism Approach for Long Context Generative AI](./docs/methods/usp.md)
|
|
279
347
|
|
|
280
|
-
<
|
|
348
|
+
<h4 id="hybrid_parallel">1.3. Hybrid Parallel</h4>
|
|
281
349
|
|
|
282
350
|
[Hybrid Parallelism](./docs/methods/hybrid.md)
|
|
283
351
|
|
|
284
|
-
<
|
|
352
|
+
<h4 id="cfg_parallel">1.4. CFG Parallel</h4>
|
|
285
353
|
|
|
286
354
|
[CFG Parallel](./docs/methods/cfg_parallel.md)
|
|
287
355
|
|
|
288
|
-
<
|
|
356
|
+
<h4 id="parallel_vae">1.5. Parallel VAE</h4>
|
|
289
357
|
|
|
290
358
|
[Patch Parallel VAE](./docs/methods/parallel_vae.md)
|
|
291
359
|
|
|
360
|
+
<h3 id="compilation">Compilation Acceleration</h3>
|
|
361
|
+
|
|
362
|
+
We utilize two compilation acceleration techniques, [torch.compile](https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html) and [onediff](https://github.com/siliconflow/onediff), to enhance runtime speed on GPUs. These compilation accelerations are used in conjunction with parallelization methods.
|
|
363
|
+
|
|
364
|
+
We employ the nexfort backend of onediff. Please install it before use:
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
pip install onediff
|
|
368
|
+
pip install -U nexfort
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
For usage instructions, refer to the [example/run.sh](./examples/run.sh). Simply append `--use_torch_compile` or `--use_onediff` to your command. Note that these options are mutually exclusive, and their performance varies across different scenarios.
|
|
372
|
+
|
|
373
|
+
|
|
292
374
|
<h2 id="dev-guide">📚 Develop Guide</h2>
|
|
293
375
|
|
|
294
376
|
[The implement and design of xdit framework](./docs/developer/The_implement_design_of_xdit_framework.md)
|
|
@@ -318,5 +400,12 @@ We also welcome developers to join and contribute more features and models to th
|
|
|
318
400
|
archivePrefix={arXiv},
|
|
319
401
|
primaryClass={cs.CV}
|
|
320
402
|
}
|
|
403
|
+
|
|
404
|
+
@article{fang2024unified,
|
|
405
|
+
title={USP: a Unified Sequence Parallelism Approach for Long Context Generative AI},
|
|
406
|
+
author={Fang, Jiarui and Zhao, Shangchun},
|
|
407
|
+
journal={arXiv preprint arXiv:2405.07719},
|
|
408
|
+
year={2024}
|
|
409
|
+
}
|
|
321
410
|
```
|
|
322
411
|
|