Repository navigation
Fix ScaledBasis equality for mismatched bases, add SM120 sparse metadata K assert - #3427
Merged
hwu36 merged 1 commit intoAug 6, 2026
Merged
Conversation
…ata K assert cute::operator==(ScaledBasis, ScaledBasis) formed t.value() == u.value() even when the basis IDs differ, so comparing two ScaledBasis whose value types are not comparable failed to compile instead of returning false. Form the value comparison only when the bases match. That unblocks the SM120 block-scaled sparse 256x128x256 tile. Its metadata tensor is tiled into a rank-2 M mode, and coalescing that mode reaches the comparison with an int32_t value against a cute::R<1,16>. The same collective asserts that the metadata atom divides the tile along M but not along K, so an unsupported K tile is reported first as a tile_to_shape failure inside cute. Add the K assert and move both above the layout they constrain. Signed-off-by: David Kogan <[email protected]>
ccecka
approved these changes
Jul 31, 2026
hwu36
approved these changes
Aug 6, 2026
This was referenced Aug 14, 2026
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.
Summary
Issue #3393 reported two SM120 block-scaled sparse tile shapes that fail to
compile,
256x128x256and128x128x128, and asked whether the restriction isintended. They have different causes and this PR handles both.
256x128x256is not a restriction of the collective. It fails insidecute::operator==(ScaledBasis, ScaledBasis), which formst.value() == u.value()even when the basis IDs already differ. With the value comparison formed only
when the bases match, the tile compiles and produces correct results on sm_121a.
128x128x128is a real constraint. The metadata tensor is tiled withSmemLayoutAtomE, whose K extent is 256 for nvf4 operands, so a K tile of 128cannot be expressed. The collective asserts that the metadata atom divides the
tile along M and does not assert the same along K, so the first thing a user sees
is a
tile_to_shapefailure inside cute rather than a statement of theconstraint.
Files:
include/cute/numeric/arithmetic_tuple.hppinclude/cutlass/gemm/collective/sm120_blockscaled_sparse_mma_tma.hppMechanism, 256x128x256
CollectiveMma::load_inittiles the metadata TMA tensor with the CTA tile(
sm120_blockscaled_sparse_mma_tma.hpp, lines 703 and 724 on main):layout_ecomes fromSm1xxGemmSparseConfig::deduce_layoutE, which blocks themetadata by the atom,
((TensorEAtomM, M/TensorEAtomM), (TensorEAtomK, K/TensorEAtomK), L).TensorEAtomMis 128, so a CTA tile of 256 rows leaves the M mode rank 2 andcoalesce_xrunsbw_coalesceover the flattened(_128,_2,_256). Its mergetest is
which here compares a
ScaledBasis<int,1>against aScaledBasis<cute::R<1,16>,0>.The basis IDs differ, so the answer is false, but the current body still forms the
value comparison and
int32_t == cute::R<1,16>has no operator:The change forms the value comparison only when the basis IDs match and returns
false_typeotherwise, which is what the two neighbouringScaledBasisequalityoverloads in the same file already do for mismatched operands. The matching-basis
branch keeps the original expression verbatim, so its return type does not change.
Mechanism, 128x128x128
SmemLayoutEistile_to_shape(SmemLayoutAtomE{}, (TileShape_M, TileShape_K, StagesE), ...),so
tile_to_shaperequires the atom to divide the tile in both modes. Only the Mhalf was asserted.
TensorEAtom_MMA_F4isShape<_128,_256>, soTileShape_Kof128 fails the K half and is reported four layers down as
"tile_to_shape: block shape does not divide the target shape."The K assert is added next to the M one and both are moved above
SmemLayoutE, sothe named message is the first error. A failed
static_assertdoes not stopinstantiation, so the downstream layout errors still follow it.
Reproducer
One-line tile substitution in the in-tree example, compile only:
Testing done
Hardware: GB10 (DGX Spark), sm_121a. CUDA 13.1, driver 580.95.05. Tree: main @
f94ec46f.Four tile shapes through example 80b, compiled and run at 2048x2048x2048,
4096x4096x4096 and 8192x4096x4096:
tile_to_shapecutlass_test_unit_gemm_device_sm120_bssp_general, built for120a;121aand runon sm_121a: 7 of 7 pass.
The full
cutlass_test_unit_cutetarget builds and its executables pass: 44 core,4 layout, 3 msvc_compilation, 2 turing, the rest gated off on this arch.
A 21 point tile sweep on examples 80a and 80b, with M in {64,128,256,384,512},
N in {32,64,96,128,256} and K in {128,256,384,512}:
256x128x256and256x64x256change from failing to compiling. Every other shape keeps its verdict. Two shapes
that already failed,
128x128x128and128x128x384, gain the new assert as theirfirst error, and
64x128x256now leads with the existing M assert instead of atile_to_shapefailure. No shape that compiled before fails after.Notes
TileShape_Mof 384 compiles and then failscuTensorMapEncodeTiledat runtime,because a TMA box dimension is capped at 256 and the A descriptor's M box extent
is
TileShape_M:That is a separate gap with no compile-time guard, and I am happy to look at it in
its own PR.
The same missing K assert is present in
sm120_sparse_mma_tma.hppand in the twoSM100 sparse collectives. This PR stays with the collective named in #3393.
No in-tree test covers a 256-row SM120 sparse tile. I can add
256x128x256totest/unit/gemm/device/sm120_blockscaled_sparse_tensorop_gemmduring review.This answers #3393.
cc @thakkarV @hwu36