{"record":{"id":"65c5d4d9dc3f02bd","repo":"jax-ml/jax","slug":"the-out-argument-to-jnp-logaddexp2-reduce-is-not","errorCode":null,"errorMessage":"The 'out' argument to jnp.logaddexp2.reduce is not supported.","messagePattern":"The 'out' argument to jnp\\.logaddexp2\\.reduce is not supported\\.","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/reductions.py","lineNumber":768,"sourceCode":"  a = ensure_arraylike(\"logsumexp\", a)\n  where = check_where(\"logsumexp\", where)\n  a_arr, = promote_dtypes_inexact(a)\n  pos_dims, dims = _reduction_dims(a_arr, axis)\n  amax = max(a_arr.real, axis=dims, keepdims=keepdims, where=where, initial=-np.inf)\n  amax = lax.stop_gradient(lax.select(lax.is_finite(amax), amax, lax.full_like(amax, 0)))\n  amax_with_dims = amax if keepdims else lax.expand_dims(amax, pos_dims)\n  exp_a = lax.exp(lax.sub(a_arr, amax_with_dims.astype(a_arr.dtype)))\n  sumexp = exp_a.sum(axis=dims, keepdims=keepdims, where=where)\n  result = lax.add(lax.log(sumexp), amax.astype(sumexp.dtype))\n  return result if initial is None else lax_other.logaddexp(initial, result)\n\n\ndef _logsumexp2(a: ArrayLike, axis: Axis = None, dtype: DTypeLike | None = None,\n                out: None = None, keepdims: bool = False,\n                initial: ArrayLike | None = None, where: ArrayLike | None = None) -> Array:\n  \"\"\"Compute log2(sum(2 ** a)) via logsumexp.\"\"\"\n  if out is not None:\n    raise NotImplementedError(\"The 'out' argument to jnp.logaddexp2.reduce is not supported.\")\n  if dtype is not None:\n    dtype = dtypes.check_and_canonicalize_user_dtype(\n        dtype, \"jnp.logaddexp2.reduce\")\n  a = ensure_arraylike(\"logsumexp2\", a)\n  where = check_where(\"logsumexp2\", where)\n  ln2 = float(np.log(2))\n  if initial is not None:\n    initial *= ln2\n  return _logsumexp(a * ln2, axis=axis, dtype=dtype, keepdims=keepdims,\n                    where=where, initial=initial) / ln2\n\n@export\ndef amin(a: ArrayLike, axis: Axis = None, out: None = None,\n        keepdims: bool = False, initial: ArrayLike | None = None,\n        where: ArrayLike | None = None) -> Array:\n  \"\"\"Alias of :func:`jax.numpy.min`.\"\"\"\n  return min(a, axis=axis, out=out, keepdims=keepdims,\n             initial=initial, where=where)","sourceCodeStart":750,"sourceCodeEnd":786,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/reductions.py#L750-L786","documentation":"The base-2 logsumexp (jnp.logaddexp2.reduce) rejects the 'out' parameter for the same reason as other JAX reductions: JAX arrays are immutable and in-place output is unsupported.","triggerScenarios":"Calling the reduce method of jnp.logaddexp2 with out=buf, or np.logaddexp2.reduce(jax_array, out=...) delegating to JAX.","commonSituations":"Numerical-stability code ported from numpy that used out buffers; kwargs-forwarding wrappers.","solutions":["Drop out= and use the returned array","Update buffers with .at[...].set(...) under jit"],"exampleFix":"// before\njnp.logaddexp2.reduce(x, axis=1, out=buf)\n// after\nbuf = jnp.logaddexp2.reduce(x, axis=1)","handlingStrategy":"validation","validationCode":"res = jnp.logaddexp2.reduce(x, axis=1)  # no out kwarg","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Drop out= from ported numpy reduce calls"],"tags":["jax","logaddexp2","out-parameter"],"backgroundTag":"unsupported-out-parameter","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}