xai-org/x-algorithm · error · ValueError
SWIZZLE_128B_BASE32B is invalid for Major-K
Error message
SWIZZLE_128B_BASE32B is invalid for Major-K
What it means
The 128B_BASE32B swizzle mode (Swizzle<2,5,2>, used for 32-bit-base fp8/mxfp8 tcgen05 operands on Blackwell) has no descriptor encoding for K-major operands in this builder — the PTX smem descriptor format only defines it for MN-major layouts. make_smem_desc_base rejects the combination up front.
Source
Thrown at phoenix/xrex/cutedsl/ranker_fa4/mma_sm100_desc.py:262
if major is Major.MN:
swizzle_atom_k_size = 4 if layout_type is LayoutType.SWIZZLE_128B_BASE32B else 8
canonical_layout = cute.logical_divide(layout, (swizzle_atom_mn_size, swizzle_atom_k_size))
if not cute.is_congruent(canonical_layout, ((1, 1), (1, 1))):
raise ValueError("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
desc = 0
desc |= (leading_byte_offset & 0x3FFF) << 16
desc |= (stride_byte_offset & 0x3FFF) << 32
desc |= (VERSION & 0x3) << 46View on GitHub (pinned to 24c60942c5)
Solutions
- Store the operand MN-major (swap to an MN-major smem layout) so Swizzle<2,5,2> is legal
- If K-major is required, switch to a standard swizzle (Swizzle<3,4,3> 128B or <2,4,3> 64B) instead of 128B_BASE32B
- Set the MMA operand major mode to MN in the MmaOp so mma_op_to_idesc and the smem descriptor agree
Example fix
# before desc = make_smem_desc_base(kmajor_layout, cute.Swizzle(2,5,2), Major.K) # after desc = make_smem_desc_base(mnmajor_layout, cute.Swizzle(2,5,2), Major.MN)
Defensive patterns
Strategy: type-guard
Validate before calling
if sw.num_base == 5: # Swizzle<2,5,2> = 128B_BASE32B
assert major is Major.MN, '128B_BASE32B requires MN-major operand' Type guard
def base32b_ok(sw: cute.Swizzle, major: Major) -> bool:
return not (sw.num_base == 5 and major is Major.K) Prevention
- For fp8/mxfp8 operands plan the B matrix as MN-major from the start
- Keep a table of swizzle x allowed-major modes near kernel config
When it happens
Trigger: Calling make_smem_desc_base (directly or via gemm_ptx*/smem_desc_base_from_tensor) with swizzle Swizzle<2,5,2> and major=Major.K, e.g. an fp8 B-operand stored K-major in shared memory.
Common situations: Using mxfp8/fp8 tensors where the B operand arrives K-major from a transpose-free GEMM epilogue; porting a CUTLASS CollectiveBuilder config with K-major B and reusing the 128B_BASE32B smem atom.
Related errors
- 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.
- Not a canonical UMMA_K Layout: Expected MN-size multiple of
- Not a canonical UMMA_K Layout: Expected profile failure.
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/0d7f09fc808f6765.
Report an issue: GitHub.