exoplanet-dev / exoplanet-dev/celerite2
Work out traceable JVP and transpose rules for JAX
- Dominant language
- C++
- Stars
- 85
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
It should be possible to write the JVP ops using existing celerite primitives. This would allow support for higher order differentiation and perhaps it won't cause a significant computational overhead.
For example, the `matmul_lower` JVP can be implemented as follows:
```python
def matmul_lower_jvp(arg_values, arg_tangents):
def make_zero(x, t):
return lax.zeros_like_array(x) if type(t) is ad.Zero else t
t, c, U, V, Y = arg_values
tp, cp, Up, Vp, Yp = (
make_zero(x, t) for x, t in zip(arg_values, arg_tangents)
)
Ut = -(c[None, :] * tp[:, None] + cp[None, :] * t[:, None]) * U + Up
Vt = (c[None, :] * tp[:, None] + cp[None, :] * t[:, None]) * V + Vp
Zp = matmul_lower(t, c, U, V, Yp)
Zp += matmul_lower(t, c, Ut, V, Y)
Zp += matmul_lower(t, c, U, Vt, Y)
return matmul_lower_p.bind(t, c, U, V, Y), (Zp, None)
```
But I haven't figured out the correct transpose yet.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.