{"record":{"id":"7b927c8bfa608236","repo":"jax-ml/jax","slug":"the-out-argument-to-jnp-logaddexp-reduce-is-not","errorCode":null,"errorMessage":"The 'out' argument to jnp.logaddexp.reduce is not supported.","messagePattern":"The 'out' argument to jnp\\.logaddexp\\.reduce is not supported\\.","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/reductions.py","lineNumber":745,"sourceCode":"                    axis=_ensure_optional_axes(axis), dtype=dtype, out=out, keepdims=keepdims,\n                    initial=initial, where_=where)\n\n\n@api.jit(static_argnames=('axis', 'keepdims', 'dtype'), inline=True)\ndef _reduce_logical_xor(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  return _reduction(a, name=\"reduce_logical_xor\", op=lax.bitwise_xor, init_val=False, preproc=_cast_to_bool,\n                    axis=_ensure_optional_axes(axis), dtype=dtype, out=out, keepdims=keepdims,\n                    initial=initial, where_=where)\n\n\ndef _logsumexp(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 log(sum(exp(a))) while avoiding precision loss.\"\"\"\n  if out is not None:\n    raise NotImplementedError(\"The 'out' argument to jnp.logaddexp.reduce is not supported.\")\n  if dtype is not None:\n    dtype = dtypes.check_and_canonicalize_user_dtype(dtype, \"jnp.logaddexp.reduce\")\n  # TODO(phawkins): dtype isn't used here. That seems like a bug!\n  del dtype\n  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,","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/reductions.py#L727-L763","documentation":"jnp.logaddexp.reduce (exposed as jnp.logsumexp) does not accept the numpy-style 'out' parameter; JAX arrays are immutable so in-place output buffers are impossible.","triggerScenarios":"Calling jnp.logsumexp(x, out=buf) or np.logaddexp.reduce(jax_array, out=...) which delegates to JAX's implementation.","commonSituations":"Porting scipy/numpy code that reused buffers for logsumexp; generic reduction wrappers that forward **kwargs including out.","solutions":["Remove out= and assign the return value: res = jnp.logsumexp(x, axis=1)","Use buffer.at[idx].set(jnp.logsumexp(...)) to update buffers under jit","Strip out from kwargs before forwarding to jnp"],"exampleFix":"// before\njnp.logsumexp(x, axis=1, out=buf)\n// after\nbuf = jnp.logsumexp(x, axis=1)","handlingStrategy":"validation","validationCode":"kwargs.pop('out', None)\nres = jnp.logsumexp(x, axis=1, **kwargs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip out= in wrappers forwarding kwargs","Use return values instead of buffers"],"tags":["jax","logsumexp","out-parameter"],"backgroundTag":"unsupported-out-parameter","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}