Skip to content

[Auto-Parallel] FSDP support for MoE - #78074

Merged
Xing-lil merged 14 commits into
PaddlePaddle:developfrom
Xing-lil:fsdp_moe
Mar 25, 2026
Merged

Xing-lil merged 14 commits into
PaddlePaddle:developfrom
Xing-lil:fsdp_moe

Conversation

@Xing-lil

@Xing-lil Xing-lil commented Feb 28, 2026 •

Copy link
Copy Markdown
Contributor

PR Category

Auto Parallel

PR Types

New features

Description

自动并行FSDP支持EP并行。
为支持MoE,从顺序的层级通信改为fsdp_unit_layers的层级通信。

TODO:目前仅支持EP组内FSDP不做额外切分,后续完善。

是否引起精度变化

否

@codecov-commenter

codecov-commenter commented Feb 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.38462% with 10 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@2b643d8). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...le/distributed/auto_parallel/fully_shard_fusion.py 90.19% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #78074   +/-   ##
==========================================
  Coverage           ?   90.38%           
==========================================
  Files              ?        2           
  Lines              ?      104           
  Branches           ?        0           
==========================================
  Hits               ?       94           
  Misses             ?       10           
  Partials           ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

hook_idx = None
for i, t in enumerate(tensors):
if not t.stop_gradient:
hook_idx = i

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里只对第一个 stop_gradient=False 的 Tensor 挂载了 Hook。是否可能出现 一恶搞Layer返回多个需要梯度的 Tensor、导致反向传播触发通信的逻辑不完整?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已做修改,完善反向hook接收dict输入的情况

grad.placements,
)
param.main_grad._local_value().copy_(grad._local_value())
param.main_grad._local_value().add_(grad._local_value())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为什么改成“add_”

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处修改欠缺考虑,已修改,保持“先通信后转换精度”

@liym27 liym27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

name = param.name
is_expert = getattr(param, "is_moe_param", False)
if is_expert:
continue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前EP组内FSDP不额外做切分,故先不创建这里的buffer,后续完善EP组内切分。

@Xing-lil
Xing-lil merged commit 6362a17 into PaddlePaddle:develop Mar 25, 2026
108 of 111 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants