{"record":{"id":"5490aa68f9f6bff4","repo":"sgl-project/sglang","slug":"swizzle-128b-base32b-is-invalid-for-major-k","errorCode":null,"errorMessage":"SWIZZLE_128B_BASE32B is invalid for Major-K","messagePattern":"SWIZZLE_128B_BASE32B is invalid for Major-K","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/attention/flash_attn/cute/mma_sm100_desc.py","lineNumber":273,"sourceCode":"                \"Not a canonical UMMA_MN Layout: Expected profile failure.\"\n            )\n        stride_00 = canonical_layout.stride[0][0]\n        if layout_type is not LayoutType.SWIZZLE_NONE and stride_00 != 1:\n            raise ValueError(\"Not a canonical UMMA_MN Layout: Expected stride failure.\")\n        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 = (\n            canonical_layout.stride[0][1],\n            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","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/attention/flash_attn/cute/mma_sm100_desc.py#L255-L291","documentation":"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.","triggerScenarios":"Calling gemm_ptx*/smem_desc_base_from_tensor with major=Major.K while the layout's swizzle resolves to LayoutType.SWIZZLE_128B_BASE32B.","commonSituations":"Reusing an MN-major 128B-base32B tile layout for the K operand without changing its swizzle; copy-paste between A/B operand construction paths.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if major is Major.K:\n    assert (swizzle.num_base, swizzle.num_bits, swizzle.num_shift) != (5, 2, 2), \\\n        \"SWIZZLE_128B_BASE32B not allowed for Major-K\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't share one tile layout/swizzle between MN-major and K-major operands."],"tags":["cutlass","sm100","swizzle","layout"],"backgroundTag":"invalid-canonical-layout","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}