已合并
feat: kvallgather cp thd load balance #3820
feat: kvallgather cp thd load balance #3820
已合并
m0_50947149创建于 7月26日
m0_50947149
m0_50947149
7月26日

What this PR does / why we need it?

This PR adds load-balanced KVAllGather context parallelism for the THD format.

It uses EOD-aware symmetric sequence partitioning and implements a THD attention path with direct rank-major K/V indexing and a single TND fused-attention call. Metadata caching is added to reduce repeated calculations.

MHA, GQA, and expanded MLA are supported.

https://gitcode.com/Ascend/MindSpeed/issues/154
https://gitcode.com/Ascend/MindSpeed/issues/232

Does this PR introduce any user-facing change?

Yes. Users can now use THD packed sequences with kvallgather_cp_algo, causal attention, and EOD attention-mask reset without introducing new command-line options.

Each packed subsequence length must be divisible by 2 * context_parallel_size.

How was this patch tested?

Unit tests cover:

  • Load-balanced batch partitioning and metadata generation
  • Metadata cache reuse and invalidation
  • MHA, GQA, and MLA
  • FP16 and BF16
  • Distributed forward and backward consistency against a non-CP reference

The modified files also pass Ruff, Pylint, and whitespace checks.

Test_results:
kvallgather_cp1_cp2_comparison_loss.png

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 m0_50947149 的贡献)
m0_50947149m0_50947149
7月26日 创建了 pull request,commit 6531cceb
ascend-robotascend-robot成员
7月26日 添加了label:ascend-cla/no
ascend-robot
ascend-robot成员
7月26日 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-Ascend/MindSpeed Liz_, 郭鹏, wuweiqiang24 (3/2) 郭鹏 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

m0_50947149, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
ascend-robot
ascend-robot成员
7月26日 评论:

ascend docs pipeline is running...

likedislike
此处折叠了101条消息 查看更多
LLiz成员
11 天前 解决了最后一个问题
gp513成员
11 天前 评论:

/approve

likedislike
ascend-robotascend-robot成员
11 天前 添加了label:approved
ascend-robotascend-robot成员
11 天前 合入了pull request
ascend-robot
ascend-robot成员
11 天前 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike