[GH-ISSUE #129] Why do we reduce topk weights for each token? #113

Closed
opened 2026-10-26 09:54:31 +00:00 by bsakaguchi · 4 comments
Owner

Originally created by @dearsxx0918 on GitHub (Apr 21, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepEP/issues/129

Hi,
I'm quite confused by the source code here.
github.com/deepseek-ai/DeepEP@a84a24808f/csrc/kernels/intranode.cu (L772)
github.com/deepseek-ai/DeepEP@a84a24808f/csrc/kernels/internode.cu (L1261)

These implementations indicate that we have reduced TOPK weights. But as far as I know, we only need to reduce the weight of the combined tokens, so for each token, we only need to reduce it to one instead of TOPK.

Can you help he on this?

Best regards,
-Edda

Originally created by @dearsxx0918 on GitHub (Apr 21, 2025). Original GitHub issue: https://github.com/deepseek-ai/DeepEP/issues/129 Hi, I'm quite confused by the source code here. https://github.com/deepseek-ai/DeepEP/blob/a84a24808fb0ea732f49b874cc456a69dde69076/csrc/kernels/intranode.cu#L772 https://github.com/deepseek-ai/DeepEP/blob/a84a24808fb0ea732f49b874cc456a69dde69076/csrc/kernels/internode.cu#L1261 These implementations indicate that we have reduced TOPK weights. But as far as I know, we only need to reduce the weight of the combined tokens, so for each token, we only need to reduce it to one instead of TOPK. Can you help he on this? Best regards, -Edda
Author
Owner

@LyricZhao commented on GitHub (Apr 22, 2025):

This is for dispatch backward, the gradient needs to be reduced.

<!-- gh-comment-id:2819941225 --> @LyricZhao commented on GitHub (Apr 22, 2025): This is for dispatch **backward**, the gradient needs to be reduced.
Author
Owner

@dearsxx0918 commented on GitHub (Apr 22, 2025):

Thanks for your quick reply. I mean why we need reduce weights? Seems we can get this from topk_weights directly ?
And if we need reduce weights, we reduce all topk_weights into one ?

<!-- gh-comment-id:2820977516 --> @dearsxx0918 commented on GitHub (Apr 22, 2025): Thanks for your quick reply. I mean why we need reduce weights? Seems we can get this from topk_weights directly ? And if we need reduce weights, we reduce all topk_weights into one ?
Author
Owner

@LyricZhao commented on GitHub (Apr 23, 2025):

Oh, you are right. It seems that we only need to copy the weights needed, instead of copying 👍🏻

Will add this as a TODO later.

<!-- gh-comment-id:2822826573 --> @LyricZhao commented on GitHub (Apr 23, 2025): Oh, you are right. It seems that we only need to copy the weights needed, instead of copying 👍🏻 Will add this as a TODO later.
Author
Owner

@dearsxx0918 commented on GitHub (Apr 23, 2025):

Thanks for you reply!

<!-- gh-comment-id:2822888467 --> @dearsxx0918 commented on GitHub (Apr 23, 2025): Thanks for you reply!
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepEP#113
No description provided.