Add a forward-mode adjoint#536
Conversation
patrick-kidger
left a comment
There was a problem hiding this comment.
Oh no, I did not mean to close this :'D That happens automatically when the target branch (here dev) gets merged and removed.
If you can reopen this against main then I'd be very happy to take this PR! I agree we should really make this available to the world at large.
| AbstractAdjoint as AbstractAdjoint, | ||
| BacksolveAdjoint as BacksolveAdjoint, | ||
| DirectAdjoint as DirectAdjoint, | ||
| ForwardAdjoint as ForwardAdjoint, |
There was a problem hiding this comment.
Nit: we really shouldn't call this 'adjoint' as that word refers specifically to reverse-mode autodifferentiation. Maybe ForwardMode instead?
There was a problem hiding this comment.
Haha see I should really dig deeper into the theory of this!
Should we then rename the section in the documentation? Maybe "Differentiating through a solve"? ForwardMode also inherits from AbstractAdjoint.
The easiest thing to do would be to simply add a comment to the documentation of ForwardMode, that it is not really an adjoint.
Hi Patrick,
do you remember the forward-mode adjoint you wrote for me all those many months ago?
I've been wanting to make this useful to others for a long time, here it is! I have some questions:
jax.grad(..., allow_int=True).jacfwdandjax.linearizedo not support integer inputs, writing some custom thing that computes a JVP with respect to "unit pytrees" with mixed types and non-arrays is... a pain.This seems like an exceedingly rare use case given the difficulties, but maybe we should document somewhere that this option is not, in fact, available. (Or leave it be, since diffrax does not differ from jax in this respect.)
To serve documentation, I needed to make the version of mkdocs-autorefs explicit (to the second-to-last release or so), so I added that too. This also came up for optimistix a while ago.
Lastly, this is rebased on dev as of now - but I can imagine that your weekend was quite busy following Friday's release, so if you'd like to postpone this, I'm not in a rush! I will mark this as a draft, due to the questions above.