mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #350] Add shape-aware recommended alignment for SM90 small-M grouped GEMM #383
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#383
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?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/DeepGEMM/pull/350
Author: @qescccczmr
Created: 6/2/2026
Status: 🔄 Open
Base:
main← Head:sm90-small-m-alignment📝 Commits (2)
146cd35Add recommended alignment for SM90 small-M grouped GEMM2ed7b01Add SM90 small-K grouped GEMM alignment benchmark📊 Changes
6 files changed (+288 additions, -0 deletions)
View changed files
📝
README.md(+1 -0)📝
csrc/apis/layout.hpp(+10 -0)📝
csrc/jit_kernels/heuristics/runtime.hpp(+12 -0)📝
deep_gemm/utils/layout.py(+1 -0)➕
tests/test_sm90_small_m_alignment.py(+80 -0)➕
tools/bench_sm90_small_m_m_grouped.py(+184 -0)📄 Description
Summary
This PR adds a shape-aware recommended M/K alignment helper for contiguous grouped layouts.
The existing
get_theoretical_mk_alignment_for_contiguous_layout()keeps SM90 on the legacy 128 alignment. For SM90 m-grouped contiguous GEMM, this can introduce extrapadded rows for some small-M non-psum shapes.
This PR adds an opt-in recommendation helper that returns 64 only for the empirically validated shape family:
num_groups == 4expected_m == 128expected_k <= 256All other shapes fall back to the existing theoretical alignment.
This does not change the default alignment.
Motivation
Grouped contiguous layout requires each expert segment to be aligned by
get_mk_alignment_for_contiguous_layout(). In the target small-M case, using 128 alignment padsthe generated test shape from
M=640toM=768.Reducing the recommended alignment to 64 for the validated shape reduces padded rows while preserving correctness.
Broader scans showed regressions for other shapes such as
expected_m=64,expected_m=192,num_groups=8/16, andk>=512, so this helper intentionally keeps the 64recommendation restricted.
Changes
get_recommended_mk_alignment_for_contiguous_layout(use_psum_layout, expected_m, expected_k, expected_num_groups).expected_m=64falls backk=512falls backnum_groups=8falls backBenchmark
Hardware:
Command: