mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #460] [Fix] Bound cuBLASLt descriptor lifetime on errors #464
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#464
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/460
Author: @ZenAlexa
Created: 9/28/2026
Status: 🔄 Open
Base:
main← Head:contrib/cublaslt-stack-descriptors📝 Commits (5)
0677683[Fix] Bound cuBLASLt descriptor lifetime on errors7d53ec4[Perf] Drop redundant cuBLASLt scalar type updatead60716Merge public release 26/09/3099a3343Merge upstream main into cuBLASLt descriptor fixd8081b2Merge current main📊 Changes
1 file changed (+46 additions, -54 deletions)
View changed files
📝
csrc/jit_kernels/impls/smxx_cublaslt.hpp(+46 -54)📄 Description
Summary
Replaced the five cuBLASLt descriptor allocations in the shared GEMM path with caller-owned opaque descriptors initialized through the native
*InitAPIs. The layouts live in the calling scope, and the operation descriptor and preference live through heuristic selection and matmul enqueue.The current
Createsequence leaves its correspondingDestroycalls at the end of the function. A heuristic or matmul error throws through the existing error macros and exits before those calls. Stack-owned descriptors give the success and exception paths the same bounded lifetime.The native matmul initializer also sets the scalar type, so the shared path now omits the duplicate
SCALE_TYPEattribute call. The algorithm selection, per-stream workspace, matrix attributes, scaling pointers, and public interfaces retain their existing behavior. NVIDIA TransformerEngine uses the same native descriptor ownership pattern in its grouped GEMM implementation.Reproduction
A public
cublaslt_gemm_ntcall with two CUDA FP64[16, 16]inputs and an FP32[16, 16]output reaches heuristic selection and returnsCUBLAS_STATUS_NOT_SUPPORTED. Repeating this rejected call retains the allocated descriptors on the current default branch.Measured glibc
mallinfo2().uordblksin separate baseline and candidate processes after 128 warmup rejections. Each checkpoint runs garbage collection andmalloc_trim(0); inputs remain allocated throughout. The baseline is78b69000794d0937b47ae3387eff7663410264d1.The unsupported-dtype candidate measurement was repeated at
7d53ec4; the invalid-output-shape control was measured at0677683. The baseline grows by approximately 592 bytes per cuBLASLt rejection. The candidate at7d53ec4has a stable native allocation total from 1,000 through 20,000 rejected calls. Both versions preserve the rejection and complete a subsequent valid BF16 GEMM with zero maximum absolute error. Atad60716, a fresh candidate process again retained a constant native allocation total from 1,000 through 20,000 rejected calls (147,976,064 bytes), followed by a valid BF16 GEMM with zero maximum absolute error.Validation
Native validation at
ad60716on October 8 included main057ca596. That diff retains the release's output dtype, alpha scaling, and accumulation handling. A fresh native build passed all six existing test functions with their complete internal shape matrices and original tolerances (6 passed, 1,523.68 seconds):These exercise matrix orientations, padded and strided layouts, BF16 and FP32 outputs, alpha scaling, and accumulation. At
ad60716, a separate two-stream check uses distinct BF16 inputs and FP32 accumulators with non-aliased outputs. It validates finite reference-matching results after 64 interleaved eager rounds and after 64 CUDA graph replays; both stages pass withcalc_diffbelow1.2e-13on each stream.At
0677683, four paired baseline and candidate workloads passed numerical checks in eager execution and CUDA graph replay: padded-weightbhr,hdr->bhdatB=4, H=128, R=512, D=128, batched SYRK and SYMM atbatch=16, M=576, K=5120, and an FP32-output BF16 GEMM atM=4, N=64, K=7168. The measurements use the library's default heuristic cache. Host-call wall times varied across rounds.Hardware: H200 (driver reports NVIDIA L20X), PyTorch-reported compute capability 9.0, driver
570.172.08. The separate driver capability query reports 8.9. PyTorch2.12.0.dev20260408+cu128, CUDA toolkit12.9.86, loaded cuBLASLt12.8.4(cublasLtGetVersion() == 120804). The baseline andad60716native extensions both built successfully. The shared NVFP4 cuBLASLt wrapper compiled with the extension.A separate same-process host probe compared descriptor initialization with the repeated scalar-type setter and with the initializer alone. Sixteen alternating rounds of 100,000 initializations gave median thread CPU times of 60.25 ns and 47.45 ns for FAST_TF32, and 60.50 ns and 47.29 ns for FP32. Public descriptor attributes matched for both compute types and all four transpose combinations. These numbers measure host descriptor initialization.
Both native builds use the same
CPPFLAGS='-include cuda_fp8.h'setting for the header dependency reported in #439. This PR leaves that separate fix with its existing author.The timing comparison isolates host descriptor initialization; complete API and model-level performance remain unmeasured. SM100 received compile coverage for the shared wrapper; its runtime behavior requires additional hardware.
Current integration
Merged
5081f8513af5through a normal merge atd8081b2876e1on October 23. The descriptor implementation is unchanged. Source review covered all six wrappers, epilogue dispatch, stream-owned workspaces and exception exits; the contribution diff check passed. The native numerical, two-stream/graph, failure-recovery and descriptor-cost results above retain their recorded revisions and hardware coverage.Current CUDA compilation and SM90/SM100 execution remain unrun. Please run the descriptor failure/recovery cases in the project runtime lanes, including the shared NVFP4 wrapper on SM100.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.