mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[GH-ISSUE #191] The current strategy in get_best_config is suboptimal in some cases on H20 #111
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepGEMM#111
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Sulfur6 on GitHub (Sep 11, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepGEMM/issues/191
1. Problem Description
When we deployed the decoder node on H20 with EP16/BS32, we found in the profile that DeepGEMM.v2 had a certain performance loss compared to v1. The following screenshot is from Deepseek_v2 MoE layer UP&GATE GEMM.
v2:

v1:

We are also doing some work on computation/communication overlap on H20, as shown in https://github.com/sgl-project/sglang/pull/9660. We implement overlap without splitting the batch, which requires the computation kernel and the communication kernel to share the SMs. We found that in the v2 version, the gap between the GEMM kernels w/ and w/o overlap has increased significantly compared to the v1 version. By observing the profile information, we speculate that this is due to the introduction of a larger block_n size (192) in the v2 version on sm90. Therefore, we introduced a new parameter
max_block_nin https://github.com/deepseek-ai/DeepGEMM/pull/183 to limit the size of block_n. We conducted some experiments and the results showed that by settingmax_block_nto 160, we can restore the performance to the v1 version. The overall test results are shown below:The above test results show that when using H20 for Deepseek_v2 in a BS32/EP16 deployment, UP&GATE GEMM performance suffers compared to v1, while DOWN GEMM performance improves. However, for overlapped workloads (which require sharing at least 3 SMs for communication on the H20; refer to https://github.com/deepseek-ai/DeepEP/pull/390 for the specific implementation), there's also a certain performance loss on the DOWN GEMM side.
Also, based on performance comparisons with v1, we believe the current DeepGEMM get_best_config logic may not be optimal. This logic can be simply summarized as minimizing the total number of waves required for computation while maximizing the block count in the last wave. Assuming the total computation time is
T, the total number of waves isn_w, and the computation time of a single wave ist_w, we can derive the following formula:T = n_w * t_w
Based on the above test results, we can roughly calculate the following table:
num_groupsexpected_mnkblock_mblock_nblock_kvalid_smsm_usagenum_waves254.050.80112258.051.60113126.015.75118148.016.4493236.033.71123264.033.00107136.013.60113142.014.20108Based on our conjecture, we believe that the core reason for the suboptimal performance is that compressing the number of waves will prolong the calculation time of a single wave, and the total calculation time is determined by both. Therefore, optimizing only one of them is likely to lead to a suboptimal final result.
2. Reproduction
You can reproduce our results on SGLang using the branch and startup parameters in https://github.com/sgl-project/sglang/pull/9660. You can also use the test code in https://github.com/Sulfur6/DeepGEMM/tree/sbo.v2.test to see the performance of GEMM in isolation.
3. Environment