{"record":{"id":"bc41dabd60da7836","repo":"jax-ml/jax","slug":"a-scale-address-calculation-for-multiple-m-tiles","errorCode":null,"errorMessage":"A scale address calculation for multiple M tiles","messagePattern":"A scale address calculation for multiple M tiles","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/tcgen05.py","lineNumber":599,"sourceCode":"      a_mk = a.slice(slice(None), utils.ds(ki * a_k_group_elems, a_k_group_elems)).address\n    else:\n      assert a_desc_base is not None\n      a_offset = mi * a_m_group_stride + ki * a_k_group_stride\n      a_mk = (a_desc_base[0], a_desc_base[1] + mma_utils.encode_addr(a_offset))\n    b_offset = ni * b_n_group_stride + ki * b_k_group_stride\n    b_nk = (b_desc_base[0], b_desc_base[1] + mma_utils.encode_addr(b_offset))\n    if a_sparse_addr_base is not None:\n      if n_groups != 1 or m_groups != 1:\n        raise NotImplementedError(\"A sparse metadata address calculation for multiple tiles\")\n      sparse_group_elems = 8 if utils.bitwidth(mma_a_element_type) == 4 else 4\n      # Each sparse group has 2 entries, each TMEM column holds 16 i2 entries.\n      cols_per_k_group = k_group_elems // sparse_group_elems * 2 // 16\n      a_sparse_addr = arith.addi(a_sparse_addr_base, utils.c(ki * cols_per_k_group, i32))\n    else:\n      a_sparse_addr = None\n    if a_scale_addr_base is not None and b_scale_addr_base is not None:\n      if m_groups != 1:\n        raise NotImplementedError(\"A scale address calculation for multiple M tiles\")\n      if n_groups != 1:\n        raise NotImplementedError(\"B scale address calculation for multiple N tiles\")\n      assert scale_block is not None  # For type checkers.\n      assert k_group_elems % (scale_block * 4) == 0\n      assert m_group_elems % 32 == 0 and n_group_elems % (8 * num_cta) == 0\n      k_scales_per_group = k_group_elems // (scale_block * 4)\n      a_scale_addr = arith.addi(\n          a_scale_addr_base,\n          utils.c(ki * k_scales_per_group * a_scale_m_stride, i32),\n      )\n      b_scale_addr = arith.addi(\n          b_scale_addr_base,\n          utils.c(ki * k_scales_per_group * b_scale_n_stride, i32)\n      )\n    else:\n      a_scale_addr = b_scale_addr = None\n    acc = accumulate if ki == 0 else true\n    ni_lane_group, ni_col = ni // n_col_groups, ni % n_col_groups","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/tcgen05.py#L581-L617","documentation":"Block-scale TMEM addressing for the A scale tensor across multiple M tiles is not implemented; when both a_scale and b_scale are given, mma requires m_groups == 1.","triggerScenarios":"Block-scaled mma() with a_scale/b_scale supplied and a tile loop where m_groups > 1.","commonSituations":"Large-M MXFP8/FP4 GEMM where M exceeds one instruction tile (128) and the code relies on mma's internal tiling.","solutions":["Split the M dimension manually and issue one mma per M tile","Ensure the per-call m equals the full M so m_groups==1"],"exampleFix":"# before\ntcgen05.mma(a, b, d, a_scale=asc, b_scale=bsc, m=256)  # m_groups=2\n# after\nfor mi in range(2):\n  tcgen05.mma(a.slice(mi), b, d.slice(mi), a_scale=asc, b_scale=bsc, m=128)","handlingStrategy":"validation","validationCode":"assert m_groups == 1  # block-scaled A scale addressing supports single M tile","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Split M manually; one mma per M tile with scales","Cap per-call m at one tile (e.g. 128) in codegen"],"tags":["gpu","mosaic","tcgen05","block-scaling","not-implemented","tiling"],"backgroundTag":"unsupported-operation","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}