{"record":{"id":"bf187b3f885ac856","repo":"jax-ml/jax","slug":"the-out-argument-to-jnp-name-is-not-supported","errorCode":null,"errorMessage":"The 'out' argument to jnp.{name} is not supported.","messagePattern":"The 'out' argument to jnp\\.(.+?) is not supported\\.","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/reductions.py","lineNumber":115,"sourceCode":"\nReductionOp = Callable[[Any, Any], Any]\n\ndef _reduction(a: ArrayLike, name: str, op: ReductionOp, init_val: ArrayLike,\n               *, has_identity: bool = True,\n               preproc: Callable[[Array], Array] | None = None,\n               bool_op: ReductionOp | None = None,\n               upcast_f16_for_computation: bool = False,\n               axis: Axis = None, dtype: DTypeLike | None = None, out: None = None,\n               keepdims: bool = False, initial: ArrayLike | None = None,\n               where_: ArrayLike | None = None,\n               parallel_reduce: Callable[..., Array] | None = None,\n               promote_integers: bool = False) -> Array:\n  bool_op = bool_op or op\n  # Note: we must accept out=None as an argument, because numpy reductions delegate to\n  # object methods. For example `np.sum(x)` will call `x.sum()` if the `sum()` method\n  # exists, passing along all its arguments.\n  if out is not None:\n    raise NotImplementedError(f\"The 'out' argument to jnp.{name} is not supported.\")\n  a = ensure_arraylike(name, a)\n  where_ = check_where(name, where_)\n  axis = core.concrete_or_error(None, axis, f\"axis argument to jnp.{name}().\")\n\n  if initial is None and not has_identity and where_ is not None:\n    raise ValueError(f\"reduction operation {name} does not have an identity, so to use a \"\n                     f\"where mask one has to specify 'initial'\")\n\n  a = preproc(a) if preproc else a\n  pos_dims, dims = _reduction_dims(a, axis)\n\n  if initial is None and not has_identity:\n    shape = np.shape(a)\n    if not _all(shape[d] >= 1 for d in pos_dims):\n      raise ValueError(f\"zero-size array to reduction operation {name} which has no identity\")\n\n  result_dtype: DType\n  if dtype is None:","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/reductions.py#L97-L133","documentation":"JAX does not support the numpy 'out' parameter for reductions because JAX arrays are immutable and outputs cannot be written in place. The parameter is accepted only as None for numpy-delegation compatibility.","triggerScenarios":"Calling jnp.sum(x, out=buf), np.sum(jax_array, out=...) (numpy delegates to the array's .sum method), or any reduction (prod/max/min/all/any) with a non-None out argument.","commonSituations":"Porting numpy code that reuses output buffers for performance; code using np.add.reduce(x, out=y) on JAX arrays via __array_ufunc__ delegation.","solutions":["Drop the out argument and use the returned value: y = jnp.sum(x)","Use y = y.at[...].set(jnp.sum(x)) if you need to update a buffer under jit","Replace numpy namespace with jax.numpy consistently so out is never threaded through"],"exampleFix":"// before\njnp.sum(x, out=result)\n// after\nresult = jnp.sum(x)","handlingStrategy":"validation","validationCode":"kwargs = {k: v for k, v in kwargs.items() if k != 'out'}\njnp.sum(x, **kwargs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass out= to jnp reductions","Use returned values or .at[].set() under jit"],"tags":["jax","reductions","out-parameter","immutable-arrays"],"backgroundTag":"unsupported-out-parameter","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}