[BUG] jvp of mx.logcumsumexp is not implemented
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 28.5k
- Forks
- 2.3k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 62
Description
Describe the bug
Forward-mode autodiff (mx.jvp) through mx.logcumsumexp raises instead of returning the tangent:
RuntimeError: JVP is not implemented for cumulative prod/min/max
Scan::jvp only implements the Sum reduction; logcumsumexp (the LogAddExp scan) falls through to the generic "not implemented" branch even though its vjp is implemented. This breaks mx.jvp and forward-over-reverse compositions that go through logcumsumexp.
To Reproduce
import mlx.core as mx
x = mx.array([1.0, 2.0, 3.0])
t = mx.ones_like(x)
mx.jvp(lambda z: mx.logcumsumexp(z), [x], [t])
# RuntimeError: JVP is not implemented for cumulative prod/min/max
Expected behavior
mx.jvp of logcumsumexp returns the running softmax-weighted sum of the tangents,
d/dt logcumsumexp(x)_k = sum_{i<=k} softmax(x)_i * t_i,
consistent with the existing vjp (the adjoint identity <w, Jv> == <v, Jᵀw> should hold).
Desktop
- OS: macOS
- Version: main (0.32.0.dev)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Scan::jvp and trace the LogAddExp scan path used by mx.logcumsumexp, comparing it with the existing vjp implementation. Reproduce the Python mx.jvp example, then verify that the tangent is returned and that the stated adjoint identity holds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend, machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 67/100