readme.md 2.91 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 模型转换工具

A powerful utility for converting model weights between different formats and performing quantization tasks.

## Diffusers
Facilitates mutual conversion between diffusers architecture and lightx2v architecture

### Lightx2v->Diffusers
```bash
python converter.py \
       --source /Path/To/Wan-AI/Wan2.1-I2V-14B-480P \
       --output /Path/To/Wan2.1-I2V-14B-480P-Diffusers \
       --direction forward
```

### Diffusers->Lightx2v
```bash
python converter.py \
       --source /Path/To/Wan-AI/Wan2.1-I2V-14B-480P-Diffusers \
       --output /Path/To/Wan2.1-I2V-14B-480P \
       --direction backward
```


## Quantization
This tool supports converting fp32/fp16/bf16 model weights to INT8、FP8 type.


### Wan DIT

```bash
python converter.py \
    --quantized \
    --source /Path/To/Wan-AI/Wan2.1-I2V-14B-480P/ \
    --output /Path/To/output \
gushiqiao's avatar
Fix  
gushiqiao committed
36
    --output_ext .safetensors \
37
38
39
40
41
42
43
44
45
46
    --output_name wan_int8 \
    --dtype torch.int8 \
    --model_type wan_dit
```

```bash
python converter.py \
    --quantized \
    --source /Path/To/Wan-AI/Wan2.1-I2V-14B-480P/ \
    --output /Path/To/output \
gushiqiao's avatar
Fix  
gushiqiao committed
47
    --output_ext .safetensors \
48
    --output_name wan_fp8 \
gushiqiao's avatar
fix.  
gushiqiao committed
49
    --dtype torch.float8_e4m3fn \
50
51
52
53
54
55
56
57
58
59
    --model_type wan_dit
```

### Hunyuan DIT

```bash
python converter.py \
    --quantized \
    --source /Path/To/hunyuan/lightx2v_format/i2v/ \
    --output /Path/To/output \
gushiqiao's avatar
Fix  
gushiqiao committed
60
    --output_ext .safetensors \
61
62
63
64
65
66
67
68
69
70
    --output_name hunyuan_int8 \
    --dtype torch.int8 \
    --model_type hunyuan_dit
```

```bash
python converter.py \
    --quantized \
    --source /Path/To/hunyuan/lightx2v_format/i2v/ \
    --output /Path/To/output \
gushiqiao's avatar
Fix  
gushiqiao committed
71
    --output_ext .safetensors \
72
    --output_name hunyuan_fp8 \
gushiqiao's avatar
fix.  
gushiqiao committed
73
    --dtype torch.float8_e4m3fn \
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
    --model_type hunyuan_dit
```


### Wan T5EncoderModel

```bash
python converter.py \
    --quantized \
    --source /Path/To/Wan-AI/Wan2.1-I2V-14B-480P/models_t5_umt5-xxl-enc-bf16.pth \
    --output /Path/To/output \
    --output_ext .pth\
    --output_name models_t5_umt5-xxl-enc-int8 \
    --dtype torch.int8 \
    --model_type wan_t5
```

```bash
python converter.py \
    --quantized \
    --source /Path/To/Wan-AI/Wan2.1-I2V-14B-480P/models_t5_umt5-xxl-enc-bf16.pth \
    --output /Path/To/output \
    --output_ext .pth\
    --output_name models_t5_umt5-xxl-enc-fp8 \
    --dtype torch.float8_e4m3fn \
    --model_type wan_t5
```


### Wan CLIPModel

```bash
python converter.py \
  --source /Path/To/Wan-AI/Wan2.1-I2V-14B-480P/models_clip_open-clip-xlm-roberta-large-vit-huge-14.pth \
  --quantized \
  --output /Path/To/output \
  --output_ext .pth \
111
  --output_name clip_int8 \
112
113
114
115
116
117
118
119
120
121
  --dtype torch.int8 \
  --model_type wan_clip

```
```bash
python converter.py \
  --source /Path/To/Wan-AI/Wan2.1-I2V-14B-480P/models_clip_open-clip-xlm-roberta-large-vit-huge-14.pth \
  --quantized \
  --output /Path/To/output \
  --output_ext .pth \
122
  --output_name clip_fp8 \
123
124
125
  --dtype torch.float8_e4m3fn \
  --model_type wan_clip
```