mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #346] [CLOSED] fix: use dynamic shared memory in smxx_paged_mqa_logits_metadata to support large batch sizes #380
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#380
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/346
Author: @Oxygen56
Created: 5/31/2026
Status: ❌ Closed
Base:
main← Head:fix/issue-322📝 Commits (2)
36abc9cFix Mega MoE kernel shared memory calculation errorb4ab2b6fix: use dynamic shared memory in smxx_paged_mqa_logits_metadata to support large batch sizes📊 Changes
3 files changed (+11 additions, -9 deletions)
View changed files
📝
csrc/jit_kernels/impls/smxx_fp8_paged_mqa_logits.hpp(+2 -2)📝
deep_gemm/include/deep_gemm/impls/sm100_fp8_fp4_mega_moe.cuh(+1 -1)📝
deep_gemm/include/deep_gemm/scheduler/paged_mqa_logits.cuh(+8 -6)📄 Description
Summary
Fixes #322. The
smxx_paged_mqa_logits_metadatakernel used static__shared__arrays sized bykAlignedBatchSize, which caused shared memory overflow at batch sizes >= 4096. The three arrays (varlen_atom_token_start,varlen_atom_context_len,prefix_sum) consumed3 * kAlignedBatchSize * 4bytes, exceeding the 48KB limit.Changes
deep_gemm/include/deep_gemm/scheduler/paged_mqa_logits.cuh: Replaced three static__shared__arrays with anextern __shared__pool, using pointer arithmetic to partition it. Updatedvarlen_num_atoms_sharedaccesses to use pointer dereferencing.csrc/jit_kernels/impls/smxx_fp8_paged_mqa_logits.hpp: Fixed thesmem_sizecalculation fromaligned_batch_size * sizeof(int)to(3 * aligned_batch_size + 1) * sizeof(int)to match the actual allocation (the FP4 version already had the correct calculation).Background
The dynamic shared memory approach works because the
construct_launch_configfunction in the JIT runtime already callscudaFuncSetAttribute(..., cudaFuncAttributeMaxDynamicSharedMemorySize, smem_size), which raises the per-block shared memory limit beyond the default 48KB to support the requested allocation (up to the GPU's capacity of ~227KB).Tested with the reproducer from the issue at batch_size=8192.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.