模拟器用于指定工作负载、以及自定义网络拓扑进行训练仿真,得出训练过程中的训练耗时以及通信耗时等相关情况。使得大模型在部署前可以进行无GPU设备的参数调优。
涉及术语说明:
asw = 接入交换机, LEAF
psw = Pod交换机, SPINE
nv_switch = GPUserver内一个nvlink转发芯片, 一台GPU Server只有一个nv_switch
获取
# Clone the repository
$ git clone https://github.com/aliyun/SimAI.git
$ cd ./SimAI/
# Clone submodules
$ git submodule update --init --recursive
# Make sure use the newest commit
$ git submodule update --remote
# Compile SimAI-Analytical
$ ./scripts/build.sh -c analytical
# Compile SimAI-Simulation (ns3)
$ ./scripts/build.sh -c ns3
使用网络仿真
生成拓扑
# Create network topo
python3 ./astra-sim-alibabacloud/inputs/topo/gen_HPN_7.0_topo_mulgpus_one_link.py -g 128 -gt A100 -bw 100Gbps -nvbw 2400Gbps
这里是阿里提供的一个脚本生成拓扑,其中参数说明
128个GPU
A100的GPU类型
服务器网卡到接入交换机带宽 100Gbps
NVLINK带宽 2400Gbps (A100的带宽2400Gbps, H20为3600Gbps)
默认接入家换机到POD交换机带宽400Gbps
默认POD交换机psw 120台
默认接入交换机asw 64台
拓扑说明
这是生成的拓扑文件内容截取如下
272 8 16 128 736 A100
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
0 128 2400Gbps 0.000025ms 0
0 144 100Gbps 0.0005ms 0
1 128 2400Gbps 0.000025ms 0
1 145 100Gbps 0.0005ms 0
2 128 2400Gbps 0.000025ms 0
2 146 100Gbps 0.0005ms 0
...
144 152 400Gbps 0.0005ms 0
144 153 400Gbps 0.0005ms 0
144 154 400Gbps 0.0005ms 0
第一行
节点数:272(128 GPU + 16 nvswitch + 8 接入交换机 + 120 骨干交换机 )
单服务器节点数 8
nv_switch数量 :16
总交换机数量: 128 (8接入,120骨干)
总link数量: 736 , 60* 8 (psw - asw) + 16 * 8 (server - asw) + 16 * 8 (gpu - nv_switch)
第二行 144个交换节点,8 asw, 120 psw, 16 nv_switch
128~143 为nv_switch
144~151 为asw
152~211 为psw1
212~271 为psw2
第三行开始,描述所有link的带宽和时延
0 128 2400Gbps 0.000025ms 0 GPU与Nv_switch的带宽,和GPU与asw的带宽,asw与psw带宽
0 144 100Gbps 0.0005ms 0 GPU 0 与 nv_swith_128 之间的带宽时延
144 152 400Gbps 0.0005ms 0 asw_144 与 psw_152 之间的带宽时延
每一个asw连接60个psw
运行仿真
# Running
$ AS_SEND_LAT=3 AS_NVLS_ENABLE=1 ./bin/SimAI_simulator -t 16 -w ./example/microAllReduce.txt -n ./HPN_7_0_128_gpus_8_in_one_server_with_single_plane_100Gbps_A100 -c astra-sim-alibabacloud/inputs/config/SimAI.conf
工作负载
cat ./example/microAllReduce.txt
HYBRID_TRANSFORMER_FWD_IN_BCKWD model_parallel_NPU_group: 8 ep: 1 pp: 1 vpp: 8 ga: 1 all_gpus: 8 checkpoints: 0 checkpoint_initiates: 0
2
embedding_layer -1 556000 ALLREDUCE 16777216 1 NONE 0 1 NONE 0 1
embedding_layer -1 556000 ALLREDUCE 67108864 1 NONE 0 1 NONE 0 1
这是一个简单的工作负载示例,只有ALLREDUCE操作。
真是的模型负载,可以通过AICB工具生成,或者手动修改。
输出结果
文件 ncclFlowModel_EndToEnd.csv
layer_name | test1 | fwd compute | wg compute | ig compute | fwd exposed comm |
---|---|---|---|---|---|
embedding_layer | test1 | 556 | 0.001 | 0.001 | 141.464 |
embedding_layer | test1 | 556 | 0.001 | 0.001 | 434.556 |
SUM | test1 | 1112 | 0.002 | 0.002 | 576.02 |
total exposed comm | 576.026 | total comp | 1112.004 | total time | 1688.03 |
这里有前向计算时间,工作计算时间,输入计算时间,前向通信之间等等。
最终显示出相应的计算时间和传输时间。
文件 ncclFlowModel_test1_dimension_utilization_0.csv
time (us) | dim1 util | dim2 util |
---|---|---|
10 | 0 | 0 |
530 | 0 | 0 |
540 | 0 | 0 |
550 | 0 | 0 |
560 | 40 | 0 |
570 | 100 | 0 |
580 | 100 | 0 |
590 | 100 | 0 |
600 | 100 | 0 |
610 | 100 | 0 |
620 | 100 | 0 |
630 | 100 | 0 |
640 | 100 | 0 |
时间和dim1、 dim2的利用率表,这里把dim util当做GPU利用率来理解。
文件ncclFlowModel_detailed_144.csv
此文件暂时为空,可能需要复杂的工作负载才会形成它,对于模型训练细节输出。