{"record":{"id":"75dc7a40bbf407fd","repo":"jax-ml/jax","slug":"the-input-arguments-to-the-custom-jvp-decorated-fu","errorCode":null,"errorMessage":"The input arguments to the custom_jvp-decorated function {primal_name} could not be resolved to positional-only arguments. Binding failed with the error:\\n{e}","messagePattern":"The input arguments to the custom_jvp-decorated function (.+?) could not be resolved to positional-only arguments\\. Binding failed with the error:\\\\n(.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/custom_derivatives.py","lineNumber":268,"sourceCode":"      tangent_out = tree_map(_sum_tangents, primal_out, *all_tangents_out)\n      return primal_out, tangent_out\n\n    self.defjvp(jvp)\n\n  @partial(traceback_util.api_boundary,\n           repro_api_name=\"jax.custom_jvp.__call__\")\n  def __call__(self, *args: Any, **kwargs: Any) -> ReturnValue:\n    debug = debug_info(\"custom_jvp fun\", self.fun, args, kwargs,\n                       static_argnums=self.nondiff_argnums)\n    primal_name = debug.func_name\n    if not self.jvp:\n      msg = f\"No JVP defined for custom_jvp function {primal_name} using defjvp.\"\n      raise AttributeError(msg)\n\n    try:\n      args = resolve_kwargs(self.fun, args, kwargs)\n    except TypeError as e:\n      raise TypeError(\n          \"The input arguments to the custom_jvp-decorated function \"\n          f\"{primal_name} could not be resolved to positional-only arguments. \"\n          f\"Binding failed with the error:\\n{e}\"\n      ) from e\n\n    if self.nondiff_argnums:\n      args = tuple(_stop_gradient(x) if i in self.nondiff_argnums else x\n                   for i, x in enumerate(args))\n      diff_argnums = [i for i in range(len(args)) if i not in self.nondiff_argnums]\n      f_, dyn_args = argnums_partial(lu.wrap_init(self.fun, debug_info=debug),\n                                     diff_argnums, args,\n                                     require_static_args_hashable=False)\n      static_args = [args[i] for i in self.nondiff_argnums]\n      diff_args = [args[i] for i, a in enumerate(args) if i not in self.nondiff_argnums]\n      debug_jvp = debug_info(\"custom_jvp jvp\", self.jvp,\n                             (*static_args, diff_args, diff_args),\n                             {},\n                             static_argnums=tuple(range(len(static_args))))","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/custom_derivatives.py#L250-L286","documentation":"Like custom_vmap, custom_jvp functions must be invoked with positional arguments; this TypeError wraps the failure to bind supplied keyword arguments to positional parameters.","triggerScenarios":"Calling a @jax.custom_jvp function with keyword arguments that cannot be resolved to positions (unknown names, keyword-only params, or **kwargs forwarding).","commonSituations":"Refactored parameter names with stale callers; passing config flags as kwargs into a custom_jvp-wrapped loss; wrappers that forward **user_kwargs blindly.","solutions":["Call with all arguments positionally","If keyword ergonomics matter, add an outer plain-Python wrapper that binds kwargs and calls the custom_jvp function positionally"],"exampleFix":"# before\nloss = f(x, y, eps=1e-3)\n# after\nloss = f(x, y, 1e-3)","handlingStrategy":"validation","validationCode":"import inspect\ndef call_positional(fn, *args, **kwargs):\n    b = inspect.signature(fn).bind(*args, **kwargs)\n    b.apply_defaults()\n    return fn(*b.args)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mark custom_jvp params positional-only with /","Avoid **kwargs forwarding into custom_jvp functions"],"tags":["jax","custom-jvp","kwargs","argument-binding"],"backgroundTag":"keyword-argument-binding-failed","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}