Skip to content

refactor: scatter-gather-autograd-refactor#164

Open
kilinchange wants to merge 2 commits into
masterfrom
refactor/scatter-gather-autograd-refactor
Open

refactor: scatter-gather-autograd-refactor#164
kilinchange wants to merge 2 commits into
masterfrom
refactor/scatter-gather-autograd-refactor

Conversation

@kilinchange
Copy link
Copy Markdown
Collaborator

@kilinchange kilinchange commented Jun 3, 2026

#153 前置 pr,主要内容:

  1. 添加 scatter 算子;
  2. 使用命名空间区分 scatter/gather 与同名通信算子;
  3. 重新组织 misc 文件内的函数。

@kilinchange kilinchange force-pushed the refactor/scatter-gather-autograd-refactor branch from a91cb12 to 1135a56 Compare June 3, 2026 02:01
@kilinchange kilinchange changed the title feat: add scatter operator, distinguish tensor and communication APIs… refactor: scatter-gather-autograd-refactor Jun 3, 2026
… via namespaces, and reorganize functions in misc files
@kilinchange kilinchange force-pushed the refactor/scatter-gather-autograd-refactor branch from 1135a56 to d85350f Compare June 3, 2026 07:11
@kilinchange
Copy link
Copy Markdown
Collaborator Author

精度测试:
image
性能测试:
image
ctest 测试:
image

Copy link
Copy Markdown
Contributor

@Chamberlain0w0 Chamberlain0w0 left a comment

Choose a reason for hiding this comment

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

LGTM,仅有一个 check 的部分没和其他部分逻辑对齐

const int64_t topk = values->Dims().back();
const int64_t num_experts = output_dims.back();
CHECK_GT(num_experts, 0);
const int64_t rows = values->NumElements() / topk;
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.

对比 CPU 版实现,缺少 CHECK_EQ(output_numel, static_cast<size_t>(rows * num_experts)); 的校验,否则 kernel 中 output[row * num_experts + expert_idx] = values[idx]; 可能越界写

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

Co-authored-by: Copilot <copilot@github.com>
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.

2 participants