Fix CUTLASS Blackwell FMHA register spills on DRIVE Thor (sm_110a)#3308
Open
pzhao-eng wants to merge 1 commit into
Open
Fix CUTLASS Blackwell FMHA register spills on DRIVE Thor (sm_110a)#3308pzhao-eng wants to merge 1 commit into
pzhao-eng wants to merge 1 commit into
Conversation
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.
TL;DR
The CUTLASS Blackwell SM100 FMHA forward kernel spills ~529 MB of the softmax score tile to local memory on Thor (
sm_110a) because the per-warp register re-partitioning (setmaxnreg) is silently compiled out for__CUDA_ARCH__ == 1100. Adding the missing1100arch clause to CUTLASS'sCUDA_CTA_RECONFIG_ACTIVATEDgate re-enablessetmaxnreg, eliminates the spills, and makes the kernel 1.74× faster (1.33 ms → 762 µs) with no other changes.cutlass/include/cutlass/arch/reg_reconfig.h.Problem
I was working on profiling the CUTLASS FMHA forward kernel (example 77) on DRIVE Thor (

Sm100FmhaFwdKernelTmaWarpspecialized, fp16, B=1 H=16 D=64 S=2984, TileShape 256×128×64, built forsm_110a) showed the kernel writing ~535 MB to memory for a 6 MB output.Root cause
The kernel is warp-specialized: each warp group is meant to be granted a different physical register budget at runtime via the
setmaxnregPTX instruction (warpgroup_reg_set<NumRegsSoftmax=192>for the Softmax warps,<96>for Correction,<32>for the rest).setmaxnregis only emitted whenCUDA_CTA_RECONFIG_ACTIVATEDis defined, and its__CUDA_ARCH__whitelist inreg_reconfig.homits1100(Thor):On
sm_110a,warpgroup_reg_set<192>therefore expands to nothing (confirmed: zerosetmaxnregin the cubin). All 16 warps then share the single flat__launch_bounds__(512, 1)budget = 65,536 / 512 = 128 regs/thread. The Softmax warps need ~192 to hold the 128-element fp32 score row across the rowmax→exp2→rescale→fp16-convert pipeline; capped at 128 they spill the row to local memory — 7.75M times.Fix
Add the
1100clause to bothCUDA_CTA_RECONFIG_ACTIVATEDblocks, matching theexact pattern CUTLASS already uses for Thor elsewhere
(
grid_dependency_control.h,config.h):// cutlass/include/cutlass/arch/reg_reconfig.h || (__CUDA_ARCH__ == 1030 && defined(__CUDA_ARCH_FEAT_SM103_ALL)) \ + || (__CUDA_ARCH__ == 1100 && defined(__CUDA_ARCH_FEAT_SM110_ALL)) \ || (__CUDA_ARCH__ == 1200 && defined(__CUDA_ARCH_FEAT_SM120_ALL)) \ ... || (__CUDA_ARCH__ == 1030 && CUDA_ARCH_FAMILY(1030)) \ + || (__CUDA_ARCH__ == 1100 && CUDA_ARCH_FAMILY(1100)) \ || (__CUDA_ARCH__ == 1200 && CUDA_ARCH_FAMILY(1200)) \Results