mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #226] [MERGED] fix: prevent int32 overflow in k-grouped GEMM size calculations #298
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#298
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/226
Author: @SolenoidWGT
Created: 11/4/2025
Status: ✅ Merged
Merged: 11/19/2025
Merged by: @LyricZhao
Base:
main← Head:fix/fix_sum_k_overflow📝 Commits (1)
62a3122fix: prevent int32 overflow in k-grouped GEMM size calculations📊 Changes
1 file changed (+6 additions, -6 deletions)
View changed files
📝
csrc/apis/gemm.hpp(+6 -6)📄 Description
Fix Int32 Overflow: Prevent overflow in k-grouped GEMM size validation
Description
Fix integer overflow in k-grouped GEMM when validating tensor sizes with large dimensions.
While training the Deepseek-v3 model using DeepGemm on an H100 machine, we encountered an error in the group GEMM kernel when using long sequences (
>256\text{k}). Upon investigation, we found the cause was an overflow during the calculation of the product of sum_k and hidden_size.Root cause: When
mornare large and multiplied withsum_k, the result exceeds int32 max value (2,147,483,647), causing incorrect validation or undefined behavior.Solution: Cast
mandntouint64_tbefore multiplication to safely handle large matrix dimensions.Changes
csrc/apis/gemm.hpp:289-290: Cast touint64_tin size assertions🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.