xai-org/x-algorithm · error · ValueError

Not a canonical UMMA_K Layout: Expected MN-size multiple of

Error message

Not a canonical UMMA_K Layout: Expected MN-size multiple of 8.

What it means

For K-major operands, make_smem_desc_base requires the MN extent of the smem layout to be a multiple of 8 so it can logical_divide by an (8,2) atom. A non-multiple means the layout cannot be partitioned into the 8x2 core tiles the UMMA descriptor assumes.

Source

Thrown at phoenix/xrex/cutedsl/ranker_fa4/mma_sm100_desc.py:264

        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) << 46
    desc |= (BASE_OFFSET & 0x7) << 49
    desc |= (LBO_MODE & 0x1) << 52

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Pad or choose M/N extent to a multiple of 8 (the tmem/MMA atom size)
  2. Use an MN-major layout for that operand instead, which is validated against the swizzle atom instead of the 8-multiple rule
  3. Ensure the kernel's tile shape M is at least the MMA atom M (128 on tcgen05) so the smem M is naturally a multiple of 8

Example fix

# before
desc = make_smem_desc_base(cute.make_layout((6,K),stride=(K,1)), sw, Major.K)
# after
desc = make_smem_desc_base(cute.make_layout((8,K),stride=(K,1)), sw, Major.K)
Defensive patterns

Strategy: validation

Validate before calling

assert cute.size(layout.shape[0]) % 8 == 0, 'K-major UMMA operand M/N must be multiple of 8'

Prevention

When it happens

Trigger: K-major layout whose layout.shape[0] (M/N size) is e.g. 64? fine, but 4, 6, 12, or any value not divisible by 8 — typical with small unit-test tiles or tail tiles.

Common situations: Unit tests with tiny shapes like (4,K); partial/epilogue tiles of an M dimension not padded to a multiple of 8; ranker kernels whose head dimension was changed to a non-multiple-of-8 value.

Related errors


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/11a5450930028154. Report an issue: GitHub.