在 Ascend 910B × 8 卡上,对比 torch_npu FSDP2(czr_pta/pytorch 的 torch_npu.distributed.fsdp)与 hyper_parallel Torch 后端 fully_shard 的训练性能。
czr_pta/pytorch
torch_npu.distributed.fsdp
fully_shard
自研 benchmark 仓库(本地):bench_qwen35_35b_fsdp2/ 模型:Qwen3.5-35B-A3B 形状(简化实现,非官方完整模型),可调层数。 并行:1D FSDP,mesh=8,batch_size=1,HYPER_PARALLEL_PLATFORM=torch。
bench_qwen35_35b_fsdp2/
mesh=8
batch_size=1
HYPER_PARALLEL_PLATFORM=torch
forward=1
backward=1
Profiler(step3,prefetch 未显式开启)通信掩盖率:
根因:hyper 侧 HCCL 调用过碎(rank0 约 124 AG + 57 RS vs torch 12 AG + 7 RS),layer prefetch 未配置时几乎无 overlap。
Profiler 路径:results/profiler_20260625_143330/
results/profiler_20260625_143330/
开启 prefetch 后两边基本持平,hyper 略快。
结果:results/interleaved_20260625_152124/
results/interleaved_20260625_152124/
3 轮汇总(step 中位数): torch 1929 ms vs hyper 1770 ms(hyper 快 ~8.3%)
Profiler step3(8 卡均值,prefetch=1):
结果:results/interleaved_8k_8L_prof_20260625_163102/
results/interleaved_8k_8L_prof_20260625_163102/
all_gather_inputs
comm_fusion=True
prefetch depth=2
source /home/czr/env.sh cd bench_qwen35_35b_fsdp2 # 16K / 4L,prefetch=1,交错 3 轮 bash run_interleaved.sh # 8K / 8L,prefetch=1,profiler,交错 3 轮 SEQ_LEN=8192 NUM_LAYERS=8 ENABLE_PROFILER=1 bash run_interleaved.sh
Benchmark 脚本:bench_torch_npu.py、bench_hyper_parallel.py、common.py(setup_layer_prefetch)
bench_torch_npu.py
bench_hyper_parallel.py
common.py
setup_layer_prefetch
comm_fusion=False
背景
在 Ascend 910B × 8 卡上,对比 torch_npu FSDP2(
czr_pta/pytorch的torch_npu.distributed.fsdp)与 hyper_parallel Torch 后端fully_shard的训练性能。自研 benchmark 仓库(本地):
bench_qwen35_35b_fsdp2/模型:Qwen3.5-35B-A3B 形状(简化实现,非官方完整模型),可调层数。
并行:1D FSDP,
mesh=8,batch_size=1,HYPER_PARALLEL_PLATFORM=torch。实验配置摘要
forward=1/backward=1(decoder layer 链式预取)实验一:seq=16K,4 层(prefetch 前,带 profiler)
Profiler(step3,prefetch 未显式开启)通信掩盖率:
根因:hyper 侧 HCCL 调用过碎(rank0 约 124 AG + 57 RS vs torch 12 AG + 7 RS),layer prefetch 未配置时几乎无 overlap。
Profiler 路径:
results/profiler_20260625_143330/实验二:seq=16K,4 层,prefetch=1(交错 3 轮)
开启 prefetch 后两边基本持平,hyper 略快。
结果:
results/interleaved_20260625_152124/实验三:seq=8K,8 层,prefetch=1 + profiler(交错 3 轮)
3 轮汇总(step 中位数): torch 1929 ms vs hyper 1770 ms(hyper 快 ~8.3%)
Profiler step3(8 卡均值,prefetch=1):
结果:
results/interleaved_8k_8L_prof_20260625_163102/Profiler 差异点(实验三)
hyper 更快
hyper 更慢 / 待优化
all_gather_inputsvs torch module 级 bucket)torch 优势
结论
建议优化方向
comm_fusion=True、prefetch depth=2、HSDP 2×4 mesh复现
source /home/czr/env.sh cd bench_qwen35_35b_fsdp2 # 16K / 4L,prefetch=1,交错 3 轮 bash run_interleaved.sh # 8K / 8L,prefetch=1,profiler,交错 3 轮 SEQ_LEN=8192 NUM_LAYERS=8 ENABLE_PROFILER=1 bash run_interleaved.shBenchmark 脚本:
bench_torch_npu.py、bench_hyper_parallel.py、common.py(setup_layer_prefetch)环境
comm_fusion=False(默认)