Unverified Commit a58abf25 authored by gushiqiao's avatar gushiqiao Committed by GitHub
Browse files

Update doc (#387)

parent 6f281bdd
...@@ -179,7 +179,16 @@ huggingface-cli download lightx2v/Wan2.1-Distill-Models \ ...@@ -179,7 +179,16 @@ huggingface-cli download lightx2v/Wan2.1-Distill-Models \
--include "wan2.1_i2v_720p_lightx2v_4step.safetensors" --include "wan2.1_i2v_720p_lightx2v_4step.safetensors"
``` ```
**Step 2: Configure Launch Script** **Step 2: Manually Organize Other Components**
Directory structure as follows:
```
wan2.1_i2v_720p/
├── wan2.1_i2v_720p_lightx2v_4step.safetensors # Original precision
└── t5/clip/vae/config.json/xlm-roberta-large/google and other components # Need manual organization
```
**Step 3: Configure Launch Script**
```bash ```bash
# Set in launch script (point to directory containing model file) # Set in launch script (point to directory containing model file)
...@@ -219,17 +228,19 @@ huggingface-cli download lightx2v/Wan2.1-Distill-Models \ ...@@ -219,17 +228,19 @@ huggingface-cli download lightx2v/Wan2.1-Distill-Models \
--include "wan2.1_i2v_720p_int8_lightx2v_4step.safetensors" --include "wan2.1_i2v_720p_int8_lightx2v_4step.safetensors"
``` ```
**Directory Structure**: **Step 2: Manually Organize Other Components**
Directory structure as follows:
``` ```
wan2.1_i2v_720p_multi/ wan2.1_i2v_720p_multi/
├── wan2.1_i2v_720p_lightx2v_4step.safetensors # Original precision ├── wan2.1_i2v_720p_lightx2v_4step.safetensors # Original precision
├── wan2.1_i2v_720p_scaled_fp8_e4m3_lightx2v_4step.safetensors # FP8 quantization ├── wan2.1_i2v_720p_scaled_fp8_e4m3_lightx2v_4step.safetensors # FP8 quantization
└── wan2.1_i2v_720p_int8_lightx2v_4step.safetensors # INT8 quantization └── wan2.1_i2v_720p_int8_lightx2v_4step.safetensors # INT8 quantization
└── t5/clip/vae/config.json/xlm-roberta-large/google and other components # Manually organized └── t5/clip/vae/config.json/xlm-roberta-large/google and other components # Need manual organization
``` ```
**Step 2: Specify Model in Configuration File** **Step 3: Specify Model in Configuration File**
Edit configuration file (e.g., `configs/distill/wan_i2v_distill_4step_cfg.json`): Edit configuration file (e.g., `configs/distill/wan_i2v_distill_4step_cfg.json`):
...@@ -257,13 +268,15 @@ Edit configuration file (e.g., `configs/distill/wan_i2v_distill_4step_cfg.json`) ...@@ -257,13 +268,15 @@ Edit configuration file (e.g., `configs/distill/wan_i2v_distill_4step_cfg.json`)
> - **dit_original_ckpt**: Used to specify the path to original precision models (BF16/FP32/FP16) > - **dit_original_ckpt**: Used to specify the path to original precision models (BF16/FP32/FP16)
> - **dit_quantized_ckpt**: Used to specify the path to quantized models (FP8/INT8), must be used with `dit_quantized` and `dit_quant_scheme` parameters > - **dit_quantized_ckpt**: Used to specify the path to quantized models (FP8/INT8), must be used with `dit_quantized` and `dit_quant_scheme` parameters
**Step 3: Start Inference** **Step 4: Start Inference**
```bash ```bash
cd LightX2V/scripts cd LightX2V/scripts
bash wan/run_wan_i2v_distill_4step_cfg.sh bash wan/run_wan_i2v_distill_4step_cfg.sh
``` ```
> 💡 **Tip**: Other components (T5, CLIP, VAE, tokenizer, etc.) need to be manually organized into the model directory
### Wan2.2 Single-File Models ### Wan2.2 Single-File Models
#### Directory Structure Requirements #### Directory Structure Requirements
...@@ -273,10 +286,10 @@ When using Wan2.2 single-file models, you need to manually create a specific dir ...@@ -273,10 +286,10 @@ When using Wan2.2 single-file models, you need to manually create a specific dir
``` ```
wan2.2_models/ wan2.2_models/
├── high_noise_model/ # High-noise model directory (required) ├── high_noise_model/ # High-noise model directory (required)
│ └── wan2.2_i2v_A14b_high_noise_lightx2v_4step.safetensors # High-noise model file │ └── wan2.2_i2v_A14b_high_noise_lightx2v_4step.safetensors
── low_noise_model/ # Low-noise model directory (required) ── low_noise_model/ # Low-noise model directory (required)
│ └── wan2.2_i2v_A14b_low_noise_lightx2v_4step.safetensors # Low-noise model file │ └── wan2.2_i2v_A14b_low_noise_lightx2v_4step.safetensors
└── t5/vae/config.json/xlm-roberta-large/google and other components # Manually organized └── t5/clip/vae/config.json/... # Other components (manually organized)
``` ```
#### Scenario A: Only One Model File Per Directory #### Scenario A: Only One Model File Per Directory
...@@ -336,9 +349,10 @@ wan2.2_models_multi/ ...@@ -336,9 +349,10 @@ wan2.2_models_multi/
│ ├── wan2.2_i2v_A14b_high_noise_fp8_e4m3_lightx2v_4step.safetensors # FP8 quantization │ ├── wan2.2_i2v_A14b_high_noise_fp8_e4m3_lightx2v_4step.safetensors # FP8 quantization
│ └── wan2.2_i2v_A14b_high_noise_int8_lightx2v_4step.safetensors # INT8 quantization │ └── wan2.2_i2v_A14b_high_noise_int8_lightx2v_4step.safetensors # INT8 quantization
└── low_noise_model/ └── low_noise_model/
├── wan2.2_i2v_A14b_low_noise_lightx2v_4step.safetensors # Original precision │ ├── wan2.2_i2v_A14b_low_noise_lightx2v_4step.safetensors # Original precision
├── wan2.2_i2v_A14b_low_noise_fp8_e4m3_lightx2v_4step.safetensors # FP8 quantization │ ├── wan2.2_i2v_A14b_low_noise_fp8_e4m3_lightx2v_4step.safetensors # FP8 quantization
└── wan2.2_i2v_A14b_low_noise_int8_lightx2v_4step.safetensors # INT8 quantization │ └── wan2.2_i2v_A14b_low_noise_int8_lightx2v_4step.safetensors # INT8 quantization
└── t5/vae/config.json/xlm-roberta-large/google and other components # Need manual organization
``` ```
**Configuration File Settings**: **Configuration File Settings**:
...@@ -450,16 +464,17 @@ Dynamically load LoRA weights during inference without modifying the base model. ...@@ -450,16 +464,17 @@ Dynamically load LoRA weights during inference without modifying the base model.
```python ```python
# LoRA weight application formula # LoRA weight application formula
# W' = W + (alpha/rank) * B @ A # lora_scale = (alpha / rank)
# W' = W + lora_scale * B @ A
# Where: B = up_proj (out_features, rank) # Where: B = up_proj (out_features, rank)
# A = down_proj (rank, in_features) # A = down_proj (rank, in_features)
if weights_dict["alpha"] is not None: if weights_dict["alpha"] is not None:
lora_alpha = weights_dict["alpha"] / lora_down.shape[0] lora_scale = weights_dict["alpha"] / lora_down.shape[0]
elif alpha is not None: elif alpha is not None:
lora_alpha = alpha / lora_down.shape[0] lora_scale = alpha / lora_down.shape[0]
else: else:
lora_alpha = 1.0 lora_scale = 1.0
``` ```
**Configuration Method**: **Configuration Method**:
...@@ -507,7 +522,7 @@ Since Wan2.2 uses a dual-model architecture (high-noise/low-noise), LoRA needs t ...@@ -507,7 +522,7 @@ Since Wan2.2 uses a dual-model architecture (high-noise/low-noise), LoRA needs t
|------|------|--------| |------|------|--------|
| `path` | LoRA model file path | Required | | `path` | LoRA model file path | Required |
| `strength` | LoRA strength coefficient, range [0.0, 1.0] | 1.0 | | `strength` | LoRA strength coefficient, range [0.0, 1.0] | 1.0 |
| `alpha` | LoRA scaling factor, uses model's built-in value when `null`, defaults to 1 if no built-in value | null | | `alpha` | LoRA scaling factor, uses model's built-in value when `null` | null |
| `name` | (Wan2.2 only) Specifies which model to apply to | Required | | `name` | (Wan2.2 only) Specifies which model to apply to | Required |
**Advantages**: **Advantages**:
......
...@@ -179,7 +179,16 @@ huggingface-cli download lightx2v/Wan2.1-Distill-Models \ ...@@ -179,7 +179,16 @@ huggingface-cli download lightx2v/Wan2.1-Distill-Models \
--include "wan2.1_i2v_720p_lightx2v_4step.safetensors" --include "wan2.1_i2v_720p_lightx2v_4step.safetensors"
``` ```
**步骤 2:配置启动脚本** **步骤 2:手动组织其他模块**
目录结构如下
```
wan2.1_i2v_720p/
├── wan2.1_i2v_720p_lightx2v_4step.safetensors # 原始精度
└── t5/clip/vae/config.json/xlm-roberta-large/google等其他组件 # 需要手动组织
```
**步骤 3:配置启动脚本**
```bash ```bash
# 在启动脚本中设置(指向包含模型文件的目录) # 在启动脚本中设置(指向包含模型文件的目录)
...@@ -219,7 +228,9 @@ huggingface-cli download lightx2v/Wan2.1-Distill-Models \ ...@@ -219,7 +228,9 @@ huggingface-cli download lightx2v/Wan2.1-Distill-Models \
--include "wan2.1_i2v_720p_int8_lightx2v_4step.safetensors" --include "wan2.1_i2v_720p_int8_lightx2v_4step.safetensors"
``` ```
**目录结构** **步骤 2:手动组织其他模块**
目录结构如下:
``` ```
wan2.1_i2v_720p_multi/ wan2.1_i2v_720p_multi/
...@@ -229,7 +240,7 @@ wan2.1_i2v_720p_multi/ ...@@ -229,7 +240,7 @@ wan2.1_i2v_720p_multi/
└── t5/clip/vae/config.json/xlm-roberta-large/google等其他组件 # 需要手动组织 └── t5/clip/vae/config.json/xlm-roberta-large/google等其他组件 # 需要手动组织
``` ```
**步骤 2:在配置文件中指定模型** **步骤 3:在配置文件中指定模型**
编辑配置文件(如 `configs/distill/wan_i2v_distill_4step_cfg.json`): 编辑配置文件(如 `configs/distill/wan_i2v_distill_4step_cfg.json`):
...@@ -257,7 +268,7 @@ wan2.1_i2v_720p_multi/ ...@@ -257,7 +268,7 @@ wan2.1_i2v_720p_multi/
> - **dit_original_ckpt**:用于指定原始精度模型(BF16/FP32/FP16)的路径 > - **dit_original_ckpt**:用于指定原始精度模型(BF16/FP32/FP16)的路径
> - **dit_quantized_ckpt**:用于指定量化模型(FP8/INT8)的路径,需配合 `dit_quantized` 和 `dit_quant_scheme` 参数使用 > - **dit_quantized_ckpt**:用于指定量化模型(FP8/INT8)的路径,需配合 `dit_quantized` 和 `dit_quant_scheme` 参数使用
**步骤 3:启动推理** **步骤 4:启动推理**
```bash ```bash
cd LightX2V/scripts cd LightX2V/scripts
...@@ -336,9 +347,10 @@ wan2.2_models_multi/ ...@@ -336,9 +347,10 @@ wan2.2_models_multi/
│ ├── wan2.2_i2v_A14b_high_noise_fp8_e4m3_lightx2v_4step.safetensors # FP8 量化 │ ├── wan2.2_i2v_A14b_high_noise_fp8_e4m3_lightx2v_4step.safetensors # FP8 量化
│ └── wan2.2_i2v_A14b_high_noise_int8_lightx2v_4step.safetensors # INT8 量化 │ └── wan2.2_i2v_A14b_high_noise_int8_lightx2v_4step.safetensors # INT8 量化
└── low_noise_model/ └── low_noise_model/
├── wan2.2_i2v_A14b_low_noise_lightx2v_4step.safetensors # 原始精度 │ ├── wan2.2_i2v_A14b_low_noise_lightx2v_4step.safetensors # 原始精度
├── wan2.2_i2v_A14b_low_noise_fp8_e4m3_lightx2v_4step.safetensors # FP8 量化 │ ├── wan2.2_i2v_A14b_low_noise_fp8_e4m3_lightx2v_4step.safetensors # FP8 量化
└── wan2.2_i2v_A14b_low_noise_int8_lightx2v_4step.safetensors # INT8 量化 │ └── wan2.2_i2v_A14b_low_noise_int8_lightx2v_4step.safetensors # INT8 量化
└── t5/vae/config.json/xlm-roberta-large/google等其他组件 # 需要手动组织
``` ```
**配置文件设置** **配置文件设置**
...@@ -450,16 +462,17 @@ LoRA(Low-Rank Adaptation)模型提供了一种轻量级的模型微调方案 ...@@ -450,16 +462,17 @@ LoRA(Low-Rank Adaptation)模型提供了一种轻量级的模型微调方案
```python ```python
# LoRA 权重应用公式 # LoRA 权重应用公式
# W' = W + (alpha/rank) * B @ A # lora_scale = (alpha / rank)
# W' = W + lora_scale * B @ A
# 其中:B = up_proj (out_features, rank) # 其中:B = up_proj (out_features, rank)
# A = down_proj (rank, in_features) # A = down_proj (rank, in_features)
if weights_dict["alpha"] is not None: if weights_dict["alpha"] is not None:
lora_alpha = weights_dict["alpha"] / lora_down.shape[0] lora_scale = weights_dict["alpha"] / lora_down.shape[0]
elif alpha is not None: elif alpha is not None:
lora_alpha = alpha / lora_down.shape[0] lora_scale = alpha / lora_down.shape[0]
else: else:
lora_alpha = 1.0 lora_scale = 1.0
``` ```
**配置方法** **配置方法**
...@@ -507,7 +520,7 @@ else: ...@@ -507,7 +520,7 @@ else:
|------|------|--------| |------|------|--------|
| `path` | LoRA 模型文件路径 | 必填 | | `path` | LoRA 模型文件路径 | 必填 |
| `strength` | LoRA 强度系数,范围 [0.0, 1.0] | 1.0 | | `strength` | LoRA 强度系数,范围 [0.0, 1.0] | 1.0 |
| `alpha` | LoRA 缩放因子,`null` 时使用模型内置值,如果没有内置值默认1 | null | | `alpha` | LoRA 缩放因子,`null` 时使用模型内置值 | null |
| `name` | (仅 Wan2.2)指定应用到哪个模型 | 必填 | | `name` | (仅 Wan2.2)指定应用到哪个模型 | 必填 |
**优点** **优点**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment