[GH-ISSUE #57] How to use the output of DeepEP as the input of DeepGemm #35

Open
opened 2026-10-26 21:10:58 +00:00 by bsakaguchi · 4 comments
Owner

Originally created by @hpz4311 on GitHub (Mar 11, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepGEMM/issues/57

  1. Suppose the number of experts on device 0 is 4, and the number of tokens assigned to each expert is 1, 2, 3, and 7, respectively.
    I think that after DeepEP, the activations received by expert 0 are (13, 7168).

2.In this case, calling m_grouped_gemm_fp8_fp8_bf16_nt_masked requires the activations to be arranged in the form of (4, 8, 7168), with masked_m=[1,2,3,7].

So, if we want to use the output of DeepEP as the input, do we need to manually rearrange the data from form 1 to form 2?
I have only run the DeepGemm demo and am not sure if I have misunderstood the output distribution of DeepEP .

Originally created by @hpz4311 on GitHub (Mar 11, 2025). Original GitHub issue: https://github.com/deepseek-ai/DeepGEMM/issues/57 1. Suppose the number of experts on device 0 is 4, and the number of tokens assigned to each expert is 1, 2, 3, and 7, respectively. I think that after DeepEP, the activations received by expert 0 are (13, 7168). 2.In this case, calling m_grouped_gemm_fp8_fp8_bf16_nt_masked requires the activations to be arranged in the form of (4, 8, 7168), with masked_m=[1,2,3,7]. So, if we want to use the output of DeepEP as the input, do we need to manually rearrange the data from form 1 to form 2? I have only run the DeepGemm demo and am not sure if I have misunderstood the output distribution of DeepEP .
Author
Owner

@LyricZhao commented on GitHub (Mar 13, 2025):

I think that after DeepEP, the activations received by expert 0 are (13, 7168).

Not exactly, it can be less than 13, as there can be some tokens selecting more than 1 expert.

So, if we want to use the output of DeepEP as the input, do we need to manually rearrange the data from form 1 to form 2?
I have only run the DeepGemm demo and am not sure if I have misunderstood the output distribution of DeepEP .

Yes, for outputs of the normal kernels of DeepEP, you have to compute a layout and expand the tokens into the format required by the contiguous kernel in DeepGEMM.

For low-latency kernels' output of DeepEP, it can be directly used by the masked kernel in DeepGEMM (but not useful for training, small batch inference only).

<!-- gh-comment-id:2720511666 --> @LyricZhao commented on GitHub (Mar 13, 2025): > I think that after DeepEP, the activations received by expert 0 are (13, 7168). Not exactly, it can be less than 13, as there can be some tokens selecting more than 1 expert. > So, if we want to use the output of DeepEP as the input, do we need to manually rearrange the data from form 1 to form 2? I have only run the DeepGemm demo and am not sure if I have misunderstood the output distribution of DeepEP . Yes, for outputs of the normal kernels of DeepEP, you have to compute a layout and expand the tokens into the format required by the contiguous kernel in DeepGEMM. For low-latency kernels' output of DeepEP, it can be directly used by the masked kernel in DeepGEMM (but not useful for training, small batch inference only).
Author
Owner

@LyricZhao commented on GitHub (Mar 13, 2025):

We plan to open-source the small layout-related kernels later (as an optional utility C library), maybe next month. cc @xuzhean

<!-- gh-comment-id:2720514270 --> @LyricZhao commented on GitHub (Mar 13, 2025): We plan to open-source the small layout-related kernels later (as an optional utility C library), maybe next month. cc @xuzhean
Author
Owner

@xutizhou commented on GitHub (Apr 19, 2025):

Hi @LyricZhao, do you have a timeline for open-sourcing the small layout-related kernels?

<!-- gh-comment-id:2816588881 --> @xutizhou commented on GitHub (Apr 19, 2025): Hi @LyricZhao, do you have a timeline for open-sourcing the small layout-related kernels?
Author
Owner

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

Sorry, we are still refactoring and optimizing the small and wgrad kernels (optimization took much more time as expected). Hard to tell a specific time, but at least before June.

<!-- gh-comment-id:2817455744 --> @LyricZhao commented on GitHub (Apr 21, 2025): Sorry, we are still refactoring and optimizing the small and wgrad kernels (optimization took much more time as expected). Hard to tell a specific time, but at least before June.
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/DeepGEMM#35
No description provided.