Repository navigation
Conversation
sm100_tf32_hc_prenorm_gemm_impl allocated tensor memory but addressed its cast A stages and accumulator from column 0, and freed columns 0 to kNumTmemCols - 1. The allocator returns a non-zero base when CTAs of another kernel on the same SM, for example one on another stream, already hold tensor memory. The kernel then overwrote that kernel's columns and freed columns it did not own (deepseek-ai#479). Offset every tensor memory address by the base the allocator wrote, as sm100_mega_mhc already does. Signed-off-by: zhaoye <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #479.
sm100_tf32_hc_prenorm_gemm_implallocates 256 tensor memory columns, but it addresses its cast A stages and its accumulator from column 0 and frees them withfree(0, kNumTmemCols). The allocator can return a non-zero base when another CTA on the same SM already holds tensor memory. This kernel uses at most about 200 KB of shared memory, so a small CTA of another kernel, for example one on another stream, can run next to it. The GEMM then writes into that CTA's columns, andtcgen05.deallocon columns it does not own hits the tcgen05 guardrail trap.This change reads the base that the allocator wrote after
__syncthreads()and adds it to every tensor memory address and tofree, assm100_mega_mhcalready does.Validation on B200 (CUDA 13.1). A test kernel is launched first on one stream with one CTA per SM (148 CTAs). Each CTA allocates 32 or 256 columns (all at base 0), fills them with a pattern and holds them until the GEMM on a second stream has finished, then checks them. In every concurrent run that completed, the GEMM finished while all 148 CTAs were still resident.
main(5081f85)freefixed (diagnostic)unspecified launch failureunspecified launch failurecalc_diffis NaN)Under cuda-gdb,
mainstops insm100_tf32_hc_prenorm_gemm_impl<24u, 7168u, 64u, 32u, 64u, 16u, 128u, 12u, 128u, 128u>with the error from the issue:tests/test_hyperconnection.pypasses with and without this change. Kernel times are unchanged within noise: across the 24 shapes of that test, median per-kernel times differ by -8% to +6% in both directions (geometric mean 0.996). Another process shared the GPU during timing, so these numbers are not exact. The SASS of the two configs I compared has 24 and 32 fewer instructions, with the same or one fewer register.The other SM100 kernels that free from column 0 (
sm100_bf16_gemm,sm100_fp8_fp4_gemm_1d1d,sm100_bmk_bnk_mn,sm100_sparse_mqa_logits,sm100_mqa_logits,sm100_bf16_mega_gate, and the two Mega MoE kernels) are not changed here. I can extend this PR if you want them handled the same way. The test kernel and script are about 340 lines; I can share them if that helps.🤖 Generated with Claude Code