An interface to various automatic differentiation backends in Julia.
Julia
316
611 commits
updated Oct 19, 2026
An interface to various automatic differentiation (AD) backends in Julia.
This package provides a unified syntax to differentiate functions, including:
We support the following backends defined by ADTypes.jl:
[!CAUTION] Note that in some cases, going through DifferentiationInterface.jl might be slower or cause more errors than a direct call to the backend's API. This is especially true for Enzyme.jl, whose handling of activities and multiple arguments is not fully supported here. We are working on this challenge, and welcome any suggestions or contributions. Meanwhile, if differentiation fails or takes too long, consider using Enzyme.jl through its native API instead.
To install the stable version of the package, run the following code in a Julia REPL:
using Pkg
Pkg.add("DifferentiationInterface")
To install the development version, run this instead:
using Pkg
Pkg.add(;
url="https://github.com/JuliaDiff/DifferentiationInterface.jl",
subdir="DifferentiationInterface",
)
using DifferentiationInterface
using ForwardDiff: ForwardDiff
using Enzyme: Enzyme
using Zygote: Zygote # AD backends you want to use
f(x) = sum(abs2, x)
x = [1.0, 2.0]
value_and_gradient(f, AutoForwardDiff(), x) # returns (5.0, [2.0, 4.0]) with ForwardDiff.jl
value_and_gradient(f, AutoEnzyme(), x) # returns (5.0, [2.0, 4.0]) with Enzyme.jl
value_and_gradient(f, AutoZygote(), x) # returns (5.0, [2.0, 4.0]) with Zygote.jl
To improve your performance by up to several orders of magnitude compared to this example, take a look at the tutorial and its section on operator preparation.
Whenever you refer to this package or the ideas it contains, please cite:
For the first two items, you can use the provided CITATION.cff file or the following BibTeX entries:
@article{dalle2026commoninterfaceautomaticdifferentiation,
author = {Guillaume Dalle and Adrian Hill},
title = {A Common Interface for Automatic Differentiation},
journal = {Journal of Machine Learning Research},
year = {2026},
volume = {27},
number = {25},
pages = {1--13},
url = {http://jmlr.org/papers/v27/25-1024.html}
}
@misc{schäfer2022abstractdifferentiationjlbackendagnostic,
title = {AbstractDifferentiation.jl: Backend-Agnostic Differentiable Programming in Julia},
author = {Frank Schäfer and Mohamed Tarek and Lyndon White and Chris Rackauckas},
year = {2022},
eprint = {2109.12449},
archiveprefix = {arXiv},
primaryclass = {cs.MS},
url = {https://arxiv.org/abs/2109.12449}
}
If you run the actual software as part of your experiments, please cite the precise Zenodo DOI of the package version you used, or the BibTeX entry below:
@software{dalle2024DifferentiationInterface202,
author = {Dalle, Guillaume and Hill, Adrian},
title = {Differentiation{I}nterface.jl},
year = {2024},
publisher = {Zenodo},
doi = {10.5281/zenodo.11092033},
url = {https://doi.org/10.5281/zenodo.11092033}
}
437 followers · starred Apr 2024
1,963 followers · starred Apr 2024
268 followers · starred Mar 2024
460 followers · starred Mar 2024
An interface to various automatic differentiation backends in Julia.
Julia
316
611 commits
updated Oct 19, 2026
An interface to various automatic differentiation (AD) backends in Julia.
This package provides a unified syntax to differentiate functions, including:
We support the following backends defined by ADTypes.jl:
[!CAUTION] Note that in some cases, going through DifferentiationInterface.jl might be slower or cause more errors than a direct call to the backend's API. This is especially true for Enzyme.jl, whose handling of activities and multiple arguments is not fully supported here. We are working on this challenge, and welcome any suggestions or contributions. Meanwhile, if differentiation fails or takes too long, consider using Enzyme.jl through its native API instead.
To install the stable version of the package, run the following code in a Julia REPL:
using Pkg
Pkg.add("DifferentiationInterface")
To install the development version, run this instead:
using Pkg
Pkg.add(;
url="https://github.com/JuliaDiff/DifferentiationInterface.jl",
subdir="DifferentiationInterface",
)
using DifferentiationInterface
using ForwardDiff: ForwardDiff
using Enzyme: Enzyme
using Zygote: Zygote # AD backends you want to use
f(x) = sum(abs2, x)
x = [1.0, 2.0]
value_and_gradient(f, AutoForwardDiff(), x) # returns (5.0, [2.0, 4.0]) with ForwardDiff.jl
value_and_gradient(f, AutoEnzyme(), x) # returns (5.0, [2.0, 4.0]) with Enzyme.jl
value_and_gradient(f, AutoZygote(), x) # returns (5.0, [2.0, 4.0]) with Zygote.jl
To improve your performance by up to several orders of magnitude compared to this example, take a look at the tutorial and its section on operator preparation.
Whenever you refer to this package or the ideas it contains, please cite:
For the first two items, you can use the provided CITATION.cff file or the following BibTeX entries:
@article{dalle2026commoninterfaceautomaticdifferentiation,
author = {Guillaume Dalle and Adrian Hill},
title = {A Common Interface for Automatic Differentiation},
journal = {Journal of Machine Learning Research},
year = {2026},
volume = {27},
number = {25},
pages = {1--13},
url = {http://jmlr.org/papers/v27/25-1024.html}
}
@misc{schäfer2022abstractdifferentiationjlbackendagnostic,
title = {AbstractDifferentiation.jl: Backend-Agnostic Differentiable Programming in Julia},
author = {Frank Schäfer and Mohamed Tarek and Lyndon White and Chris Rackauckas},
year = {2022},
eprint = {2109.12449},
archiveprefix = {arXiv},
primaryclass = {cs.MS},
url = {https://arxiv.org/abs/2109.12449}
}
If you run the actual software as part of your experiments, please cite the precise Zenodo DOI of the package version you used, or the BibTeX entry below:
@software{dalle2024DifferentiationInterface202,
author = {Dalle, Guillaume and Hill, Adrian},
title = {Differentiation{I}nterface.jl},
year = {2024},
publisher = {Zenodo},
doi = {10.5281/zenodo.11092033},
url = {https://doi.org/10.5281/zenodo.11092033}
}
437 followers · starred Apr 2024
1,963 followers · starred Apr 2024
268 followers · starred Mar 2024
460 followers · starred Mar 2024