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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
- text-to-video
|
| 12 |
library_name: diffusers
|
| 13 |
pipeline_tag: image-to-video
|
| 14 |
+
---
|
| 15 |
+
# Hy1.5-Quantized-Models
|
| 16 |
+
|
| 17 |
+
This repository contains quantized models for [HunyuanVideo-1.5](https://huggingface.co/tencent/HunyuanVideo-1.5) optimized for use with [LightX2V](https://github.com/ModelTC/LightX2V). These quantized models significantly reduce memory usage while maintaining high-quality video generation performance.
|
| 18 |
+
|
| 19 |
+
## π Model List
|
| 20 |
+
|
| 21 |
+
### DIT (Diffusion Transformer) Models
|
| 22 |
+
|
| 23 |
+
- **`hy15_720p_i2v_fp8_e4m3_lightx2v.safetensors`** - 720p Image-to-Video quantized DIT model
|
| 24 |
+
- **`hy15_720p_t2v_fp8_e4m3_lightx2v.safetensors`** - 720p Text-to-Video quantized DIT model
|
| 25 |
+
|
| 26 |
+
### Encoder Models
|
| 27 |
+
|
| 28 |
+
- **`hy15_qwen25vl_llm_encoder_fp8_e4m3_lightx2v.safetensors`** - Quantized text encoder (Qwen2.5-VL LLM Encoder)
|
| 29 |
+
|
| 30 |
+
## π Quick Start
|
| 31 |
+
|
| 32 |
+
### Installation
|
| 33 |
+
|
| 34 |
+
First, install LightX2V:
|
| 35 |
+
|
| 36 |
+
```bash
|
| 37 |
+
pip install -v git+https://github.com/ModelTC/LightX2V.git
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
Or build from source:
|
| 41 |
+
|
| 42 |
+
```bash
|
| 43 |
+
git clone https://github.com/ModelTC/LightX2V.git
|
| 44 |
+
cd LightX2V
|
| 45 |
+
pip install -v -e .
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
### Download Models
|
| 49 |
+
|
| 50 |
+
Download the quantized models from this repository:
|
| 51 |
+
|
| 52 |
+
```bash
|
| 53 |
+
# Using git-lfs
|
| 54 |
+
git lfs install
|
| 55 |
+
git clone https://huggingface.co/lightx2v/Hy1.5-Quantized-Models
|
| 56 |
+
|
| 57 |
+
# Or download individual files using huggingface-hub
|
| 58 |
+
pip install huggingface-hub
|
| 59 |
+
python -c "from huggingface_hub import hf_hub_download; hf_hub_download(repo_id='lightx2v/Hy1.5-Quantized-Models', filename='hy15_720p_i2v_fp8_e4m3_lightx2v.safetensors', local_dir='./models')"
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
## π» Usage in LightX2V
|
| 63 |
+
|
| 64 |
+
### Text-to-Video (T2V) Example
|
| 65 |
+
|
| 66 |
+
```python
|
| 67 |
+
from lightx2v import LightX2VPipeline
|
| 68 |
+
|
| 69 |
+
# Initialize pipeline
|
| 70 |
+
pipe = LightX2VPipeline(
|
| 71 |
+
model_path="/path/to/hunyuanvideo-1.5/", # Original model path
|
| 72 |
+
model_cls="hunyuan_video_1.5",
|
| 73 |
+
transformer_model_name="720p_t2v",
|
| 74 |
+
task="t2v",
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
# Enable quantization
|
| 78 |
+
pipe.enable_quantize(
|
| 79 |
+
quant_scheme='fp8-sgl',
|
| 80 |
+
dit_quantized=True,
|
| 81 |
+
dit_quantized_ckpt="/path/to/hy15_720p_t2v_fp8_e4m3_lightx2v.safetensors",
|
| 82 |
+
text_encoder_quantized=True,
|
| 83 |
+
text_encoder_quantized_ckpt="/path/to/hy15_qwen25vl_llm_encoder_fp8_e4m3_lightx2v.safetensors",
|
| 84 |
+
image_encoder_quantized=False,
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
# Optional: Enable offloading for lower VRAM usage
|
| 88 |
+
pipe.enable_offload(
|
| 89 |
+
cpu_offload=True,
|
| 90 |
+
offload_granularity="block", # For HunyuanVideo-1.5, only "block" is supported
|
| 91 |
+
text_encoder_offload=True,
|
| 92 |
+
image_encoder_offload=False,
|
| 93 |
+
vae_offload=False,
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
# Create generator
|
| 97 |
+
pipe.create_generator(
|
| 98 |
+
attn_mode="sage_attn2",
|
| 99 |
+
infer_steps=50,
|
| 100 |
+
num_frames=121,
|
| 101 |
+
guidance_scale=6.0,
|
| 102 |
+
sample_shift=9.0,
|
| 103 |
+
aspect_ratio="16:9",
|
| 104 |
+
fps=24,
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
# Generate video
|
| 108 |
+
seed = 123
|
| 109 |
+
prompt = "A beautiful sunset over the ocean with waves gently crashing on the shore."
|
| 110 |
+
negative_prompt = ""
|
| 111 |
+
save_result_path="/path/to/output.mp4"
|
| 112 |
+
|
| 113 |
+
pipe.generate(
|
| 114 |
+
seed=seed,
|
| 115 |
+
prompt=prompt,
|
| 116 |
+
negative_prompt=negative_prompt,
|
| 117 |
+
save_result_path=save_result_path,
|
| 118 |
+
)
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
### Image-to-Video (I2V) Example
|
| 122 |
+
|
| 123 |
+
```python
|
| 124 |
+
from lightx2v import LightX2VPipeline
|
| 125 |
+
|
| 126 |
+
# Initialize pipeline
|
| 127 |
+
pipe = LightX2VPipeline(
|
| 128 |
+
image_path="/path/to/input_image.jpg",
|
| 129 |
+
model_path="/path/to/hunyuanvideo-1.5/", # Original model path
|
| 130 |
+
model_cls="hunyuan_video_1.5",
|
| 131 |
+
transformer_model_name="720p_i2v",
|
| 132 |
+
task="i2v",
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
# Enable quantization
|
| 136 |
+
pipe.enable_quantize(
|
| 137 |
+
quant_scheme='fp8-sgl',
|
| 138 |
+
dit_quantized=True,
|
| 139 |
+
dit_quantized_ckpt="/path/to/hy15_720p_i2v_fp8_e4m3_lightx2v.safetensors",
|
| 140 |
+
text_encoder_quantized=True,
|
| 141 |
+
text_encoder_quantized_ckpt="/path/to/hy15_qwen25vl_llm_encoder_fp8_e4m3_lightx2v.safetensors",
|
| 142 |
+
image_encoder_quantized=False,
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
# Optional: Enable offloading for lower VRAM usage
|
| 146 |
+
pipe.enable_offload(
|
| 147 |
+
cpu_offload=True,
|
| 148 |
+
offload_granularity="block",
|
| 149 |
+
text_encoder_offload=True,
|
| 150 |
+
image_encoder_offload=False,
|
| 151 |
+
vae_offload=False,
|
| 152 |
+
)
|
| 153 |
+
|
| 154 |
+
# Create generator
|
| 155 |
+
pipe.create_generator(
|
| 156 |
+
attn_mode="sage_attn2",
|
| 157 |
+
infer_steps=50,
|
| 158 |
+
num_frames=121,
|
| 159 |
+
guidance_scale=6.0,
|
| 160 |
+
sample_shift=7.0,
|
| 161 |
+
fps=24,
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
# Generate video
|
| 165 |
+
seed = 42
|
| 166 |
+
prompt = "The image comes to life with smooth motion and natural transitions."
|
| 167 |
+
negative_prompt = ""
|
| 168 |
+
save_result_path="/path/to/output.mp4"
|
| 169 |
+
|
| 170 |
+
pipe.generate(
|
| 171 |
+
seed=seed,
|
| 172 |
+
prompt=prompt,
|
| 173 |
+
negative_prompt=negative_prompt,
|
| 174 |
+
save_result_path=save_result_path,
|
| 175 |
+
)
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
## βοΈ Quantization Scheme
|
| 179 |
+
|
| 180 |
+
These models use **FP8-E4M3** quantization with the **SGL (SGLang) kernel** scheme (`fp8-sgl`). This quantization format provides:
|
| 181 |
+
|
| 182 |
+
- **Significant memory reduction**: Up to 50% reduction in VRAM usage
|
| 183 |
+
- **Maintained quality**: Minimal quality degradation compared to full precision models
|
| 184 |
+
- **Faster inference**: Optimized kernels for accelerated computation
|
| 185 |
+
|
| 186 |
+
### Requirements
|
| 187 |
+
|
| 188 |
+
To use these quantized models, you need to install the SGL kernel:
|
| 189 |
+
|
| 190 |
+
```bash
|
| 191 |
+
# Requires torch == 2.8.0
|
| 192 |
+
pip install sgl-kernel --upgrade
|
| 193 |
+
```
|
| 194 |
+
|
| 195 |
+
Alternatively, you can use VLLM kernels:
|
| 196 |
+
|
| 197 |
+
```bash
|
| 198 |
+
pip install vllm
|
| 199 |
+
```
|
| 200 |
+
|
| 201 |
+
For more details on quantization schemes, please refer to the [LightX2V Quantization Documentation](https://lightx2v-en.readthedocs.io/en/latest/method_tutorials/quantization.html).
|
| 202 |
+
|
| 203 |
+
## π Performance Benefits
|
| 204 |
+
|
| 205 |
+
Using quantized models provides:
|
| 206 |
+
|
| 207 |
+
- **Lower VRAM Requirements**: Enables running on GPUs with less memory (e.g., RTX 4090 24GB)
|
| 208 |
+
- **Faster Inference**: Optimized quantized kernels accelerate computation
|
| 209 |
+
- **Quality Preservation**: FP8 quantization maintains high visual quality
|
| 210 |
+
|
| 211 |
+
## π Related Resources
|
| 212 |
+
|
| 213 |
+
- [LightX2V GitHub Repository](https://github.com/ModelTC/LightX2V)
|
| 214 |
+
- [LightX2V Documentation](https://lightx2v-en.readthedocs.io/en/latest/)
|
| 215 |
+
- [HunyuanVideo-1.5 Original Model](https://huggingface.co/tencent/HunyuanVideo-1.5)
|
| 216 |
+
- [LightX2V Examples](https://github.com/ModelTC/LightX2V/tree/main/examples)
|
| 217 |
+
|
| 218 |
+
## π Notes
|
| 219 |
+
|
| 220 |
+
- **Important**: All advanced configurations (including `enable_quantize()`) must be called **before** `create_generator()`, otherwise they will not take effect.
|
| 221 |
+
- The original HunyuanVideo-1.5 model weights are still required. These quantized models are used in conjunction with the original model structure.
|
| 222 |
+
- For best performance, we recommend using SageAttention 2 (`sage_attn2`) as the attention mode.
|
| 223 |
+
|
| 224 |
+
## π€ Citation
|
| 225 |
+
|
| 226 |
+
If you use these quantized models in your research, please cite:
|
| 227 |
+
|
| 228 |
+
```bibtex
|
| 229 |
+
@misc{lightx2v,
|
| 230 |
+
author = {LightX2V Contributors},
|
| 231 |
+
title = {LightX2V: Light Video Generation Inference Framework},
|
| 232 |
+
year = {2025},
|
| 233 |
+
publisher = {GitHub},
|
| 234 |
+
journal = {GitHub repository},
|
| 235 |
+
howpublished = {\url{https://github.com/ModelTC/lightx2v}},
|
| 236 |
+
}
|
| 237 |
+
```
|
| 238 |
+
|
| 239 |
+
## π License
|
| 240 |
+
|
| 241 |
+
This model is released under the Apache 2.0 License, same as the original HunyuanVideo-1.5 model.
|