Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ steps:
agents:
queue: "juliagpu"
cuda: "*"
timeout_in_minutes: 60
timeout_in_minutes: 60
2 changes: 1 addition & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
4 changes: 2 additions & 2 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:

docs:
name: ${{ matrix.pkg.shortcut }}
runs-on: ubuntu-latest
Expand All @@ -33,7 +33,7 @@ jobs:
- name: DifferentiationInterfaceTest
shortcut: DIT
dir: './DifferentiationInterfaceTest'

steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/PreCommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Pre-Commit

# needed to allow julia-actions/cache to delete old caches that it has created
permissions:
actions: write
contents: read

on:
push:
branches:
- main
tags: ["*"]
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
workflow_dispatch:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
- uses: julia-actions/cache@v2
- run: julia -e 'using Pkg; Pkg.add("JuliaFormatter")'
- uses: astral-sh/setup-uv@v6
- run: uv tool install pre-commit
- run: pre-commit run --all-files --show-diff-on-failure --color always
2 changes: 1 addition & 1 deletion .github/workflows/Register.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
steps:
- uses: julia-actions/RegisterAction@latest
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
subdir: DifferentiationInterfaceTest
subdir: DifferentiationInterfaceTest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
*.csv

playground.jl
.vscode
.vscode
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- id: no-commit-to-branch
- repo: "https://github.com/domluna/JuliaFormatter.jl"
rev: "v2.1.6" # or whatever the desired release is
hooks:
- id: "julia-formatter"
fail_fast: true
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ _Only the two maintainers are allowed to approve and merge pull requests._
Feel free to ping them if they do not answer within a week or so.

Apart from the conditions above, this repository follows the [ColPrac](https://github.com/SciML/ColPrac) best practices and [Conventional Commits](https://www.conventionalcommits.org/en/).
Its code is formatted using [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl) with [BlueStyle](https://github.com/JuliaDiff/BlueStyle) -- please format any modified code before opening a pull request, otherwise CI will fail.
Its code is formatted using [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl) with [BlueStyle](https://github.com/JuliaDiff/BlueStyle).
As part of continuous integration, a set of formal tests is run using [pre-commit](https://pre-commit.com/).
We invite you to install pre-commit so that these checks are performed locally before you open or update a pull request.
You can refer to the [dev guide](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/dev/dev_guide/) for details on the package structure and the testing pipeline.
2 changes: 1 addition & 1 deletion DifferentiationInterface/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#790]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/790
[#788]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/788
[#782]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/782
[#768]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/768
[#768]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/768
3 changes: 0 additions & 3 deletions DifferentiationInterface/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ GPUArraysCore = "0.2"
GTPSA = "1.4.0"
JET = "0.9"
JLArrays = "0.2.0"
JuliaFormatter = "1,2"
LinearAlgebra = "1"
Mooncake = "0.4.147"
Pkg = "1"
Expand Down Expand Up @@ -110,7 +109,6 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
GTPSA = "b27dd330-f138-47c5-815b-40db9dd9b6e8"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PolyesterForwardDiff = "98d1487c-24ca-40b6-b7ab-df2af84e126b"
Expand All @@ -136,7 +134,6 @@ test = [
"ExplicitImports",
"JET",
"JLArrays",
"JuliaFormatter",
"Pkg",
"Random",
"SparseArrays",
Expand Down
10 changes: 5 additions & 5 deletions DifferentiationInterface/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Pkg.add(

```julia
using DifferentiationInterface
import ForwardDiff, Enzyme, Zygote # AD backends you want to use
import ForwardDiff, Enzyme, Zygote # AD backends you want to use

f(x) = sum(abs2, x)

Expand All @@ -97,23 +97,23 @@ You can use the provided [`CITATION.cff`](https://github.com/JuliaDiff/Different

```bibtex
@misc{dalle2025commoninterfaceautomaticdifferentiation,
title={A Common Interface for Automatic Differentiation},
title={A Common Interface for Automatic Differentiation},
author={Guillaume Dalle and Adrian Hill},
year={2025},
eprint={2505.05542},
archivePrefix={arXiv},
primaryClass={cs.MS},
url={https://arxiv.org/abs/2505.05542},
url={https://arxiv.org/abs/2505.05542},
}

@misc{schäfer2022abstractdifferentiationjlbackendagnosticdifferentiableprogramming,
title={AbstractDifferentiation.jl: Backend-Agnostic Differentiable Programming in Julia},
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},
url={https://arxiv.org/abs/2109.12449},
}
```

Expand Down
2 changes: 1 addition & 1 deletion DifferentiationInterface/docs/src/assets/logo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ end

# ╔═╡ 69d0fa4d-2585-42a0-981f-99d43f7e2c1f
md"## Creating Favicons
Using Imagemagick, run
Using Imagemagick, run
```bash
convert -background transparent logo.svg -define icon:auto-resize=256,128,48,32,16 favicon.ico
```
Expand Down
4 changes: 2 additions & 2 deletions DifferentiationInterface/docs/src/faq/differentiability.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ In some situations, manually writing overloads for `x::Dual` or `x::AbstractArra
### ReverseDiff

[ReverseDiff.jl](https://github.com/JuliaDiff/ReverseDiff.jl) relies on operator overloading for scalars, but also for arrays.
The relevant types are called `TrackedReal` and `TrackedArray`, they have a set of [limitations](https://juliadiff.org/ReverseDiff.jl/stable/limits/) very similar to that of ForwardDiff.jl's `Dual` and will cause similar errors.
The relevant types are called `TrackedReal` and `TrackedArray`, they have a set of [limitations](https://juliadiff.org/ReverseDiff.jl/stable/limits/) very similar to that of ForwardDiff.jl's `Dual` and will cause similar errors.

### Symbolic backends

Expand Down Expand Up @@ -112,4 +112,4 @@ There are, however, translation utilities:

Also note the existence of [`DifferentiationInterface.DifferentiateWith`](@ref), which allows the user to wrap a function that should be differentiated with a specific backend.

Right now, it only targets [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl), [Mooncake.jl](), [ChainRules.jl](https://juliadiff.org/ChainRulesCore.jl/stable/)-compatible backends (e.g., [Zygote.jl](https://github.com/FluxML/Zygote.jl)), but PRs are welcome to define Enzyme.jl rules for this object.
Right now, it only targets [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl), [Mooncake.jl](), [ChainRules.jl](https://juliadiff.org/ChainRulesCore.jl/stable/)-compatible backends (e.g., [Zygote.jl](https://github.com/FluxML/Zygote.jl)), but PRs are welcome to define Enzyme.jl rules for this object.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct GTPSAOneArgGradientPrep{SIG,X} <: DI.GradientPrep{SIG}
xt::X
end

# Unlike JVP, this requires us to use all variables
# Unlike JVP, this requires us to use all variables
function DI.prepare_gradient_nokwarg(
strict::Val, f, backend::AutoGTPSA{D}, x, contexts::Vararg{DI.Constant,C}
) where {D,C}
Expand Down Expand Up @@ -197,7 +197,7 @@ struct GTPSAOneArgJacobianPrep{SIG,X} <: DI.JacobianPrep{SIG}
xt::X
end

# To materialize the entire Jacobian we use all variables
# To materialize the entire Jacobian we use all variables
function DI.prepare_jacobian_nokwarg(
strict::Val, f, backend::AutoGTPSA{D}, x, contexts::Vararg{DI.Constant,C}
) where {D,C}
Expand Down Expand Up @@ -406,7 +406,7 @@ function DI.value_derivative_and_second_derivative!(
end

## Hessian
# Stores allocated array of TPS and an array for the monomial coefficient
# Stores allocated array of TPS and an array for the monomial coefficient
# indexing in GTPSA.cycle! (which is used if a Descriptor is specified)
struct GTPSAOneArgHessianPrep{SIG,X,M} <: DI.HessianPrep{SIG}
_sig::Val{SIG}
Expand All @@ -424,14 +424,14 @@ function DI.prepare_hessian_nokwarg(
else
nn = length(x)
d = Descriptor(nn, 2)
# If all variables/variable+parameters have truncation order > 2, then
# If all variables/variable+parameters have truncation order > 2, then
# the indexing is known beforehand and we can do it (very slightly) faster
m = nothing
end
xt = similar(x, TPS{promote_type(eltype(x), Float64)})

# xt and x have same indexing because of similar
# Setting the first derivatives must be 1-based
# Setting the first derivatives must be 1-based
# linear with the variables.
j = 1
for i in eachindex(xt)
Expand Down
2 changes: 1 addition & 1 deletion DifferentiationInterface/test/Back/GTPSA/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test_differentiation(
d1 = GTPSA.Descriptor(20, 2) # 20 variables to 2nd order
test_differentiation(AutoGTPSA(d1); type_stability=:full, logging=LOGGING);

# Test with Descriptor using varying orders
# Test with Descriptor using varying orders
vos = 2 * ones(Int, 20)
vos[1] = 3
d2 = GTPSA.Descriptor(vos, 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ using Aqua: Aqua
using DifferentiationInterface
using ExplicitImports
using JET: JET
using JuliaFormatter: JuliaFormatter
using Test
using SparseMatrixColorings
using SparseArrays
Expand All @@ -17,10 +16,6 @@ end
JET.test_package(DifferentiationInterface; target_defined_modules=true)
end

@testset "JuliaFormatter" begin
@test JuliaFormatter.format(DifferentiationInterface; verbose=false, overwrite=false)
end

@testset "Documentation" begin
if VERSION >= v"1.11"
@test isempty(Docs.undocumented_names(DifferentiationInterface))
Expand Down
2 changes: 1 addition & 1 deletion DifferentiationInterfaceTest/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#786]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/786
[#749]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/749
[#748]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/748
[#745]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/745
[#745]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/745
3 changes: 0 additions & 3 deletions DifferentiationInterfaceTest/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ ForwardDiff = "0.10.36,1"
Functors = "0.4, 0.5"
JET = "0.4 - 0.8, 0.9"
JLArrays = "0.1, 0.2"
JuliaFormatter = "1,2"
LinearAlgebra = "1"
Lux = "1.1.0"
LuxTestUtils = "1.3.1"
Expand Down Expand Up @@ -88,7 +87,6 @@ Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
Lux = "b2108857-7c20-44ae-9111-449ecde12c47"
LuxTestUtils = "ac9de150-d08f-4546-94fb-7472b5760531"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand All @@ -114,7 +112,6 @@ test = [
"ForwardDiff",
"JET",
"JLArrays",
"JuliaFormatter",
"Pkg",
"Random",
"SparseArrays",
Expand Down
2 changes: 1 addition & 1 deletion DifferentiationInterfaceTest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Pkg.add(
url="https://github.com/JuliaDiff/DifferentiationInterface.jl",
subdir="DifferentiationInterface"
)

Pkg.add(
url="https://github.com/JuliaDiff/DifferentiationInterface.jl",
subdir="DifferentiationInterfaceTest"
Expand Down
6 changes: 0 additions & 6 deletions DifferentiationInterfaceTest/test/formalities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ using DifferentiationInterfaceTest
using Aqua: Aqua
using ExplicitImports
using JET: JET
using JuliaFormatter: JuliaFormatter
using SparseMatrixColorings: SparseMatrixColorings
using Test

@testset "Aqua" begin
Aqua.test_all(DifferentiationInterfaceTest; ambiguities=false, undocumented_names=true)
end
@testset "JuliaFormatter" begin
@test JuliaFormatter.format(
DifferentiationInterfaceTest; verbose=false, overwrite=false
)
end
@testset verbose = true "JET" begin
JET.test_package(DifferentiationInterfaceTest; target_defined_modules=true)
end
Expand Down
Loading