Loading...
Loading...
HCCL (Huawei Collective Communication Library) performance testing for Ascend NPU clusters. Use for testing distributed communication bandwidth, verifying HCCL functionality, and benchmarking collective operations like AllReduce, AllGather. Covers MPI installation, multi-node pre-flight checks (SSH/CANN version/NPU health), and production testing workflows.
npx skill4agent add ascend/agent-skills hccl-test${INSTALL_DIR}/tools/hccl_test| 产品系列 | 最大 Rank 数 | 备注 |
|---|---|---|
| Atlas 训练系列产品 | 4096 | - |
| Atlas A2 训练系列产品 | 32K | - |
| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | 32K | AlltoAll/AlltoAllV 最大 8K |
| Atlas 300I Duo 推理卡 | - | - |
| 算子 | 可执行文件 | 通信模式 | 适用场景 | 推荐度 |
|---|---|---|---|---|
| AllReduce | | 多对多 | 梯度聚合、参数同步 | ⭐⭐⭐ 必测 |
| AllGather | | 多对多 | 数据聚合、参数收集 | ⭐⭐⭐ 必测 |
| Broadcast | | 一对多 | 配置分发、初始化 | ⭐⭐ 可选 |
| AlltoAll | | 多对多 | 数据重排、负载均衡 | ⭐⭐ 可选 |
提示: 完整算子列表见 references/parameters.md
# 1. 前置检查(多机测试必需)
./scripts/pre-test-check.sh 175.99.1.2 175.99.1.3
# 2. 编译工具
cd ${INSTALL_DIR}/tools/hccl_test
make MPI_HOME=/usr/local/mpich ASCEND_DIR=${INSTALL_DIR}
# 3. 快速连通性测试(单机)
mpirun -n 8 ./bin/all_reduce_test -p 8 -b 8K -e 64M -f 2 -d fp32 -o sum
# 4. 完整性能测试(多机,推荐)
mpirun -f hostfile -n 16 ./bin/all_reduce_test -p 8 -b 8K -e 1G -f 2 -d fp32 -o sum⚠️ 重要: 多机测试前必须完成以下检查,否则可能出现建链超时或测试失败。
# 1. 生成 SSH 密钥(如已存在可跳过)
ssh-keygen -t rsa
# 2. 将公钥复制到所有节点(包括本机)
ssh-copy-id -i ~/.ssh/id_rsa.pub root@<node1_ip>
ssh-copy-id -i ~/.ssh/id_rsa.pub root@<node2_ip>
# 3. 验证免密登录
ssh root@<node1_ip> "echo 'SSH OK'"
ssh root@<node2_ip> "echo 'SSH OK'"# 检查所有节点的 CANN 版本
for node in 175.99.1.2 175.99.1.3; do
echo "=== $node ==="
ssh root@$node "cat /usr/local/Ascend/ascend-toolkit/latest/version.cfg | grep runtime_running_version"
done注意: 版本不一致时需统一版本(建议统一为最新 RC 版本)。
# 检查所有节点的 NPU 健康状态
for node in 175.99.1.2 175.99.1.3; do
echo "=== $node NPU Health ==="
ssh root@$node "npu-smi info -t health -i 0"
done| 状态 | 说明 | 操作建议 |
|---|---|---|
| OK | 正常 | ✅ 可以使用 |
| Alarm | 告警 | ⚠️ 需排查故障 |
| Offline | 离线 | ❌ 不可使用 |
如存在 Alarm 状态,需排除故障卡。例如 NPU 0 故障,使用 7 张卡测试。
# 使用提供的检查脚本(推荐)
./scripts/pre-test-check.sh 175.99.1.2 175.99.1.3| 产品系列 | 推荐版本 |
|---|---|
| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | MPICH 4.1.3 |
| Atlas A2 训练系列产品 | MPICH 3.2.1 |
| Atlas 训练系列产品 | MPICH 3.2.1 |
| Atlas 300I Duo 推理卡 | MPICH 3.2.1 |
# 1. 解压
tar -zxvf mpich-${version}.tar.gz
cd mpich-${version}
# 2. 配置编译选项
# Atlas A3 产品(必须使用 TCP 协议)
./configure --disable-fortran --prefix=/usr/local/mpich --with-device=ch3:nemesis
# 其他产品
./configure --disable-fortran --prefix=/usr/local/mpich
# 3. 编译安装
make -j 32 && make installtar -zxvf openmpi-4.1.5.tar.gz
cd openmpi-4.1.5
./configure --disable-fortran --enable-ipv6 --prefix=/usr/local/openmpi
make -j 32 && make install# MPICH 环境
export INSTALL_DIR=/usr/local/Ascend/ascend-toolkit/latest
export PATH=/usr/local/mpich/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/mpich/lib:${INSTALL_DIR}/lib64:$LD_LIBRARY_PATHcd ${INSTALL_DIR}/tools/hccl_test
# MPICH
make MPI_HOME=/usr/local/mpich ASCEND_DIR=${INSTALL_DIR}
# Open MPI
make MPI_HOME=/usr/local/openmpi ASCEND_DIR=${INSTALL_DIR}bin# 单机快速测试
mpirun -n 8 ./bin/all_reduce_test -p 8 -b 8K -e 64M -f 2 -d fp32 -o sum
# 多机快速测试
mpirun -f hostfile -n 16 ./bin/all_reduce_test -p 8 -b 8K -e 64M -f 2 -d fp32 -o sum# 单机完整性能测试
mpirun -n 8 ./bin/all_reduce_test -p 8 -b 8K -e 1G -f 2 -d fp32 -o sum
# 多机完整性能测试(推荐)
mpirun -f hostfile -n 16 ./bin/all_reduce_test -p 8 -b 8K -e 1G -f 2 -d fp32 -o sum-b 8K-e 1G-f 2# 使用 quick-verify.sh 测试核心算子(推荐)
./scripts/quick-verify.sh 8
# 手动测试核心算子
./bin/all_reduce_test -p 8 -b 8K -e 1G -f 2 -d fp32 -o sum
./bin/all_gather_test -p 8 -b 8K -e 1G -f 2 -d fp32节点IP:卡数# 单机测试
175.99.1.3:8
# 双机测试
175.99.1.3:8
175.99.1.4:8请将属于同一超节点的 AI Server 信息配置在一起,不支持交叉配置。
| 参数 | 说明 | 示例 |
|---|---|---|
| 单节点参与训练的 NPU 个数 | |
| 测试数据量起始值 | |
| 测试数据量结束值 | |
| 乘法因子 | |
| 数据类型: fp32/fp16/int32 | |
| 操作类型: sum/prod/max/min | |
| 迭代次数(默认 20) | |
| 是否开启结果校验(默认 1) | |
详细参数说明见 references/parameters.md
# 固定数据量测试
-b 100M -e 100M
# 乘法因子测试(测试 100M, 200M, 400M)
-b 100M -e 400M -f 2
# 完整性能测试(推荐)
-b 8K -e 1G -f 2data_size avg_time(us) alg_bandwidth(GB/s) check_result
8192 125.3 0.065 success
16384 132.1 0.124 success
...| 字段 | 说明 |
|---|---|
| 单个 NPU 上参与集合通信的数据量(Bytes) |
| 集合通信算子执行耗时(us) |
| 算法带宽(GB/s),计算方式:集合通信数据量/耗时 |
| 结果校验标识:success/failed/NULL |
# 解析结果文件
./scripts/parse-hccl-result.py output.log
# 输出 Markdown 表格
./scripts/parse-hccl-result.py output.log -f markdown| 算子 | 结果 | 备注 |
|---|---|---|
| AllReduce | ✅ PASS | 最高带宽 48.59 GB/s (32MB) |
| AllGather | ✅ PASS | - |
| AllGatherV | ❌ FAIL | retcode: 5(变长参数问题) |
| AlltoAll | ✅ PASS | - |
| AlltoAllV | ✅ PASS | - |
| Broadcast | ✅ PASS | - |
| Reduce | ✅ PASS | - |
| ReduceScatter | ✅ PASS | - |
| ReduceScatterV | ❌ FAIL | retcode: 5(变长参数问题) |
| Scatter | ✅ PASS | - |
| 问题 | 原因 | 解决方法 |
|---|---|---|
| SSH 免密登录失败 | 未配置 SSH 密钥 | 执行 ssh-copy-id 配置免密登录 |
| CANN 版本不一致 | 多机 CANN 版本不同 | 统一所有节点的 CANN 版本 |
| NPU Alarm 状态 | NPU 硬件故障 | 检查 npu-smi info -t health,排除故障卡 |
| 问题 | 原因 | 解决方法 |
|---|---|---|
| gethostbyname failed | 主机名无法解析 | 配置 /etc/hosts |
| retcode: 7 | 残余进程干扰 | 执行清理命令: |
| retcode: 5 | 变长参数配置错误 | AllGatherV/ReduceScatterV 需要特殊参数配置 |
~/ascend/log/debug/plog详细故障排除见 references/common-issues.md
# 多机测试前置检查
./scripts/pre-test-check.sh 175.99.1.2 175.99.1.3# 测试核心算子
./scripts/quick-verify.sh 8
# 完整性能测试
./scripts/quick-verify.sh 8 full# 一键多机测试(自动前置检查 + 测试)
./scripts/multi-node-test.sh --nodes 175.99.1.2,175.99.1.3 --npus 8 --mode full