{"record":{"id":"7d9eec2b5f806e79","repo":"jax-ml/jax","slug":"parameter-key-is-not-a-jaxpr-or-sequence-of-jaxp","errorCode":null,"errorMessage":"Parameter {key} is not a Jaxpr or sequence of Jaxprs: {value}","messagePattern":"Parameter (.+?) is not a Jaxpr or sequence of Jaxprs: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/hlo_interpreter.py","lineNumber":275,"sourceCode":"    new_jaxpr = jaxpr.with_consts(new_consts)\n    return new_jaxpr, extra_args\n\n  def rule(interpreter, *args, **params):\n    new_params = {}\n    for key in keys:\n      value = params[key]\n      if isinstance(value, jax_core.Jaxpr):\n        new_jaxpr, extra_args = _resolve_jaxpr(interpreter, value)\n        new_params[key] = new_jaxpr\n        args = extra_args + args\n      elif isinstance(value, tuple) or isinstance(value, list):\n        mapped_jaxprs, mapped_args = zip(*map(\n          lambda x, i: _resolve_jaxpr(interpreter, x, mapped_idx=i), value, range(len(value))))\n        all_new_args = tuple(new_arg for _args in mapped_args for new_arg in _args)\n        new_params[key] = tuple(mapped_jaxprs)\n        args = all_new_args + args\n      else:\n        raise ValueError(f\"Parameter {key} is not a Jaxpr or sequence of Jaxprs: {value}\")\n    params.update(new_params)\n    return primitive.bind(*args, **params)\n  return rule\n\n_eval_jaxpr_hop_rules[loops.scan_p] = make_hop_rule(loops.scan_p, 'jaxpr')\n_eval_jaxpr_hop_rules[loops.while_p] = make_hop_rule(\n    loops.while_p, 'body_jaxpr', 'cond_jaxpr')\n_eval_jaxpr_hop_rules[conditionals.cond_p] = make_hop_rule(conditionals.cond_p, 'branches')\ndef _run_scoped_physicalize_rule(\n    interpreter, *consts, jaxpr: jax_core.Jaxpr, collective_axes, **params):\n  if collective_axes:\n    raise NotImplementedError(\n        \"run_scoped interpret rule does not support collective axes\"\n    )\n  physical_jaxpr, physical_consts = interpreter(jaxpr, consts)\n  return primitives.run_scoped_p.bind(\n      *physical_consts, jaxpr=physical_jaxpr, collective_axes=collective_axes,\n      **params","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/hlo_interpreter.py#L257-L293","documentation":"This error is thrown by the Pallas HLO interpreter when a higher-order primitive (scan, while_loop, cond) is being re-bound with parameters that were expected to contain a Jaxpr or a sequence of Jaxprs, but the parameter value is neither. The interpreter's rule factory (make_hop_rule) inspects each primitive's params and must lower embedded jaxprs to interpret them; unknown parameter shapes abort.","triggerScenarios":"Running the Pallas HLO interpreter (e.g., pallas_call with an interpret/translation stage that hits _eval_jaxpr_hop_rules) over a kernel containing scan_p, while_p, or cond_p whose jaxpr-typed parameter ('jaxpr', 'body_jaxpr', 'cond_jaxpr', 'branches') holds a non-Jaxpr value (e.g., a closed jaxpr tuple, None, or a custom params dict injected by a transformation).","commonSituations":"Custom JAX transformations or new primitives that attach extra params to control-flow primitives; version mismatches where a param's expected type changed; passing a jaxpr closure via pjit-style (closed_jaxpr, consts) tuples instead of a raw Jaxpr.","solutions":["Ensure the parameter passed for the control-flow primitive is a raw jax_core.Jaxpr, not a ClosedJaxpr or tuple — unwrap with closed_jaxpr.jaxpr and thread consts as args","Check that any custom primitive params added by your transformation don't shadow the jaxpr-typed keys ('jaxpr', 'body_jaxpr', 'cond_jaxpr', 'branches')","Update JAX to a matching version where the interpreter rule supports your primitive's parameter layout","Avoid the HLO interpreter path (compile normally or use the standard interpret mode) if your kernel uses exotic control-flow metadata"],"exampleFix":"// before\nparams['body_jaxpr'] = (closed_jaxpr, ())  # tuple, not a Jaxpr\n// after\nparams['body_jaxpr'] = closed_jaxpr.jaxpr\nargs = args + tuple(closed_jaxpr.consts)","handlingStrategy":"validation","validationCode":"import jax._src.core as jax_core\ndef is_jaxpr(v):\n    return isinstance(v, jax_core.Jaxpr)","typeGuard":"def is_jaxpr(v) -> TypeGuard[jax_core.Jaxpr]: return isinstance(v, jax_core.Jaxpr)","tryCatchPattern":null,"preventionTips":["Keep jaxpr params as raw Jaxpr objects, never ClosedJaxpr tuples","Write a unit test that runs the interpreter over kernels with scan/while/cond"],"tags":["jax","pallas","jaxpr","control-flow","interpreter"],"backgroundTag":"invalid-parameter-type","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}