You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Both layouts of Grouped GEMMs need to be aligned to the GEMM M block size ? #15
The m_grouped_gemm_fp8_fp8_bf16_nt_contiguous function documentation says that
"On the M axis, inputs are grouped into several batches, of which batch sizes aligned to get_m_alignment_for_contiguous_layout() (128).",
which means the M of each group must be multiples of 128?
I don't see such declaration on the m_grouped_gemm_fp8_fp8_bf16_nt_masked, but I test several M (8, 16, 64) that don't meet the requirement on test/test_core.py by test_m_grouped_gemm_masked and found they can't pass the correctness validation, so does the masked layout grouped gemm also has the limitation implicitly?
which means the M of each group must be multiples of 128?
Yes.
but I test several M (8, 16, 64) that don't meet the requirement on test/test_core.py by test_m_grouped_gemm_masked and found they can't pass the correctness validation, so does the masked layout grouped gemm also has the limitation implicitly
No limitation for the masked kernel, could you please share you modified test script?
The reason is wrong TMA store block size when shape_m is smaller than BLOCK_M. So currently we restrict shape_m <= BLOCK_M or shape_m % BLOCK_M == 0 if for masked GEMM with more than one group.
Are these limitations necessary to achieve good performance?can we remove them to support any m ? for example, by passing extra params that can indicate batch size or data address of each group, like exclusive_sum.
Not necessary, they are TMA limitations. If we are using 2D [num_groups * m, k] TMA store, I guess there's no way to bypass the limitation (one group may overwrite to the next group).
A possible solution is to use 3D TMA [num_groups, m, k], but I don't think adding such support for some rare cases is good.
Activity
LyricZhao commentedon Feb 27, 2025
Yes.
No limitation for the masked kernel, could you please share you modified test script?
CtfGo commentedon Feb 27, 2025
@LyricZhao Hi, thank you for your reply and appreciate your awesome work.
I just modify the two lines on
test/test_core.py test_m_grouped_gemm_maskedto test othernum_groupsandm, the detail diff is:then run
python test/test_core.py, and will see AssertionError of the diff check:test machine environment: Nvidia H800、cuda 12.4、torch 2.6.0+cu124
LyricZhao commentedon Feb 27, 2025
Fixed in main, commit: ca13ce0 and 6da94d2
The reason is wrong TMA store block size when
shape_mis smaller thanBLOCK_M. So currently we restrictshape_m <= BLOCK_M or shape_m % BLOCK_M == 0if for masked GEMM with more than one group.Thanks for feedback!
CtfGo commentedon Feb 28, 2025
It looks well now.
Are these limitations necessary to achieve good performance?can we remove them to support any
m? for example, by passing extra params that can indicate batch size or data address of each group, like exclusive_sum.LyricZhao commentedon Feb 28, 2025
Not necessary, they are TMA limitations. If we are using 2D
[num_groups * m, k]TMA store, I guess there's no way to bypass the limitation (one group may overwrite to the next group).A possible solution is to use 3D TMA
[num_groups, m, k], but I don't think adding such support for some rare cases is good.CtfGo commentedon Mar 1, 2025
Got it, thanks for your explanation.
Add DEEPGEMM Masked API.
Add DEEPGEMM Masked API. (#3949)
Merge pull request deepseek-ai#15 from cleonard530/migrate_pybind_to_…
Migrate DeepGEMM off pybind11 onto TORCH_LIBRARY (deepseek-ai#15)