xai-org/x-algorithm · error · ValueError

M must be 64, 128 or 256

Error message

M must be 64, 128 or 256

What it means

make_instr_desc encodes the UMMA instruction M dimension into the instruction descriptor and hardware only supports M in {64, 128, 256}. Passing any other M (e.g. 32, 96, 512) raises ValueError before the descriptor is built.

Source

Thrown at phoenix/xrex/cutedsl/ranker_fa4/mma_sm100_desc.py:164

    a_type,
    b_type,
    c_type,
    M: int,
    N: int,
    a_major: Major,
    b_major: Major,
    a_neg: ScaleIn = ScaleIn.One,
    b_neg: ScaleIn = ScaleIn.One,
    c_sat: Saturate = Saturate.False_,
    is_sparse: bool = False,
    max_shift: MaxShift = MaxShift.NoShift,
) -> int:
    a_fmt = int(to_UMMA_format(a_type))
    b_fmt = int(to_UMMA_format(b_type))
    c_fmt = int(to_C_format(c_type))

    if M not in (64, 128, 256):
        raise ValueError("M must be 64, 128 or 256")
    if N < 8 or N > 256 or (N & 7):
        raise ValueError("N must be a multiple of 8 in the range 8…256")

    m_dim = M >> 4
    n_dim = N >> 3

    desc = 0
    desc |= (0 & 0x3) << 0
    desc |= (int(is_sparse) & 0x1) << 2
    desc |= (int(c_sat) & 0x1) << 3
    desc |= (c_fmt & 0x3) << 4
    desc |= (a_fmt & 0x7) << 7
    desc |= (b_fmt & 0x7) << 10
    desc |= (int(a_neg) & 0x1) << 13
    desc |= (int(b_neg) & 0x1) << 14
    desc |= (int(a_major) & 0x1) << 15
    desc |= (int(b_major) & 0x1) << 16
    desc |= (n_dim & 0x3F) << 17

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Round the MMA M dimension to 64, 128, or 256 (e.g. pad a 96-row tile to 128)
  2. Update the tile-shape config so the atom's M is legal while padding handles the remainder at the layout level
  3. If a smaller M is required, use masking over a 64-row atom rather than an unsupported atom size

Example fix

# before
desc = make_instr_desc(a, b, c, M=96, N=128)
# after
desc = make_instr_desc(a, b, c, M=128, N=128)  # mask remainder rows
Defensive patterns

Strategy: validation

Validate before calling

if M not in (64, 128, 256):
    raise ValueError(f'M={M} illegal for SM100 UMMA; use 64/128/256')

Type guard

def is_legal_umma_m(m: int) -> bool:
    return m in (64, 128, 256)

Prevention

When it happens

Trigger: Constructing an MMA op / calling mma_op_to_idesc where the tile M is derived from a head count or block size like 32, 96, or 512, which is not in (64, 128, 256).

Common situations: Tuning attention tile shapes (e.g. 96-row Q tiles for small batch) or porting SM90 tile configs to SM100 where the legal M set differs.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/50ff1ddd6ef63287. Report an issue: GitHub.