Repository navigation
Deterministic MoE Router Kernel By Removing Global Atomic Ops - #3587
zhongbozhu wants to merge 2 commits into
Conversation
[High impact] The PR appears safe to merge; no actionable issues were found. SummaryAdds an optional fixed-order reduction for MoE auxiliary loss while preserving the existing atomic path by default.
No actionable issues were found. CUDA tests were not run. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["fused_moe_aux_loss"] --> B{"deterministic?"}
B -->|No| C["Existing atomic reduction"]
B -->|Yes| D["Get workspace"]
D --> E["Each block writes one partial sum"]
E --> F["Sum partials in a fixed order"]
C --> G["Loss and saved coefficient"]
F --> G
G --> H["Existing backward kernel"]
Reviews (3) · Last reviewed commit: "Align deterministic MoE aux-loss workspa..." · Reviewed by Greptile |
| * | ||
| * \return Maximum required workspace size in bytes. | ||
| */ | ||
| size_t nvte_get_moe_aux_loss_workspace_size(); |
There was a problem hiding this comment.
The way we handle the workspace in the other APIs is similar to CUB - we run the APIs with the nullptr arguments for the workspace once (which populates the other fields), then run it again with the proper workspace. Please align this API to that.
ecdbe5d to
17c35fa
Compare
|
Thanks a lot @zhongbozhu. The kernel is deterministic on one GPU. For multi-node runs, does determinism also hold with multi-node job, do we need the same placement and a fixed NCCL algorithm? Good to put it in the docs if there's anything worth noting. |
Signed-off-by: Zhongbo Zhu <zhongboz@nvidia.com> Signed-off-by: zhongboz <zhongboz@nvidia.com>
Query workspace shape and dtype through the deterministic forward APIs, retain stream and CUDA Graph isolation, and cover metadata queries and invalid scratch buffers. Fix the stream cache-key lint warning and upstream import ordering. Validated on GB200: 201 TE tests passed (12 invalid top-k cases skipped), 6 C API tests passed, and 40 MCore checks passed with 1 expected atomic negative-control XPASS. Full PyTorch QA lint, pre-commit, and license checks passed. Signed-off-by: zhongboz <zhongboz@nvidia.com>
17c35fa to
07887f8
Compare
|
/te-ci pytorch |
Description
Please include a brief summary of the changes, relevant motivation and context.
Fixes NVIDIA/Megatron-LM#7221
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: