[Profiler] Skip cuBLAS verification when C and D element types differ - #3613
Open
LiRunGuo wants to merge 1 commit into
Open
[Profiler] Skip cuBLAS verification when C and D element types differ#3613LiRunGuo wants to merge 1 commit into
LiRunGuo wants to merge 1 commit into
Conversation
The cuBLAS verification path allocates a single "Reference" buffer with the D element type and passes that buffer to cuBLAS as both the C and the D operand, while cublasLtGemmExDispatcher builds both matrix descriptors with the C element type. This is only sound when the kernel's C and D element types match. For the SM90 kernels that write narrow FP8 output from an FP32 C, cuBLASLt ends up walking an FP8-sized buffer as if it held FP32 elements, faults with an illegal memory access, and the resulting sticky CUDA error aborts the whole profiling session. The abort surfaced later as a misleading "Failed to allocate workspace" exception thrown by the next workspace allocation. Report those problems as not supported instead of running cuBLAS on them, and include the requested size plus the CUDA error name/string in the workspace allocation failure message so a poisoned context is no longer reported as a workspace sizing problem. Verified on an H200 (sm90a, CUDA 12.8, 8x H200 host): - Single kernel, before: abort (exit 134, "Failed to allocate workspace") - Single kernel, after : Success/Passed, cuBLAS: Not run - Full SM90 GEMM sweep, before: 434/604 problems then SIGABRT - Full SM90 GEMM sweep, after : 604/604 problems, exit 0 (602 passed, 2 not verified) at 4096x4096x4096; all previously completed problems report identical results, and 170 previously unreachable kernels are now profiled Signed-off-by: Gawr Gura 0721 <LiRunGuo@users.noreply.github.com>
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.
Motivation
cutlass_profileraborts the entire profiling session (SIGABRT, exit code 134) as soon as it profiles an SM90 GEMM that writes narrow FP8 output from an FP32C:Because the profiler is usually run over the whole kernel set, this kills the run at the first such kernel and all already-collected results are lost (the final report is never printed).
Root cause. In
GemmOperationProfiler::verify_with_cublas_, theReferenceworkspace is allocated withdesc.D.elementand the D layout, but that single buffer is handed to cuBLAS as both theCand theDoperand, whilecublasLtGemmExDispatcherbuildsCdescandDdescwithdata_type_C:When the kernel's
CandDelement types differ (FP32C+ FP8D), cuBLASLt walks the 1-byte-per-elementReferencebuffer as if it held 4-byte elements, faults with an illegal memory access, and leaves a stickycudaErrorIllegalAddress(700) in the context. The nextcudaMalloctherefore fails, so the abort surfaces as a completely misleading"Failed to allocate workspace"fromHandle::set_workspace_size, far away from the real fault. Confirmed with acudaMallocinterposer:The existing guard in
cublas_satisfies()only covered one FP8 operand ordering (A=E5M2, B=E4M3, C=F32, D!=F32,tools/profiler/src/cublas_helpers.cu:272). The symmetric ordering (A=E4M3, B=E5M2) and even the homogeneousE4M3 x E4M3 -> FP32 C -> E4M3 Dkernels are not covered and take the same crashing path.Modifications
tools/profiler/src/cublas_helpers.cu:cublas_satisfies()now returnskErrorNotSupportedwheneverdesc.C.element != desc.D.element. This is the exact precondition of the single-buffer/single-CTypeverification path, so those problems are reported as not verified instead of being sent to a cuBLAS call that cannot represent them.tools/library/src/handle.cu: the workspace allocation failure message now reports the requested size and the CUDA error name/string, so a poisoned context can no longer be mistaken for a workspace sizing problem.The guard affects 212 of the 604 SM90 GEMM kernels of the default instantiation level, all of which have a narrow FP8
Dand avoid/s8/f16/bf16/f32C. It cannot remove verification coverage anywhere else: no SM80/SM100 kernel in the library hasC.element != D.element, and every C!=D kernel that did complete before the fix reports exactly the same dispositions afterwards.Verification
H200 (sm90a), CUDA 12.8, driver 580, CUTLASS 4.8.0 (
147295a3),-DCUTLASS_NVCC_ARCHS=90a.Single kernel,
--m=4096 --n=4096 --k=4096(the kernel above):Aborted (core dumped))Passed(cuBLAS: not run, device reference: passed)Full SM90 dense GEMM sweep,
--kernels="cutlass3x_sm90_*" --profiling-iterations=1, 604 kernels:Per-kernel comparison for the 434 problems that completed before the abort: 0 differences in
Disposition,cuBLAS, andreference_deviceresults; 170 previously unreachable kernels are now profiled.Regression tests on the same host (all green, none of these paths are touched by the patch):
cutlass_test_unit_gemm_device_tensorop_sm9092/92,..._alignx_sm9077/77,..._epilogue_fusion_sm9065/65,..._gmma_rs_warpspecialized_sm9016/16,..._sm90_blockwise3/3,..._sm90_stream_k35/35 in 25 min. (..._sm90_group_gemmand..._sm90_ptr_arraycontain only SM100 test cases, so they register 0 tests when built for90a.)Notes
A complete fix would let the profiler verify these kernels by allocating separate, correctly typed
CandDbuffers (Ddescwould then need theDelement type and a type-aware comparison against the CUTLASS result). That is a larger change to the verification harness, so this PR takes the conservative route and reports the affected problems as not verified, mirroring howC=voidandC=s8kernels are already handled.