{"record":{"id":"f2c78e02b2c0fb6f","repo":"xai-org/x-algorithm","slug":"not-a-canonical-umma-k-layout-expected-stride-fai","errorCode":null,"errorMessage":"Not a canonical UMMA_K Layout: Expected stride failure.","messagePattern":"Not a canonical UMMA_K Layout: Expected stride failure\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/cutedsl/ranker_fa4/mma_sm100_desc.py","lineNumber":270,"sourceCode":"        stride_10 = canonical_layout.stride[1][0]\n        if stride_10 != swizzle_atom_mn_size:\n            raise ValueError(\"Not a canonical UMMA_MN Layout: Expected stride failure.\")\n        stride_01, stride_11 = canonical_layout.stride[0][1], canonical_layout.stride[1][1]\n        if layout_type is LayoutType.SWIZZLE_NONE:\n            stride_byte_offset, leading_byte_offset = stride_01, stride_11\n        else:\n            stride_byte_offset, leading_byte_offset = stride_11, stride_01\n    else:\n        if layout_type == LayoutType.SWIZZLE_128B_BASE32B:\n            raise ValueError(\"SWIZZLE_128B_BASE32B is invalid for Major-K\")\n        if not cute.size(layout.shape[0]) % 8 == 0:\n            raise ValueError(\"Not a canonical UMMA_K Layout: Expected MN-size multiple of 8.\")\n        canonical_layout = cute.logical_divide(layout, (8, 2))\n        if not cute.is_congruent(canonical_layout, ((1, 1), (1, 1))):\n            raise ValueError(\"Not a canonical UMMA_K Layout: Expected profile failure.\")\n        stride_00 = canonical_layout.stride[0][0]\n        if stride_00 != swizzle_atom_mn_size:\n            raise ValueError(\"Not a canonical UMMA_K Layout: Expected stride failure.\")\n        stride_10 = canonical_layout.stride[1][0]\n        if layout_type is not LayoutType.SWIZZLE_NONE and stride_10 != 1:\n            raise ValueError(\"Not a canonical UMMA_K Layout: Expected stride failure.\")\n        stride_01 = canonical_layout.stride[0][1]\n        stride_byte_offset, leading_byte_offset = stride_01, stride_10\n\n    desc = 0\n    desc |= (leading_byte_offset & 0x3FFF) << 16\n    desc |= (stride_byte_offset & 0x3FFF) << 32\n    desc |= (VERSION & 0x3) << 46\n    desc |= (BASE_OFFSET & 0x7) << 49\n    desc |= (LBO_MODE & 0x1) << 52\n    desc |= (int(layout_type) & 0x7) << 61\n\n    return desc & 0xFFFF_FFFF_FFFF_FFFF\n\n\ndef make_smem_desc_start_addr(start_addr: cute.Pointer) -> cutlass.Int32:","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/cutedsl/ranker_fa4/mma_sm100_desc.py#L252-L288","documentation":"In the K-major branch, stride_00 — the stride of the first mode of the M-divided (8,m) hierarchy — must equal swizzle_atom_mn_size (8 for 128B/BASE32B, 4 for 64B, 2 for 32B). This binds the layout's inner M repetition stride to the swizzle period; a mismatch means the declared swizzle does not describe how the layout repeats in M.","triggerScenarios":"Passing a 64B swizzle (atom 4) with a layout tiled with M-stride 8, or any K-major layout whose stride_00 differs from the table entry for the swizzle's LayoutType.","commonSituations":"Changing dtype (fp16 -> fp8 changes the natural atom width) without changing the swizzle constant; reusing a descriptor helper with a layout built for a different swizzle atom.","solutions":["Align the swizzle with the layout's M atom stride using the swizzle_atom_mn_size table (NONE:1, 32B:2, 64B:4, 128B:8)","Rebuild the layout via tile_to_shape from the same swizzle atom used in the descriptor call","Log canonical_layout.stride[0][0] to see the actual value and adjust one side"],"exampleFix":"# before\ndesc = make_smem_desc_base(layout_with_m_stride_8, cute.Swizzle(2,4,3), Major.K)  # 64B\n# after\ndesc = make_smem_desc_base(layout_with_m_stride_4, cute.Swizzle(2,4,3), Major.K)","handlingStrategy":"validation","validationCode":"expected = {0:1,1:8,2:8,4:4,6:2}[layout_type]\nassert cute.logical_divide(layout,(8,2)).stride[0][0] == expected","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate layouts whenever the dtype (and thus atom width) changes","Assert stride_00 equals the swizzle atom table value in kernel tests"],"tags":["cuda","cutlass","cute-dsl","umma","stride-check","smem-descriptor"],"backgroundTag":"layout-validation-failed","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}