{"record":{"id":"87ef596594cc2429","repo":"sgl-project/sglang","slug":"n-must-be-a-multiple-of-8-in-the-range-8-256","errorCode":null,"errorMessage":"N must be a multiple of 8 in the range 8…256","messagePattern":"N must be a multiple of 8 in the range 8…256","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/attention/flash_attn/cute/mma_sm100_desc.py","lineNumber":141,"sourceCode":"    c_sat: Saturate = Saturate.False_,\n    is_sparse: bool = False,\n    max_shift: MaxShift = MaxShift.NoShift,\n) -> int:\n    \"\"\"\n    Build the 32-bit instruction descriptor for Blackwell MMA.\n    All matrix/accumulator **types must be CUTLASS scalar classes** –\n    passing integers is forbidden.\n    \"\"\"\n    # --- encode element formats -------------------------------------------------\n    a_fmt = int(to_UMMA_format(a_type))\n    b_fmt = int(to_UMMA_format(b_type))\n    c_fmt = int(to_C_format(c_type))\n\n    # --- range checks on M/N -----------------------------------------------------\n    if M not in (64, 128, 256):\n        raise ValueError(\"M must be 64, 128 or 256\")\n    if N < 8 or N > 256 or (N & 7):\n        raise ValueError(\"N must be a multiple of 8 in the range 8…256\")\n\n    m_dim = M >> 4  # 5-bit field\n    n_dim = N >> 3  # 6-bit field\n\n    # fmt: off\n    # --- pack the bit-fields -----------------------------------------------------\n    desc = 0\n    desc |= (0                 & 0x3) << 0        # sparse_id2 (always 0 here)\n    desc |= (int(is_sparse)    & 0x1) << 2        # sparse_flag\n    desc |= (int(c_sat)        & 0x1) << 3        # saturate\n    desc |= (c_fmt             & 0x3) << 4        # c_format\n    desc |= (a_fmt             & 0x7) << 7        # a_format\n    desc |= (b_fmt             & 0x7) << 10       # b_format\n    desc |= (int(a_neg)        & 0x1) << 13       # a_negate\n    desc |= (int(b_neg)        & 0x1) << 14       # b_negate\n    desc |= (int(a_major)      & 0x1) << 15       # a_major\n    desc |= (int(b_major)      & 0x1) << 16       # b_major\n    desc |= (n_dim             & 0x3F) << 17      # n_dim (6 bits)","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/attention/flash_attn/cute/mma_sm100_desc.py#L123-L159","documentation":"The UMMA instruction descriptor's N field is 6 bits storing N>>3, so N must be a multiple of 8 between 8 and 256 inclusive. make_instr_desc raises this ValueError when N is out of range or not 8-aligned.","triggerScenarios":"Calling make_instr_desc with N values like 4, 12, 300, or any non-multiple of 8; common when deriving N from a head_dim or tile N of e.g. 96 is fine but 100 or 264 is not.","commonSituations":"Using non-standard head dims or K-tile sizes when building SM100 attention/GEMM descriptors; porting shapes from architectures with different alignment rules.","solutions":["Round N up to the nearest multiple of 8 within [8, 256] and predicate the excess columns.","Verify head_dim/tile_k values are 8-aligned; typical values 64/128/256 are safe.","If N > 256 you need multiple MMA instructions, not a larger descriptor N."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"assert 8 <= N <= 256 and N % 8 == 0, f\"N={N} must be multiple of 8 in [8, 256]\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep head dims and tile N 8-aligned.","Pad shapes up to the alignment boundary with masking rather than passing odd values."],"tags":["cutlass","sm100","mma","alignment"],"backgroundTag":"invalid-mma-tile-shape","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}