{"record":{"id":"d655785b84ffda6d","repo":"jax-ml/jax","slug":"op-does-not-have-an-name-attribute","errorCode":null,"errorMessage":"{op} does not have an {name} attribute","messagePattern":"(.+?) does not have an (.+?) attribute","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/inference_utils.py","lineNumber":88,"sourceCode":"    ValueError: If the operation does not have an in_tmem_layouts attribute.\n  \"\"\"\n  return _array_attr(op, \"in_tmem_layouts\")\n\n\ndef out_tmem_layouts(op: MlirOperation) -> Sequence[ir.Attribute]:\n  \"\"\"Returns the out_tmem_layouts attribute of the given operation.\n\n  Raises:\n    ValueError: If the operation does not have an out_tmem_layouts attribute.\n  \"\"\"\n  return _array_attr(op, \"out_tmem_layouts\")\n\n\ndef _array_attr(op: MlirOperation, name: str) -> Sequence[ir.Attribute]:\n  try:\n    result = op.attributes[name]\n  except KeyError:\n    raise ValueError(f\"{op} does not have an {name} attribute\") from None\n  if not isinstance(result, ir.ArrayAttr):\n    raise TypeError(f\"{op} has {name} of an unexpected type: {result}\")\n  return result  # pyrefly: ignore[bad-return]\n\n\ndef should_have_in_tmem_layout(op: MlirOperation) -> bool:\n  \"\"\"Returns 'true' if the operation operands should be assigned a TMEM layout.\"\"\"\n  return any(\n      isinstance(v.type, ir.MemRefType) and utils.is_tmem_ref(v)\n      for v in op.operands\n  )\n\n\ndef should_have_out_tmem_layout(op: MlirOperation) -> bool:\n  \"\"\"Returns 'true' if the operation results should be assigned a TMEM layout.\"\"\"\n  return any(\n      isinstance(v.type, ir.MemRefType) and utils.is_tmem_ref(v)\n      for v in op.results","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/inference_utils.py#L70-L106","documentation":"inference_utils._array_attr fetches a required MLIR array attribute (e.g. in_layouts, out_layouts, in_transforms, out_transforms, in_tmem_layouts, out_tmem_layouts) from an operation. If the op lacks the attribute entirely, a ValueError is raised naming the op and missing attribute. It typically means an operation was constructed without the layout/transform attributes the inference utilities expect.","triggerScenarios":"Calling in_layouts(op)/out_layouts(op)/in_transforms(op)/out_transforms(op)/in_tmem_layouts(op)/out_tmem_layouts(op) on an MlirOperation missing the corresponding array attribute, e.g. a manually built mosaic op without the in_layouts attribute, or running layout inference on an op type the utilities don't cover.","commonSituations":"Constructing MLIR ops by hand or via text parsing without attaching all attributes; version skew where attribute names changed between Mosaic/JAX releases; calling inference helpers on ops from a different dialect.","solutions":["Ensure the operation is built with the required attribute (e.g. include in_layouts/out_layouts array attributes when creating the op)","Check op.attributes names before calling the helper and skip ops that legitimately lack them","Verify you are running inference on ops produced by the current Mosaic pipeline, not hand-written or stale ops from an older version"],"exampleFix":"# before\nlayouts = inference_utils.in_layouts(op)  # op lacks 'in_layouts' -> ValueError\n\n# after\nif \"in_layouts\" in op.attributes:\n  layouts = inference_utils.in_layouts(op)\nelse:\n  layouts = None  # handle op without layouts","handlingStrategy":"try-catch","validationCode":"required = ['in_layouts', 'out_layouts']\nmissing = [n for n in required if n not in op.attributes]\nif missing:\n  raise RuntimeError(f'{op.name} missing attributes: {missing}')\nlayouts = inference_utils.in_layouts(op)","typeGuard":null,"tryCatchPattern":"try:\n  layouts = inference_utils.in_layouts(op)\nexcept ValueError as e:\n  if 'does not have' in str(e):\n    layouts = None  # op has no layouts; handle gracefully\n  else:\n    raise","preventionTips":["Build ops through the Mosaic wrappers so all attributes are attached","Assert required attributes exist before running inference utilities","Log op.attributes.keys() when debugging layout inference failures"],"tags":["mosaic-gpu","mlir","missing-attribute","layout-inference"],"backgroundTag":"missing-attribute","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}