{"record":{"id":"f656dea18ec269dd","repo":"jax-ml/jax","slug":"rule-cannot-handle-an-op-with-vector-operands-or-r","errorCode":null,"errorMessage":"Rule cannot handle an op with vector operands or results: {op}","messagePattern":"Rule cannot handle an op with vector operands or results: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/dialect_lowering.py","lineNumber":2954,"sourceCode":"  utils.try_cluster_cancel(op.cancellation_result, barrier.barrier_ref, predicate)\n  return []\n\n\n@_register_lowering(mgpu.QueryClusterCancelOp)\ndef _query_cluster_cancel_op_lowering_rule(\n    ctx: LoweringContext, op: mgpu.QueryClusterCancelOp\n) -> Sequence[ir.Value]:\n  del ctx\n  return utils.query_cluster_cancel(op.cancellation_result)\n\n\n@_register_lowering(func.FuncOp)\n@_register_lowering(gpu.LaunchOp)\ndef _traverse_op_lowering_rule(\n    ctx: LoweringContext, op: ir.OpView\n) -> MlirLoweringRuleResult:\n  if inference_utils.should_have_layout(op):\n    raise ValueError(\n        f\"Rule cannot handle an op with vector operands or results: {op}\"\n    )\n  for region in op.operation.regions:\n    for block in region:\n      for block_op in list(block):\n        with ir.InsertionPoint(block_op):\n          ctx.lower_op(block_op)\n  return RECURSED\n\n\ndef _should_lower(op: ir.OpView) -> bool:\n  \"\"\"Returns 'true' if the operation should be lowered.\"\"\"\n  return (\n      # pyrefly: ignore[missing-attribute]\n      op.OPERATION_NAME.startswith(\"mosaic_gpu.\")\n      or inference_utils.should_have_layout(op)\n      or inference_utils.should_have_transforms(op)\n      or inference_utils.should_have_tmem_layout(op)","sourceCodeStart":2936,"sourceCodeEnd":2972,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/dialect_lowering.py#L2936-L2972","documentation":"The generic traversal lowering rule (used for func.func, gpu.launch, etc.) cannot handle ops whose operands or results carry vector layouts — it would silently drop layout information, so it refuses.","triggerScenarios":"A layout-annotated vector op reaching _traverse_op_lowering_rule because no specialized lowering was registered for it — e.g. a new or custom op with tiled tensor operands that lacks a registered lowering rule.","commonSituations":"Custom ops or new dialect ops added without a registered Mosaic lowering; version mismatch where a registered rule is missing.","solutions":["Register a dedicated lowering rule for the op via _register_lowering (or use an existing op with a rule)","Wrap the vector computation in ops that Mosaic knows how to lower","Check the op's operands/results — if it's purely scalar it shouldn't have layouts; fix layout inference attachment"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if inference_utils.should_have_layout(op):\n    raise ValueError(f'{op} needs a dedicated lowering rule; not supported by traversal')","typeGuard":"def needs_special_lowering(op) -> bool:\n    from jax.experimental.mosaic.gpu import inference_utils\n    return inference_utils.should_have_layout(op)","tryCatchPattern":null,"preventionTips":["Register lowering rules for every custom op with tensor operands","Don't rely on the generic traversal rule for vector ops"],"tags":["mosaic","gpu","lowering","layout-mismatch","not-implemented"],"backgroundTag":"unsupported-op-lowering","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}