{"record":{"id":"5dd7992dfc253912","repo":"sgl-project/sglang","slug":"only-swizzle-2-5-2-supported-for-128b-base32b","errorCode":null,"errorMessage":"Only Swizzle<2,5,2> supported for 128B_BASE32B","messagePattern":"Only Swizzle<2,5,2> supported for 128B_BASE32B","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/attention/flash_attn/cute/mma_sm100_desc.py","lineNumber":217,"sourceCode":"\n\ndef _layout_type(swizzle: cute.Swizzle) -> LayoutType:\n    B, M, S = swizzle.num_bits, swizzle.num_base, swizzle.num_shift\n\n    if M == 4:  # Swizzle<*,4,3>\n        if S != 3:\n            raise ValueError(\"Unexpected swizzle shift – want S==3 for M==4\")\n        return {\n            0: LayoutType.SWIZZLE_NONE,\n            1: LayoutType.SWIZZLE_32B,\n            2: LayoutType.SWIZZLE_64B,\n            3: LayoutType.SWIZZLE_128B,\n        }[\n            B\n        ]  # KeyError ⇒ invalid B→ raise\n    if M == 5:  # Swizzle<2,5,2> (the only legal triple for M==5)\n        if (B, S) != (2, 2):\n            raise ValueError(\"Only Swizzle<2,5,2> supported for 128B_BASE32B\")\n        return LayoutType.SWIZZLE_128B_BASE32B\n\n    # Any other (M,B,S) triple is not a UMMA-legal shared-memory layout\n    raise ValueError(\"Unsupported swizzle triple for UMMA smem descriptor\")\n\n\ndef make_smem_desc_base(\n    layout: cute.Layout, swizzle: cute.Swizzle, major: Major\n) -> int:\n    \"\"\"\n    Convert a 2-D *shared-memory* Cute layout into the Blackwell 64-bit\n    smem-descriptor, without the smem start address.\n    layout must correspond to layout of an uint128 tensor.\n    \"\"\"\n    # ------------------------------------------------------------------ meta\n    layout_type = _layout_type(swizzle)  # resolve SWIZZLE_* family\n\n    VERSION = 1  # bits 46–47","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/attention/flash_attn/cute/mma_sm100_desc.py#L199-L235","documentation":"_layout_type only accepts Swizzle<2,5,2> for the num_base==5 case, which maps to LayoutType.SWIZZLE_128B_BASE32B. Any (B, S) other than (2, 2) with M==5 raises this ValueError.","triggerScenarios":"Calling make_smem_desc_base with a Swizzle whose num_base is 5 but whose num_bits/num_shift differ from 2/2 — e.g. Swizzle<3,5,2> or Swizzle<2,5,3>.","commonSituations":"Building 128B-base32B layouts manually with slightly-off parameters; mixing swizzle constants copied from a different atom.","solutions":["Use exactly Swizzle<2,5,2> for the 128B_BASE32B layout.","Take the swizzle from a canonical cute atom (the layouts used by the shipped kernels) instead of constructing it manually.","If you don't need base32B, use a Swizzle<*,4,3> triple instead."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if swizzle.num_base == 5:\n    assert (swizzle.num_bits, swizzle.num_shift) == (2, 2)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use Swizzle<2,5,2> verbatim for 128B_BASE32B.","Prefer building descriptors from tensors via smem_desc_base_from_tensor over manual layouts."],"tags":["cutlass","sm100","swizzle","shared-memory"],"backgroundTag":"invalid-swizzle-layout","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}