sgl-project/sglang · error · ValueError
SWIZZLE_128B_BASE32B is invalid for Major-K
Error message
SWIZZLE_128B_BASE32B is invalid for Major-K
What it means
make_smem_desc_base rejects SWIZZLE_128B_BASE32B layouts on the Major-K path: the base32B sub-atom encoding is only defined for Major-MN operands in the UMMA shared-memory descriptor, so a Major.K layout combined with Swizzle<2,5,2> is invalid.
Source
Thrown at python/sglang/kernels/ops/attention/flash_attn/cute/mma_sm100_desc.py:273
"Not a canonical UMMA_MN Layout: Expected profile failure."
)
stride_00 = canonical_layout.stride[0][0]
if layout_type is not LayoutType.SWIZZLE_NONE and stride_00 != 1:
raise ValueError("Not a canonical UMMA_MN Layout: Expected stride failure.")
stride_10 = canonical_layout.stride[1][0]
if stride_10 != swizzle_atom_mn_size:
raise ValueError("Not a canonical UMMA_MN Layout: Expected stride failure.")
stride_01, stride_11 = (
canonical_layout.stride[0][1],
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 = 0View on GitHub (pinned to 0132848349)
Solutions
- Give the K-major operand a standard swizzle (SWIZZLE_32B/64B/128B or none) instead of the base32B atom.
- Or keep the base32B layout but tag the operand Major.MN if it truly is MN-major.
- Re-derive the layout from the operand's actual memory layout rather than sharing one layout across operands.
Defensive patterns
Strategy: validation
Validate before calling
if major is Major.K:
assert (swizzle.num_base, swizzle.num_bits, swizzle.num_shift) != (5, 2, 2), \
"SWIZZLE_128B_BASE32B not allowed for Major-K" Prevention
- Don't share one tile layout/swizzle between MN-major and K-major operands.
When it happens
Trigger: Calling gemm_ptx*/smem_desc_base_from_tensor with major=Major.K while the layout's swizzle resolves to LayoutType.SWIZZLE_128B_BASE32B.
Common situations: Reusing an MN-major 128B-base32B tile layout for the K operand without changing its swizzle; copy-paste between A/B operand construction paths.
Related errors
- Unexpected swizzle shift – want S==3 for M==4
- Only Swizzle<2,5,2> supported for 128B_BASE32B
- Unsupported swizzle triple for UMMA smem descriptor
- Not a canonical UMMA_MN Layout: Expected profile failure.
- Not a canonical UMMA_MN Layout: Expected stride failure.
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/5490aa68f9f6bff4.
Report an issue: GitHub.