Skip to content

Commit 9b6fd11

Browse files
Musisoulgushiqiao
andauthored
[Feat] entrypoint like diffusers (#475)
### 单卡 ```bash python examples/simple_launch.py ``` ```python # examples/simple_launch.py from lightx2v import LightGenerator generator = LightGenerator( model_path="/path/to/Wan2.1-T2V-1.3B", model_cls="wan2.1", task="t2v", ) video_path = generator.generate( prompt="Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage.", negative_prompt="镜头晃动,色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走", seed=42, save_result_path="output.mp4", ) ``` ### 多卡 ```bash export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 torchrun --nproc_per_node=8 examples/multi_launch.py ``` --------- Co-authored-by: gushiqiao <975033167@qq.com>
1 parent d996a81 commit 9b6fd11

27 files changed

+2290
-15
lines changed

README.md

100644100755
Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,66 @@
2020

2121
## :fire: Latest News
2222

23-
- **November 21, 2025:** 🚀 We support the [HunyuanVideo-1.5](https://huggingface.co/tencent/HunyuanVideo-1.5) video generation model since Day 0. With the same number of GPUs, LightX2V can achieve a speed improvement of over 2 times and supports deployment on GPUs with lower memory (such as the 24GB RTX 4090). It also supports CFG/Ulysses parallelism, efficient offloading, TeaCache/MagCache technologies, and more. We will soon update our models on our [HuggingFace page](https://huggingface.co/lightx2v), including quantization, step distillation, VAE distillation, and other related models. Refer to [this](https://github.com/ModelTC/LightX2V/tree/main/scripts/hunyuan_video_15) for usage tutorials.
23+
- **November 21, 2025:** 🚀 We support the [HunyuanVideo-1.5](https://huggingface.co/tencent/HunyuanVideo-1.5) video generation model since Day 0. With the same number of GPUs, LightX2V can achieve a speed improvement of over 2 times and supports deployment on GPUs with lower memory (such as the 24GB RTX 4090). It also supports CFG/Ulysses parallelism, efficient offloading, TeaCache/MagCache technologies, and more. It also supports deployment on domestic chips such as Muxi and Cambricon. Quantized models and lightweight VAE models are now available: [Hy1.5-Quantized-Models](https://huggingface.co/lightx2v/Hy1.5-Quantized-Models) for quantized inference, and [LightTAE for HunyuanVideo-1.5](https://huggingface.co/lightx2v/Autoencoders/blob/main/lighttaehy1_5.safetensors) for fast VAE decoding. We will soon update more models on our [HuggingFace page](https://huggingface.co/lightx2v), including step distillation, VAE distillation, and other related models. Refer to [this](https://github.com/ModelTC/LightX2V/tree/main/scripts/hunyuan_video_15) for usage tutorials, or check out the [examples directory](https://github.com/ModelTC/LightX2V/tree/main/examples) for code examples.
2424

2525
## 💡 Quick Start
2626

2727
For comprehensive usage instructions, please refer to our documentation: **[English Docs](https://lightx2v-en.readthedocs.io/en/latest/) | [中文文档](https://lightx2v-zhcn.readthedocs.io/zh-cn/latest/)**
2828

29+
### Installation from Git
30+
```bash
31+
pip install -v git+https://github.com/ModelTC/LightX2V.git
32+
```
33+
34+
### Building from Source
35+
```bash
36+
git clone https://github.com/ModelTC/LightX2V.git
37+
cd LightX2V
38+
uv pip install -v . # pip install -v .
39+
```
40+
41+
### (Optional) Install Attention/Quantize Operators
42+
For attention operators installation, please refer to our documentation: **[English Docs](https://lightx2v-en.readthedocs.io/en/latest/getting_started/quickstart.html#step-4-install-attention-operators) | [中文文档](https://lightx2v-zhcn.readthedocs.io/zh-cn/latest/getting_started/quickstart.html#id9)**
43+
44+
### Quick Start
45+
```python
46+
# examples/hunyuan_video/hunyuan_t2v.py
47+
from lightx2v import LightX2VPipeline
48+
49+
pipe = LightX2VPipeline(
50+
model_path="/path/to/ckpts/hunyuanvideo-1.5/",
51+
model_cls="hunyuan_video_1.5",
52+
transformer_model_name="720p_t2v",
53+
task="t2v",
54+
)
55+
56+
pipe.create_generator(
57+
attn_mode="sage_attn2",
58+
infer_steps=50,
59+
num_frames=121,
60+
guidance_scale=6.0,
61+
sample_shift=9.0,
62+
aspect_ratio="16:9",
63+
fps=24,
64+
)
65+
66+
seed = 123
67+
prompt = "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
68+
negative_prompt = ""
69+
save_result_path="/path/to/save_results/output.mp4"
70+
71+
pipe.generate(
72+
seed=seed,
73+
prompt=prompt,
74+
negative_prompt=negative_prompt,
75+
save_result_path=save_result_path,
76+
)
77+
78+
```
79+
80+
> 💡 **More Examples**: For more usage examples including quantization, offloading, caching, and other advanced configurations, please refer to the [examples directory](https://github.com/ModelTC/LightX2V/tree/main/examples).
81+
82+
2983

3084
## 🤖 Supported Model Ecosystem
3185

@@ -37,15 +91,13 @@ For comprehensive usage instructions, please refer to our documentation: **[Engl
3791
-[Qwen-Image-Edit-2509](https://huggingface.co/Qwen/Qwen-Image-Edit-2509)
3892

3993
### Quantized and Distilled Models/LoRAs (**🚀 Recommended: 4-step inference**)
40-
-[Hy1.5-Quantized-Models](https://huggingface.co/lightx2v/Hy1.5-Quantized-Models)
4194
-[Wan2.1-Distill-Models](https://huggingface.co/lightx2v/Wan2.1-Distill-Models)
4295
-[Wan2.2-Distill-Models](https://huggingface.co/lightx2v/Wan2.2-Distill-Models)
4396
-[Wan2.1-Distill-Loras](https://huggingface.co/lightx2v/Wan2.1-Distill-Loras)
4497
-[Wan2.2-Distill-Loras](https://huggingface.co/lightx2v/Wan2.2-Distill-Loras)
4598

4699
### Lightweight Autoencoder Models (**🚀 Recommended: fast inference & low memory usage**)
47100
-[Autoencoders](https://huggingface.co/lightx2v/Autoencoders)
48-
49101
🔔 Follow our [HuggingFace page](https://huggingface.co/lightx2v) for the latest model releases from our team.
50102

51103
### Autoregressive Models

README_zh.md

100644100755
Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,66 @@
2020

2121
## :fire: 最新动态
2222

23-
- **2025年11月21日:** 🚀 我们Day0支持了[HunyuanVideo-1.5](https://huggingface.co/tencent/HunyuanVideo-1.5)的视频生成模型,同样GPU数量,LightX2V可带来约2倍以上的速度提升,并支持更低显存GPU部署(如24G RTX4090)。支持CFG并行/Ulysses并行,高效Offload,TeaCache/MagCache等技术。同时支持沐曦,寒武纪等国产芯片部署。我们很快将在我们的[HuggingFace主页](https://huggingface.co/lightx2v)更新量化,步数蒸馏,VAE蒸馏等相关模型。使用教程参考[这里](https://github.com/ModelTC/LightX2V/tree/main/scripts/hunyuan_video_15)
23+
- **2025年11月21日:** 🚀 我们Day0支持了[HunyuanVideo-1.5](https://huggingface.co/tencent/HunyuanVideo-1.5)的视频生成模型,同样GPU数量,LightX2V可带来约2倍以上的速度提升,并支持更低显存GPU部署(如24G RTX4090)。支持CFG并行/Ulysses并行,高效Offload,TeaCache/MagCache等技术。同时支持沐曦,寒武纪等国产芯片部署。量化模型和轻量VAE模型现已可用:[Hy1.5-Quantized-Models](https://huggingface.co/lightx2v/Hy1.5-Quantized-Models)用于量化推理,[HunyuanVideo-1.5轻量TAE](https://huggingface.co/lightx2v/Autoencoders/blob/main/lighttaehy1_5.safetensors)用于快速VAE解码。我们很快将在我们的[HuggingFace主页](https://huggingface.co/lightx2v)更新更多模型,包括步数蒸馏,VAE蒸馏等相关模型。使用教程参考[这里](https://github.com/ModelTC/LightX2V/tree/main/scripts/hunyuan_video_15),或查看[示例目录](https://github.com/ModelTC/LightX2V/tree/main/examples)获取代码示例
2424

2525

2626
## 💡 快速开始
2727

2828
详细使用说明请参考我们的文档:**[英文文档](https://lightx2v-en.readthedocs.io/en/latest/) | [中文文档](https://lightx2v-zhcn.readthedocs.io/zh-cn/latest/)**
2929

30+
### 从 Git 安装
31+
```bash
32+
pip install -v git+https://github.com/ModelTC/LightX2V.git
33+
```
34+
35+
### 从源码构建
36+
```bash
37+
git clone https://github.com/ModelTC/LightX2V.git
38+
cd LightX2V
39+
uv pip install -v . # pip install -v .
40+
```
41+
42+
### (可选)安装注意力/量化算子
43+
注意力算子安装说明请参考我们的文档:**[英文文档](https://lightx2v-en.readthedocs.io/en/latest/getting_started/quickstart.html#step-4-install-attention-operators) | [中文文档](https://lightx2v-zhcn.readthedocs.io/zh-cn/latest/getting_started/quickstart.html#id9)**
44+
45+
### 快速开始
46+
```python
47+
# examples/hunyuan_video/hunyuan_t2v.py
48+
from lightx2v import LightX2VPipeline
49+
50+
pipe = LightX2VPipeline(
51+
model_path="/path/to/ckpts/hunyuanvideo-1.5/",
52+
model_cls="hunyuan_video_1.5",
53+
transformer_model_name="720p_t2v",
54+
task="t2v",
55+
)
56+
57+
pipe.create_generator(
58+
attn_mode="sage_attn2",
59+
infer_steps=50,
60+
num_frames=121,
61+
guidance_scale=6.0,
62+
sample_shift=9.0,
63+
aspect_ratio="16:9",
64+
fps=24,
65+
)
66+
67+
seed = 123
68+
prompt = "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
69+
negative_prompt = ""
70+
save_result_path="/path/to/save_results/output.mp4"
71+
72+
pipe.generate(
73+
seed=seed,
74+
prompt=prompt,
75+
negative_prompt=negative_prompt,
76+
save_result_path=save_result_path,
77+
)
78+
79+
```
80+
81+
> 💡 **更多示例**: 更多使用案例,包括量化、卸载、缓存等进阶配置,请参考 [examples 目录](https://github.com/ModelTC/LightX2V/tree/main/examples)
82+
3083
## 🤖 支持的模型生态
3184

3285
### 官方开源模型

docs/EN/source/getting_started/quickstart.md

100644100755
Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,46 @@ git clone https://github.com/thu-ml/SageAttention.git
102102
cd SageAttention && CUDA_ARCHITECTURES="8.0,8.6,8.9,9.0,12.0" EXT_PARALLEL=4 NVCC_APPEND_FLAGS="--threads 8" MAX_JOBS=32 pip install -v -e .
103103
```
104104

105-
**Option D: Q8 Kernels**
105+
#### Step 4: Install Quantization Operators (Optional)
106+
107+
Quantization operators are used to support model quantization, which can significantly reduce memory usage and accelerate inference. Choose the appropriate quantization operator based on your needs:
108+
109+
**Option A: VLLM Kernels (Recommended)**
110+
Suitable for various quantization schemes, supports FP8 and other quantization formats.
111+
112+
```bash
113+
pip install vllm
114+
```
115+
116+
Or install from source for the latest features:
117+
118+
```bash
119+
git clone https://github.com/vllm-project/vllm.git
120+
cd vllm
121+
uv pip install -e .
122+
```
123+
124+
**Option B: SGL Kernels**
125+
Suitable for SGL quantization scheme, requires torch == 2.8.0.
126+
127+
```bash
128+
pip install sgl-kernel --upgrade
129+
```
130+
131+
**Option C: Q8 Kernels**
132+
Suitable for Ada architecture GPUs (such as RTX 4090, L40S, etc.).
133+
106134
```bash
107135
git clone https://github.com/KONAKONA666/q8_kernels.git
108136
cd q8_kernels && git submodule init && git submodule update
109137
python setup.py install
110138
```
111139

140+
> 💡 **Note**:
141+
> - You can skip this step if you don't need quantization functionality
142+
> - Quantized models can be downloaded from [LightX2V HuggingFace](https://huggingface.co/lightx2v)
143+
> - For more quantization information, please refer to the [Quantization Documentation](method_tutorials/quantization.html)
144+
112145
#### Step 5: Verify Installation
113146

114147
```python
@@ -215,8 +248,27 @@ cd LightX2V
215248
216249
# Install Windows-specific dependencies
217250
pip install -r requirements_win.txt
251+
pip install -v -e .
252+
```
253+
254+
#### Step 7: Install Quantization Operators (Optional)
255+
256+
Quantization operators are used to support model quantization, which can significantly reduce memory usage and accelerate inference.
257+
258+
**Install VLLM (Recommended):**
259+
260+
Download the corresponding wheel package from [vllm-windows releases](https://github.com/SystemPanic/vllm-windows/releases) and install it.
261+
262+
```cmd
263+
# Install vLLM (please adjust according to actual filename)
264+
pip install vllm-0.9.1+cu124-cp312-cp312-win_amd64.whl
218265
```
219266

267+
> 💡 **Note**:
268+
> - You can skip this step if you don't need quantization functionality
269+
> - Quantized models can be downloaded from [LightX2V HuggingFace](https://huggingface.co/lightx2v)
270+
> - For more quantization information, please refer to the [Quantization Documentation](method_tutorials/quantization.html)
271+
220272
## 🎯 Inference Usage
221273

222274
### 📥 Model Preparation
@@ -249,6 +301,42 @@ bash scripts/wan/run_wan_t2v.sh
249301
scripts\win\run_wan_t2v.bat
250302
```
251303

304+
#### Python Script Launch
305+
306+
```python
307+
from lightx2v import LightX2VPipeline
308+
309+
pipe = LightX2VPipeline(
310+
model_path="/path/to/Wan2.1-T2V-14B",
311+
model_cls="wan2.1",
312+
task="t2v",
313+
)
314+
315+
pipe.create_generator(
316+
attn_mode="sage_attn2",
317+
infer_steps=50,
318+
height=480, # 720
319+
width=832, # 1280
320+
num_frames=81,
321+
guidance_scale=5.0,
322+
sample_shift=5.0,
323+
)
324+
325+
seed = 42
326+
prompt = "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
327+
negative_prompt = "镜头晃动,色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
328+
save_result_path="/path/to/save_results/output.mp4"
329+
330+
pipe.generate(
331+
seed=seed,
332+
prompt=prompt,
333+
negative_prompt=negative_prompt,
334+
save_result_path=save_result_path,
335+
)
336+
```
337+
338+
> 💡 **More Examples**: For more usage examples including quantization, offloading, caching, and other advanced configurations, please refer to the [examples directory](https://github.com/ModelTC/LightX2V/tree/main/examples).
339+
252340
## 📞 Get Help
253341

254342
If you encounter problems during installation or usage, please:

docs/ZH_CN/source/getting_started/quickstart.md

100644100755
Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ conda activate lightx2v
8383
pip install -v -e .
8484
```
8585

86-
8786
#### 步骤 4: 安装注意力机制算子
8887

8988
**选项 A: Flash Attention 2**
@@ -103,13 +102,46 @@ git clone https://github.com/thu-ml/SageAttention.git
103102
cd SageAttention && CUDA_ARCHITECTURES="8.0,8.6,8.9,9.0,12.0" EXT_PARALLEL=4 NVCC_APPEND_FLAGS="--threads 8" MAX_JOBS=32 pip install -v -e .
104103
```
105104

106-
**选项 D: Q8 Kernels**
105+
#### 步骤 4: 安装量化算子(可选)
106+
107+
量化算子用于支持模型量化功能,可以显著降低显存占用并加速推理。根据您的需求选择合适的量化算子:
108+
109+
**选项 A: VLLM Kernels(推荐)**
110+
适用于多种量化方案,支持 FP8 等量化格式。
111+
112+
```bash
113+
pip install vllm
114+
```
115+
116+
或者从源码安装以获得最新功能:
117+
118+
```bash
119+
git clone https://github.com/vllm-project/vllm.git
120+
cd vllm
121+
uv pip install -e .
122+
```
123+
124+
**选项 B: SGL Kernels**
125+
适用于 SGL 量化方案,需要 torch == 2.8.0。
126+
127+
```bash
128+
pip install sgl-kernel --upgrade
129+
```
130+
131+
**选项 C: Q8 Kernels**
132+
适用于 Ada 架构显卡(如 RTX 4090、L40S 等)。
133+
107134
```bash
108135
git clone https://github.com/KONAKONA666/q8_kernels.git
109136
cd q8_kernels && git submodule init && git submodule update
110137
python setup.py install
111138
```
112139

140+
> 💡 **提示**:
141+
> - 如果不需要使用量化功能,可以跳过此步骤
142+
> - 量化模型可以从 [LightX2V HuggingFace](https://huggingface.co/lightx2v) 下载
143+
> - 更多量化相关信息请参考 [量化文档](method_tutorials/quantization.html)
144+
113145
#### 步骤 5: 验证安装
114146
```python
115147
import lightx2v
@@ -215,6 +247,31 @@ cd LightX2V
215247
216248
# 安装 Windows 专用依赖
217249
pip install -r requirements_win.txt
250+
pip install -v -e .
251+
```
252+
253+
#### 步骤 7: 安装量化算子(可选)
254+
255+
量化算子用于支持模型量化功能,可以显著降低显存占用并加速推理。
256+
257+
**安装 VLLM(推荐):**
258+
259+
[vllm-windows releases](https://github.com/SystemPanic/vllm-windows/releases) 下载对应的 wheel 包并安装。
260+
261+
```cmd
262+
# 安装 vLLM(请根据实际文件名调整)
263+
pip install vllm-0.9.1+cu124-cp312-cp312-win_amd64.whl
264+
```
265+
266+
> 💡 **提示**:
267+
> - 如果不需要使用量化功能,可以跳过此步骤
268+
> - 量化模型可以从 [LightX2V HuggingFace](https://huggingface.co/lightx2v) 下载
269+
> - 更多量化相关信息请参考 [量化文档](method_tutorials/quantization.html)
270+
271+
#### 步骤 8: 验证安装
272+
```python
273+
import lightx2v
274+
print(f"LightX2V 版本: {lightx2v.__version__}")
218275
```
219276

220277
## 🎯 推理使用
@@ -248,6 +305,40 @@ bash scripts/wan/run_wan_t2v.sh
248305
# 使用 Windows 批处理脚本
249306
scripts\win\run_wan_t2v.bat
250307
```
308+
#### Python脚本启动
309+
310+
```python
311+
from lightx2v import LightX2VPipeline
312+
313+
pipe = LightX2VPipeline(
314+
model_path="/path/to/Wan2.1-T2V-14B",
315+
model_cls="wan2.1",
316+
task="t2v",
317+
)
318+
319+
pipe.create_generator(
320+
attn_mode="sage_attn2",
321+
infer_steps=50,
322+
height=480, # 720
323+
width=832, # 1280
324+
num_frames=81,
325+
guidance_scale=5.0,
326+
sample_shift=5.0,
327+
)
328+
329+
seed = 42
330+
prompt = "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
331+
negative_prompt = "镜头晃动,色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
332+
save_result_path="/path/to/save_results/output.mp4"
333+
334+
pipe.generate(
335+
seed=seed,
336+
prompt=prompt,
337+
negative_prompt=negative_prompt,
338+
save_result_path=save_result_path,
339+
)
340+
```
341+
251342

252343
## 📞 获取帮助
253344

0 commit comments

Comments
 (0)