{"record":{"id":"de60df459ebaf904","repo":"jax-ml/jax","slug":"unsupported-layout-for-conversion-from-mlir-attrib","errorCode":null,"errorMessage":"Unsupported layout for conversion from MLIR attribute: {attr}","messagePattern":"Unsupported layout for conversion from MLIR attribute: (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/layouts.py","lineNumber":133,"sourceCode":"      return _to_splat_fragmented_layout_attr(layout)\n    case fa.WGStridedFragLayout():\n      return _to_strided_fragmented_layout_attr(layout)\n    case fa.TiledLayout():\n      return _to_tiled_layout_attr(layout)\n    case _:\n      assert_never(layout)\n\n\ndef from_layout_attr(attr: ir.Attribute) -> fa.FragmentedLayout:\n  \"\"\"Constructs a layout from an MLIR attribute.\"\"\"\n  if isinstance(attr, mgpu.WGSplatFragLayoutAttr):\n    return _from_splat_fragmented_layout_attr(attr)\n  elif isinstance(attr, mgpu.WGStridedFragLayoutAttr):\n    return _from_strided_fragmented_layout_attr(attr)\n  elif isinstance(attr, mgpu.TiledLayoutAttr):\n    return _from_tiled_layout_attr(attr)\n  else:\n    raise NotImplementedError(\n        f\"Unsupported layout for conversion from MLIR attribute: {attr}\"\n    )\n\n\ndef splat_is_compatible_with_tiled(\n    l1: fa.WGSplatFragLayout, l2: fa.TiledLayout\n) -> bool:\n  # A splat layout is compatible with a tiled layout up to replication if each\n  # dimension in the shape of the splat layout is divisible by the corresponding\n  # dimension in the base tile shape.\n  s1, s2 = l1.shape, l2.base_tile_shape\n  return all(d1 % d2 == 0 for d1, d2 in zip(s1, s2))\n\n\ndef to_transform_attr(\n    transform: launch_context.MemRefTransform | mgpu.SwizzlingMode,\n) -> ir.Attribute:\n  if isinstance(transform, launch_context.TileTransform):","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/layouts.py#L115-L151","documentation":"layouts_lib.from_layout_attr converts an MLIR layout attribute into a Python layout object; only WGSPlacedFrag, WGStridedFrag, splat, and Tiled layout attrs (plus their fragmented variants) are recognized. Any other attribute type raises NotImplementedError.","triggerScenarios":"A custom or newly introduced mgpu layout attribute reaches from_layout_attr — e.g. when serializing/deserializing Mosaic kernels or lowering custom ops with a novel layout attr.","commonSituations":"Version mismatch where MLIR produces a layout attr the Python side doesn't know, or third-party dialects reusing mgpu layout attributes.","solutions":["Use one of the supported layout attributes (TiledLayoutAttr, WGSPlacedFragLayoutAttr, etc.)","If defining a new layout, also extend from_layout_attr with a converter","Align jax and any custom MLIR pass versions"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def is_supported_layout_attr(attr):\n    return isinstance(attr, (mgpu.TiledLayoutAttr, mgpu.WGSPlacedFragLayoutAttr,\n                             mgpu.WGStridedFragLayoutAttr, mgpu.WGSplatFragLayoutAttr))","tryCatchPattern":null,"preventionTips":["Only attach the documented layout attribute kinds","Version-match producers and consumers of MLIR modules"],"tags":["jax","mosaic","layout","mlir-attribute","not-implemented"],"backgroundTag":"unsupported-layout-attribute","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}