parallel.md 1.14 KB
Newer Older
xuwx1's avatar
xuwx1 committed
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# 并行推理

LightX2V 支持分布式并行推理,能够利用多个 GPU 进行推理。DiT部分支持两种并行注意力机制:**Ulysses****Ring**,同时还支持 **Cfg 并行推理**。并行推理,显著降低推理耗时和减轻每个GPU的显存开销。

## DiT 并行配置

### 1. Ulysses 并行

**配置方式:**
```json
    "parallel": {
        "seq_p_size": 4,
        "seq_p_attn_type": "ulysses"
    }
```

### 2. Ring 并行


**配置方式:**
```json
    "parallel": {
        "seq_p_size": 4,
        "seq_p_attn_type": "ring"
    }
```

## Cfg 并行配置

**配置方式:**
```json
    "parallel": {
        "cfg_p_size": 2
    }
```

## 混合并行配置

**配置方式:**
```json
    "parallel": {
        "seq_p_size": 4,
        "seq_p_attn_type": "ulysses",
        "cfg_p_size": 2
    }
```


## 使用方式

并行推理的config文件在[这里](https://github.com/ModelTC/lightx2v/tree/main/configs/dist_infer)

通过指定--config_json到具体的config文件,即可以测试并行推理

[这里](https://github.com/ModelTC/lightx2v/tree/main/scripts/dist_infer)有一些运行脚本供使用。