{"record":{"id":"f42fb98013d4a745","repo":"jax-ml/jax","slug":"invalid-compute-type-c-type-current-supported-v-f42fb9","errorCode":null,"errorMessage":"Invalid compute type {c_type}. Current supported values are `device_host`, `device` and `tpu_sparsecore`","messagePattern":"Invalid compute type (.+?)\\. Current supported values are `device_host`, `device` and `tpu_sparsecore`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/interpreters/mlir.py","lineNumber":2819,"sourceCode":"  tokens_in = ctx.tokens_in.subset(effects)\n  out_nodes, tokens = call_lowering(\n      name, call_jaxpr, backend, ctx.module_context,\n      ctx.avals_in, ctx.avals_out, tokens_in, *args,\n      dim_var_values=ctx.dim_var_values,\n      const_lowering=ctx.const_lowering)\n  ctx.set_tokens_out(ctx.tokens_in.update_tokens(tokens))\n  return [lower_with_sharding_in_types(ctx, o, a)\n          for o, a in zip(out_nodes, ctx.avals_out)]\n\n\ndef map_compute_type(c_type: str) -> str:\n  if c_type == \"device_host\":\n    return \"host\"\n  elif c_type == \"device\":\n    return \"dense\"\n  elif c_type == \"tpu_sparsecore\":\n    return \"sparseoffload\"\n  raise ValueError(f\"Invalid compute type {c_type}. Current supported values \"\n                   \"are `device_host`, `device` and `tpu_sparsecore`\")\n\n\ndef _update_frontend_attributes(op, attrs):\n  if isinstance(op, ir.Block):\n    return\n  if attr_array := op.attributes.get(\"mhlo.frontend_attributes\"):\n    assert isinstance(attr_array, ir.DictAttr)\n    attrs |= {a.name: a.attr for a in attr_array}\n  op.attributes[\"mhlo.frontend_attributes\"] = ir.DictAttr.get(attrs)\n\n# TODO(yashkatariya): Delete this after legacy compute_on is deleted.\ndef wrap_compute_type_in_place(ctx: LoweringRuleContext,\n                               op: ir.Value | ir.Operation) -> None:\n  if ctx.jaxpr_eqn_ctx is None or ctx.jaxpr_eqn_ctx.compute_type is None:\n    return\n  op = _get_owner(op)\n","sourceCodeStart":2801,"sourceCodeEnd":2837,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/interpreters/mlir.py#L2801-L2837","documentation":"JAX maps a user-facing 'compute type' string to an internal string when setting up computations. Only `device_host`, `device`, and `tpu_sparsecore` are recognized; anything else reaches this fallthrough and raises. It is a strict input-validation error on a string enum.","triggerScenarios":"Passing an invalid string to a JAX API that accepts a compute/compute-type argument (e.g. a Pallas or TPU-related config taking compute type), such as compute_type='gpu', 'host', 'sparse', or a typo like 'device-host'. The value flows down to this normalizer in jax/_src/interpreters/mlir.py.","commonSituations":"Typos in config strings; assuming older/alternative names like `host` or `sparse` work; copying compute type values from outdated docs or other frameworks.","solutions":["Use exactly one of the supported strings: `device_host`, `device`, or `tpu_sparsecore`","Check for typos/dashes vs underscores (e.g. `device-host` is invalid)","If you need host vs device vs TPU Sparse Core placement, confirm which of the three supported modes matches your intent in current JAX docs"],"exampleFix":"# before\ncompute_type = 'device-host'\n\n# after\ncompute_type = 'device_host'","handlingStrategy":"validation","validationCode":"VALID_COMPUTE_TYPES = {'device_host', 'device', 'tpu_sparsecore'}\nif compute_type not in VALID_COMPUTE_TYPES:\n    raise ValueError(f'compute_type must be one of {VALID_COMPUTE_TYPES}')","typeGuard":"def is_valid_compute_type(c: str) -> bool:\n    return c in {'device_host', 'device', 'tpu_sparsecore'}","tryCatchPattern":null,"preventionTips":["Keep compute-type strings as module-level constants instead of literals scattered in configs","Add a unit test asserting config values against the supported set"],"tags":["jax","mlir","input-validation","enum","compute-type"],"backgroundTag":"invalid-enum-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}