Skip to content

Add kernel‘s config cache and improve TMA alignment - #47

Closed
DXHPC wants to merge 3 commits into
deepseek-ai:mainfrom
DXHPC:dev_config_cache
Closed

DXHPC wants to merge 3 commits into
deepseek-ai:mainfrom
DXHPC:dev_config_cache

Conversation

@DXHPC

@DXHPC DXHPC commented Mar 7, 2025 •

Copy link
Copy Markdown

When testing the function deep_gemm.gemm_fp8_fp8_bf16_nt, we observed that for certain examples, especially matrices with small shapes, the overhead outside of the GEMM kernel's execution was non-negligible. By using PyTorch's profiler, we found that the execution of the functions get_col_major_tma_aligned_tensor and get_best_configs introduces significant overhead.
截屏2025-03-07 11 53 19

We tried to perform memory alignment in advance by calling the function get_col_major_tma_aligned_tensor before invoking the function deep_gemm.gemm_fp8_fp8_bf16_nt. But we still noticed that the alignment-related operations were triggered during the execution of deep_gemm.gemm_fp8_fp8_bf16_nt. Additionally, the function get_best_configs redundantly executes for the same inputs, yielding the same results, which introduces unnecessary overhead.
First, we fixed the improper handling of 2D matrices in function get_col_major_tma_aligned_tensor. Additionally, we added a cache to obtain the optimal configuration before the GEMM kernel launches, which reduces overhead for inputs of the same size.

@soundOfDestiny

Copy link
Copy Markdown
Contributor

Thanks!

the overhead outside of the GEMM kernel's execution was non-negligible

Indeed. get_col_major_tma_aligned_tensor is for demo use and can be fused into one CUDA kernel when we want to achieve the best performance.

@LyricZhao LyricZhao closed this Mar 10, 2025
@kzjeef

kzjeef commented Mar 14, 2025

Copy link
Copy Markdown

nice job! @DXHPC

LyricZhao added a commit that referenced this pull request Apr 16, 2026
* Add BF16 GEMM draft

* Add tests

* Add BF16 GEMM APIs

* Minor fix

* Minor fix

* Minor fix

* Minor fix

* Support BF16 configs

* Fix all bugs

* Fix all bugs

* Add more test cases
qiushixiaoyu pushed a commit to qiushixiaoyu/DeepGEMM that referenced this pull request Jun 22, 2026
qiushixiaoyu pushed a commit to qiushixiaoyu/DeepGEMM that referenced this pull request Jun 30, 2026
qiushixiaoyu pushed a commit to qiushixiaoyu/DeepGEMM that referenced this pull request Sep 4, 2026
lucifer1004 pushed a commit to lucifer1004/DeepGEMM that referenced this pull request Oct 30, 2026
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.

4 participants