{"record":{"id":"ed9886a497e4eecf","repo":"jax-ml/jax","slug":"expected-b-scales-to-have-a-m-64-collective-layout","errorCode":null,"errorMessage":"Expected B scales to have a M=64 collective layout, got {b_scale.layout}","messagePattern":"Expected B scales to have a M=64 collective layout, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/tcgen05.py","lineNumber":475,"sourceCode":"        raise ValueError(\n            \"Scale element type mismatch: expected f8e8m0fnu or f8e4m3fn, got\"\n            f\" {scale_element_type}\"\n        )\n    else:\n      raise NotImplementedError(\n          f\"Unsupported element type for block scaling: {a_element_type}\"\n      )\n    k_scales = k // scale_block\n    if a_scale.shape != (TMEM_ROWS, k_scales):\n      raise ValueError(\n          f\"A scale shape mismatch: expected ({TMEM_ROWS}, {k_scales}), got\"\n          f\" {a_scale.shape}\"\n      )\n    if a_scale.layout != scales_layout():\n      raise ValueError(f\"A scale layout {a_scale.layout} is not supported\")\n    if collective and m == 64:\n      if b_scale.layout != b_scales_m64_collective_layout():\n        raise ValueError(\n            \"Expected B scales to have a M=64 collective layout, got\"\n            f\" {b_scale.layout}\"\n        )\n    elif m == 128:\n      if b_scale.layout != scales_layout():\n        raise ValueError(\n            f\"Expected B scales to have a M=128 layout, got {b_scale.layout}\"\n        )\n    else:\n      raise AssertionError(\"Should not happen\")\n    if b_scale.shape[0] % 128 or b_scale.shape[0] < n * num_cta:\n      raise ValueError(\n          f\"B scale shape[0] must be a multiple of 128 and >= N={n * num_cta},\"\n          f\" got {b_scale.shape[0]}\"\n      )\n    if b_scale.shape[1] != k_scales:\n      raise ValueError(\n          f\"B scale shape mismatch: expected ({b_scale.shape[0]}, {k_scales}),\"","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/tcgen05.py#L457-L493","documentation":"For collective (multi-CTA) block-scaled MMA with M=64, the B scale tensor must use the special layout b_scales_m64_collective_layout(). This mirrors the M=64 collective MMA instruction's scale lanes across CTAs.","triggerScenarios":"Calling mma(..., collective=True, m=64) with b_scale.layout != b_scales_m64_collective_layout().","commonSituations":"Reusing dense M=128 kernel scale layouts in a 2-CTA collective M=64 configuration; forgetting to switch layouts when enabling collective mode.","solutions":["Set b_scale layout to b_scales_m64_collective_layout() when collective=True and m=64","Or use m=128 (with plain scales_layout) if collective M=64 isn't required"],"exampleFix":"# before\nb_scale = TensorMemRefView(buf, shape, dt, layout=scales_layout())\n# after (collective, m=64)\nb_scale = TensorMemRefView(buf, shape, dt, layout=b_scales_m64_collective_layout())","handlingStrategy":"validation","validationCode":"from jax.experimental.mosaic.gpu import tcgen05\nexpected = tcgen05.b_scales_m64_collective_layout() if (collective and m == 64) else None\nassert expected is None or b_scale.layout == expected","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick the B scale layout from (collective, m) in one helper function","Test both M=64-collective and M=128 configs in CI"],"tags":["gpu","mosaic","tcgen05","layout","collective","cgmma"],"backgroundTag":"invalid-memory-layout","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}