{"record":{"id":"f427dfd615cfa4d2","repo":"sgl-project/sglang","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":"python/sglang/kernels/ops/attention/flash_attn/cute/mma_sm100_desc.py","lineNumber":283,"sourceCode":"            canonical_layout.stride[1][1],\n        )\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(\n                \"Not a canonical UMMA_K Layout: Expected MN-size multiple of 8.\"\n            )\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    # ------------------------------------------------------------------ pack\n    desc = 0\n    # leading_byte_offset_  [16:30)\n    desc |= (leading_byte_offset & 0x3FFF) << 16\n    # stride_byte_offset_   [32:46)\n    desc |= (stride_byte_offset & 0x3FFF) << 32\n    # version_             [46:48)\n    desc |= (VERSION & 0x3) << 46\n    # base_offset_         [49:52)\n    desc |= (BASE_OFFSET & 0x7) << 49\n    # lbo_mode_            [52:53)\n    desc |= (LBO_MODE & 0x1) << 52","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/attention/flash_attn/cute/mma_sm100_desc.py#L265-L301","documentation":"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.","triggerScenarios":"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.","commonSituations":"Bank-conflict padding inserted into K-major smem tiles; layouts composed with an extra hierarchy level from zipped/divide modes.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"canon = cute.logical_divide(layout, (8, 2))\nassert canon.stride[0][0] == swizzle_atom_mn_size","typeGuard":null,"tryCatchPattern":null,"preventionTips":["No padding between atoms; keep atom strides canonical.","Validate strides in unit tests before kernel launch."],"tags":["cutlass","sm100","layout","stride"],"backgroundTag":"invalid-canonical-layout","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}