mindspore-ai / mindspore-ai/hyper-parallel

[Benchmark] torch_npu FSDP2 vs hyper_parallel Torch fully_shard(Qwen3.5 形状,8×910B)

Open
#241 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
53
Forks
63
Avg merge
23h 45m
Merged PRs (30d)
63

Description

背景

在 Ascend 910B × 8 卡上,对比 torch_npu FSDP2czr_pta/pytorchtorch_npu.distributed.fsdp)与 hyper_parallel Torch 后端 fully_shard 的训练性能。

自研 benchmark 仓库(本地):bench_qwen35_35b_fsdp2/
模型:Qwen3.5-35B-A3B 形状(简化实现,非官方完整模型),可调层数。
并行:1D FSDP,mesh=8batch_size=1HYPER_PARALLEL_PLATFORM=torch


实验配置摘要

说明
硬件 8 × Ascend 910B
对比基线 torch_npu FSDP2 vs hyper_parallel fully_shard
prefetch 显式 forward=1 / backward=1(decoder layer 链式预取)
计时 warmup=2,measure=20,NPU sync 分阶段计时
交错实验 每轮 torch → hyper,共 3 轮,减少温度/频率漂移

实验一:seq=16K,4 层(prefetch 前,带 profiler)

指标 torch_npu hyper_parallel
step 中位数 1841 ms 1948 ms
forward 465 ms 465 ms
backward 1378 ms 1464 ms

Profiler(step3,prefetch 未显式开启)通信掩盖率:

  • torch_npu:48.8%(8 卡均值)
  • hyper_parallel:5.9%(7 卡)

根因: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 轮)

指标 torch_npu hyper_parallel hyper/torch
step 中位数(3 轮均值) 1830.7 ms 1782.8 ms 0.974x
forward 中位数 456.8 ms 421.5 ms 0.921x
backward 中位数 1372.1 ms 1360.7 ms 0.992x

开启 prefetch 后两边基本持平,hyper 略快。

结果:results/interleaved_20260625_152124/


实验三:seq=8K,8 层,prefetch=1 + profiler(交错 3 轮)

Round torch step hyper step hyper/torch
1 2026 ms 1770 ms 0.874x
2 1929 ms 1768 ms 0.917x
3 1911 ms 1784 ms 0.933x

3 轮汇总(step 中位数): torch 1929 ms vs hyper 1770 mshyper 快 ~8.3%

阶段 torch hyper Δ
forward 中位数 493 ms 422 ms -71 ms
backward 中位数 1436 ms 1350 ms -86 ms

Profiler step3(8 卡均值,prefetch=1):

指标 torch_npu hyper_parallel
通信掩盖率 57.6% 44.2%
暴露通信 603 ms 816 ms
纯计算 1579 ms 1450 ms
allGather 次数 (rank0) 20 244
reduceScatter 次数 (rank0) 11 111

结果:results/interleaved_8k_8L_prof_20260625_163102/


Profiler 差异点(实验三)

hyper 更快
  • Slice -64 ms、ConcatD -24 ms、Cast -14 ms(rank0 单步)
  • 总 kernel 时间 hyper 1473 ms vs torch 1606 ms(-133 ms)
hyper 更慢 / 待优化
  • HCCL 调用 10–12× 更碎(参数级 all_gather_inputs vs torch module 级 bucket)
  • 通信掩盖率仍低于 torch(44% vs 58%),暴露通信多 ~213 ms
  • BARRIER / Launch_Ffts 次数显著更多(365 vs 59)
  • RealDiv 调用 173 vs 73 次
torch 优势
  • FSDP2 module 级通信聚合,HCCL 次数少
  • backward prefetch 成熟,掩盖率更高

结论

  1. 未开 layer prefetch 时,hyper Torch 后端通信几乎串行暴露(掩盖 ~6%),step 慢于 torch_npu。
  2. 显式 prefetch=1 后,16K/4L 基本持平,8K/8L hyper 快 ~8%
  3. 主要性能差距来自 HCCL 调度粒度:hyper 参数级 AG/RS vs torch module 级融合。
  4. hyper 在算子路径(Slice/Cast/Concat)上有优势,部分抵消通信暴露劣势。

建议优化方向

  1. P0:参数级 AG/RS 向 module-bucket 合并,减少 HCCL launch 与 BARRIER
  2. P1:降低多余 DeviceSync / Launch_Ffts
  3. P2:评估 comm_fusion=Trueprefetch 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.sh

Benchmark 脚本:bench_torch_npu.pybench_hyper_parallel.pycommon.pysetup_layer_prefetch


环境

  • CANN 9.1.0,torch + torch_npu(czr_pta patch)
  • hyper_parallel Torch 后端,comm_fusion=False(默认)

schema_version: 1
source: gitcode
gitcode_repo: mindspore/hyper-parallel
gitcode_issue: 250
source_url: https://gitcode.com/mindspore/hyper-parallel/issues/250

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading bench_torch_npu.py, bench_hyper_parallel.py, and common.py, especially setup_layer_prefetch, then reproduce the 16K/4L and 8K/8L runs with run_interleaved.sh. Use the listed profiler results to compare HCCL call counts, communication masking, and kernel time. Done would require a clearly scoped optimization and benchmark evidence showing its effect on the reported communication and step-time gaps.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.