Add automatic differentiation test suite and add ForwardDiff support for dynamic master solvers #455
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I added a test suite that exhaustively checks automatic differentiation capabilities for each solver. With this PR, FiniteDiff.jl and ForwardDiff.jl are fully supported for schroedinger and master solvers (including their dynamic versions). I added DifferentiationInterface.jl as a test dependency to quickly test other autodiff libraries supported in Julia in the future (such as Zygote.jl and Enzyme.jl). In the future I will also add support for the stochastic, semi-classical, and Monte Carlo solvers.
One note: here I am simply testing whether or not each differentiation operation runs on each solver with random test cases. I'm open to testing for correctness within some numerical tolerance, but I'd imagine we'd have to be extremely careful that the hundreds of tests pass every time, particularly when we have a handful of autodiff libraries supported in the suite.