sgl-project/sglang · error · ValueError
Not a canonical UMMA_K Layout: Expected stride failure.
Error message
Not a canonical UMMA_K Layout: Expected stride failure.
What it means
On the Major-K path, the atom-level stride along the MN direction (stride_00 after the (8,2) divide) must equal swizzle_atom_mn_size. This raise fires when that stride doesn't match, meaning atoms are not packed at the expected spacing.
Source
Thrown at python/sglang/kernels/ops/attention/flash_attn/cute/mma_sm100_desc.py:283
canonical_layout.stride[1][1],
)
if layout_type is LayoutType.SWIZZLE_NONE:
stride_byte_offset, leading_byte_offset = stride_01, stride_11
else:
stride_byte_offset, leading_byte_offset = stride_11, stride_01
else:
if layout_type == LayoutType.SWIZZLE_128B_BASE32B:
raise ValueError("SWIZZLE_128B_BASE32B is invalid for Major-K")
if not cute.size(layout.shape[0]) % 8 == 0:
raise ValueError(
"Not a canonical UMMA_K Layout: Expected MN-size multiple of 8."
)
canonical_layout = cute.logical_divide(layout, (8, 2))
if not cute.is_congruent(canonical_layout, ((1, 1), (1, 1))):
raise ValueError("Not a canonical UMMA_K Layout: Expected profile failure.")
stride_00 = canonical_layout.stride[0][0]
if stride_00 != swizzle_atom_mn_size:
raise ValueError("Not a canonical UMMA_K Layout: Expected stride failure.")
stride_10 = canonical_layout.stride[1][0]
if layout_type is not LayoutType.SWIZZLE_NONE and stride_10 != 1:
raise ValueError("Not a canonical UMMA_K Layout: Expected stride failure.")
stride_01 = canonical_layout.stride[0][1]
stride_byte_offset, leading_byte_offset = stride_01, stride_10
# ------------------------------------------------------------------ pack
desc = 0
# leading_byte_offset_ [16:30)
desc |= (leading_byte_offset & 0x3FFF) << 16
# stride_byte_offset_ [32:46)
desc |= (stride_byte_offset & 0x3FFF) << 32
# version_ [46:48)
desc |= (VERSION & 0x3) << 46
# base_offset_ [49:52)
desc |= (BASE_OFFSET & 0x7) << 49
# lbo_mode_ [52:53)
desc |= (LBO_MODE & 0x1) << 52View on GitHub (pinned to 0132848349)
Solutions
- Remove inter-atom padding; the descriptor requires tight atom packing.
- Rebuild via cute.tile_to_shape with a standard atom so strides come out canonical.
- Use the un-swizzled (SWIZZLE_NONE) path if you control the layout and need non-standard packing — but prefer canonical atoms.
Defensive patterns
Strategy: validation
Validate before calling
canon = cute.logical_divide(layout, (8, 2)) assert canon.stride[0][0] == swizzle_atom_mn_size
Prevention
- No padding between atoms; keep atom strides canonical.
- Validate strides in unit tests before kernel launch.
When it happens
Trigger: Major.K layout where stride_00 != swizzle_atom_mn_size — e.g. atoms spaced with padding or an intermediate stride level between element and atom tiers.
Common situations: Bank-conflict padding inserted into K-major smem tiles; layouts composed with an extra hierarchy level from zipped/divide modes.
Related errors
- Not a canonical UMMA_MN Layout: Expected stride failure.
- Not a canonical UMMA_MN Layout: Expected profile failure.
- SWIZZLE_128B_BASE32B is invalid for Major-K
- Not a canonical UMMA_K Layout: Expected MN-size multiple of
- Not a canonical UMMA_K Layout: Expected profile failure.
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/f427dfd615cfa4d2.
Report an issue: GitHub.