Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link
Contributor

Summary

This PR adds initial support for using DifferentiationInterface.jl backends (ADTypes) as the sensealg parameter for computing derivatives of integrals.

  • Adds new IntegralsDifferentiationInterfaceExt extension that defines a ChainRulesCore.rrule for __solvebp when sensealg::AbstractADType
  • Uses DifferentiationInterface.pullback for gradient computation
  • Supports both in-place and out-of-place integrands, as well as batch integral functions
  • Computes boundary gradients using fundamental theorem of calculus (for 1D integrals)

Test plan

  • The extension loads correctly when ADTypes, DifferentiationInterface, and ChainRulesCore are loaded
  • Gradients can be computed using sensealg = AutoZygote() or other ADTypes backends
  • Results match existing ReCallVJP(ZygoteVJP()) implementation

Note: Full integration testing is marked as TODO in test/derivative_tests.jl because it requires further work to handle the complex interactions between the Zygote/Mooncake extensions. The extension provides the foundation for using ADTypes backends as sensealg.

Closes #258

cc @ChrisRackauckas

🤖 Generated with Claude Code

This PR adds initial support for using DifferentiationInterface.jl
backends (ADTypes) as the sensealg parameter for computing derivatives
of integrals.

Changes:
- Add IntegralsDifferentiationInterfaceExt extension that defines
  a ChainRulesCore.rrule for __solvebp when sensealg is an AbstractADType
- Add ADTypes and DifferentiationInterface as weak dependencies
- Add compat bounds for ADTypes (1) and DifferentiationInterface (0.6)

This provides the foundation for using unified AD backends like
AutoZygote(), AutoForwardDiff(), etc. as sensealg instead of the
current ReCallVJP(ZygoteVJP()) wrapper.

Note: Full integration testing is TODO - the extension needs further
refinement to work seamlessly with the existing Zygote/Mooncake
extensions. This is an initial implementation that addresses issue SciML#258.

Closes SciML#258

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@ChrisRackauckas-Claude ChrisRackauckas-Claude force-pushed the feature-differentiation-interface-support branch from 3e58bb9 to a082606 Compare January 12, 2026 10:04
The runic-action requires Julia to be installed first.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@ChrisRackauckas ChrisRackauckas merged commit f37d3cf into SciML:master Jan 12, 2026
10 checks passed
CommonSolve = "0.2.4"
Cuba = "2.2"
Cubature = "1.5"
DifferentiationInterface = "0.6"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the outdated version @ChrisRackauckas?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other deps.

@test grad_explicit grad_fd rtol = 1.0e-5
end

# DifferentiationInterface extension tests are TODO
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a dangerous way to add new features?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not documenting it for now because we can't run half of the ADs on v1.12 right now 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DifferentiationInterface instead of individual backends?

4 participants