{"record":{"id":"8631583c6363c1b2","repo":"jax-ml/jax","slug":"unsupported-wgmma-features-with-a-in-registers","errorCode":null,"errorMessage":"Unsupported WGMMA features with A in registers","messagePattern":"Unsupported WGMMA features with A in registers","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/wgmma.py","lineNumber":166,"sourceCode":"  if b_k_stride % 16:\n    raise ValueError\n  assert bytewidth(a_element_type) == bytewidth(b_element_type)\n  # Only 16-bit types support transposes\n  supports_transpose = bytewidth(b_element_type) == 2\n  if not supports_transpose and (a_transpose or b_transpose):\n    raise ValueError(\"Only f16 WGMMA supports transposes\")\n  if a_in_regs := isinstance(a, fa.FragmentedArray):\n    if a.mlir_dtype not in {bf16, f16, i8, f8e5m2, f8e4m3fn}:\n      raise ValueError(f\"Unsupported A register array dtype: {a.mlir_dtype}\")\n    # Column count must be equal to swizzle // bytewidth.\n    elt_bytewidth = utils.bytewidth(a_element_type)\n    swizzle_elems = swizzle // elt_bytewidth\n    if a.shape != (64, swizzle_elems):\n      raise ValueError(\"Unsupported A register array shape\")\n    if a.layout not in {fa.WGMMA_LAYOUT, fa.WGMMA_LAYOUT_8BIT}:\n      raise ValueError(\"Unsupported A register array layout\")\n    if a_k_stride is not None or a_transpose is not None:\n      raise ValueError(\"Unsupported WGMMA features with A in registers\")\n  else:\n    if a_k_stride is None or a_k_stride % 16:\n      raise ValueError\n    if a_transpose is None:\n      raise ValueError\n\n  if isinstance(out_ty, ir.F32Type) or out_ty == i32:\n    num_acc_regs = n // 2\n    out_ty_field = ir.VectorType.get((1,), out_ty)\n    acc_regs = list(acc.flat)\n    assert acc_regs[0].type == ir.VectorType.get((1,), out_ty)\n    to_acc_vec_regs = lambda regs: np.array(regs).reshape(acc.shape)\n    acc_constraint = \"r\" if isinstance(out_ty, ir.IntegerType) else \"f\"\n  elif isinstance(out_ty, ir.F16Type):\n    num_acc_regs = n // 4\n    out_ty_field = i32\n    acc_regs = [_as_i32_reg(reg) for reg in acc.flat]\n    vec_ty = ir.VectorType(acc.flat[0].type)","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/wgmma.py#L148-L184","documentation":"At wgmma.py:166, the A-in-registers form of wgmma does not support a_k_stride or a_transpose — those parameters only apply when A is read from shared memory.","triggerScenarios":"Calling wgmma.wgmma with a as a FragmentedArray AND specifying a_k_stride=... or a_transpose=True/False.","commonSituations":"Copy-pasting a memory-operand wgmma call and swapping in a register array; leaving explicit a_transpose=False (not None) set from earlier config.","solutions":["Set a_k_stride=None and a_transpose=None when A is in registers","Physically pre-transpose or re-stride A before loading into registers","Use the SMEM path if strides/transposes are required"],"exampleFix":"# before\nacc = wgmma.wgmma(a_regs, b, acc, a_k_stride=64, a_transpose=False)\n# after\nacc = wgmma.wgmma(a_regs, b, acc, a_k_stride=None, a_transpose=None)","handlingStrategy":"validation","validationCode":"if isinstance(a, fa.FragmentedArray):\n    assert a_k_stride is None and a_transpose is None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass None (not False) for unused transpose/stride flags","Keep memory-operand and register-operand call sites separate"],"tags":["jax","mosaic-gpu","wgmma","api-misuse","registers"],"backgroundTag":"unsupported-option-combination","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}