[GH-ISSUE #93] Handling k-Dimension Divisibility in Backward Matrix Multiplication for kv_a_proj_with_mqa (din=7168, dout=576) #53

Closed
opened 2026-10-26 21:11:20 +00:00 by bsakaguchi · 3 comments
Owner

Originally created by @HIT-cwh on GitHub (May 6, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepGEMM/issues/93

In the attn part of dsv3, there is a linear module with a shape of din = 7168 and dout = 576. When calculating dx in the backward pass, the matrix multiplication involves shapes like (seq_len, 576) @ (576, 7168). However, DeepGEMM imposes a restriction on the k dimension, requiring it to be divisible by 128 (reference: DeepGEMM gemm.py#L192).

I’d like to ask whether padding is necessary for the matrix multiplication to meet this requirement.

Originally created by @HIT-cwh on GitHub (May 6, 2025). Original GitHub issue: https://github.com/deepseek-ai/DeepGEMM/issues/93 In the attn part of dsv3, there is a linear module with a shape of `din = 7168` and `dout = 576`. When calculating dx in the backward pass, the matrix multiplication involves shapes like `(seq_len, 576) @ (576, 7168)`. However, DeepGEMM imposes a restriction on the k dimension, requiring it to be divisible by 128 (reference: [DeepGEMM gemm.py#L192](https://github.com/deepseek-ai/DeepGEMM/blob/main/deep_gemm/jit_kernels/gemm.py#L192)). I’d like to ask whether padding is necessary for the matrix multiplication to meet this requirement.
Author
Owner

@LyricZhao commented on GitHub (May 7, 2025):

Our internal impl supports these shapes, will push later @zheanxu

<!-- gh-comment-id:2856921940 --> @LyricZhao commented on GitHub (May 7, 2025): Our internal impl supports these shapes, will push later @zheanxu
Author
Owner

@HIT-cwh commented on GitHub (May 7, 2025):

Thanks a lot!

<!-- gh-comment-id:2856945970 --> @HIT-cwh commented on GitHub (May 7, 2025): Thanks a lot!
Author
Owner

@LyricZhao commented on GitHub (May 14, 2025):

See #95, will merge it today.

<!-- gh-comment-id:2878848418 --> @LyricZhao commented on GitHub (May 14, 2025): See #95, will merge it today.
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#53
No description provided.