Skip to content

Commit

Permalink
Update pipeline.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Sep 26, 2024
1 parent d94d15e commit 4b51746
Show file tree
Hide file tree
Showing 18 changed files with 212 additions and 17 deletions.
183 changes: 182 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,186 @@ steps:
cuda: "*"
command: |
julia --color=yes --project -e 'using Pkg; Pkg.add("CUDA"); Pkg.add("NLPModels"); Pkg.add("NLPModelsTest"); Pkg.instantiate()'
julia --color=yes --project -e 'include("test/gpu.jl")'
julia --color=yes --project -e 'include("test/gpu/nvidia.jl")'
timeout_in_minutes: 30

- label: "CPUs -- ForwardDiff.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("ForwardDiff")
Pkg.instantiate()
include("test/backend/ForwardDiff.jl")'
timeout_in_minutes: 30

- label: "CPUs -- ReverseDiff.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("ReverseDiff")
Pkg.instantiate()
include("test/backend/ReverseDiff.jl")'
timeout_in_minutes: 30

- label: "CPUs -- Enzyme.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("Enzyme")
Pkg.instantiate()
include("test/backend/Enzyme.jl")'
timeout_in_minutes: 30

- label: "CPUs -- Zygote.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("Zygote")
Pkg.instantiate()
include("test/backend/Zygote.jl")'
timeout_in_minutes: 30

- label: "CPUs -- Mooncake.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("Mooncake")
Pkg.instantiate()
include("test/backend/Mooncake.jl")'
timeout_in_minutes: 30

- label: "CPUs -- Diffractor.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("Diffractor")
Pkg.instantiate()
include("test/backend/Diffractor.jl")'
timeout_in_minutes: 30

- label: "CPUs -- Tracker.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("Tracker")
Pkg.instantiate()
include("test/backend/Tracker.jl")'
timeout_in_minutes: 30

- label: "CPUs -- Symbolics.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("Symbolics")
Pkg.instantiate()
include("test/backend/Symbolics.jl")'
timeout_in_minutes: 30

- label: "CPUs -- ChainRules.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("ChainRules")
Pkg.instantiate()
include("test/backend/ChainRules.jl")'
timeout_in_minutes: 30

- label: "CPUs -- FastDifferentiation.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("FastDifferentiation")
Pkg.instantiate()
include("test/backend/FastDifferentiation.jl")'
timeout_in_minutes: 30

- label: "CPUs -- FiniteDiff.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("FiniteDiff")
Pkg.instantiate()
include("test/backend/FiniteDiff.jl")'
timeout_in_minutes: 30

- label: "CPUs -- FiniteDifferences.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("FiniteDifferences")
Pkg.instantiate()
include("test/backend/FiniteDifferences.jl")'
timeout_in_minutes: 30

- label: "CPUs -- PolyesterForwardDiff.jl"
plugins:
- JuliaCI/julia#v1:
version: "1.10"
agents:
queue: "juliaecosystem"
command: |
julia --color=yes --project -e '
using Pkg
Pkg.add("PolyesterForwardDiff")
Pkg.instantiate()
include("test/backend/PolyesterForwardDiff.jl")'
8 changes: 4 additions & 4 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
DataFrames = "1"
Documenter = "1.0"
ManualNLPModels = "0.1"
NLPModels = "0.21"
NLPModelsJuMP = "0.13"
OptimizationProblems = "0.8"
NLPModels = "0.21.3"
NLPModelsJuMP = "0.13.2"
OptimizationProblems = "0.9"
Percival = "0.7"
Plots = "1"
SolverBenchmark = "0.6"
Zygote = "0.6.62"
Zygote = "0.6.70"
25 changes: 13 additions & 12 deletions docs/src/backend.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# How to switch backend in ADNLPModels

`ADNLPModels` allows the use of different backends to compute the derivatives required within NLPModel API.
It uses `ForwardDiff.jl`, `ReverseDiff.jl`, and more via optional depencies.
It uses `ForwardDiff.jl`, `ReverseDiff.jl`, and more via optional dependencies.

The backend information is in a structure [`ADNLPModels.ADModelBackend`](@ref) in the attribute `adbackend` of a `ADNLPModel`, it can also be accessed with [`get_adbackend`](@ref).

The functions used internally to define the NLPModel API and the possible backends are defined in the following table:

| Functions | FowardDiff backends | ReverseDiff backends | Zygote backends | Enzyme backend | Sparse backend |
| --------- | ------------------- | -------------------- | --------------- | -------------- | -------------- |
| `gradient` and `gradient!` | `ForwardDiffADGradient`/`GenericForwardDiffADGradient` | `ReverseDiffADGradient`/`GenericReverseDiffADGradient` | `ZygoteADGradient` | `EnzymeADGradient` | -- |
| `jacobian` | `ForwardDiffADJacobian` | `ReverseDiffADJacobian` | `ZygoteADJacobian` | `EnzymeADJacobian` | `SparseADJacobian` |
| `hessian` | `ForwardDiffADHessian` | `ReverseDiffADHessian` | -- | -- | `SparseADHessian`/`SparseReverseADHessian` |
| `Jprod` | `ForwardDiffADJprod`/`GenericForwardDiffADJprod` | `ReverseDiffADJprod`/`GenericReverseDiffADJprod` | `ZygoteADJprod` | `EnzymeADJprod` | -- |
| `Jtprod` | `ForwardDiffADJtprod`/`GenericForwardDiffADJtprod` | `ReverseDiffADJtprod`/`GenericReverseDiffADJtprod` | `ZygoteADJtprod` | `EnzymeADJtprod` | -- |
| `Hvprod` | `ForwardDiffADHvprod`/`GenericForwardDiffADHvprod` | `ReverseDiffADHvprod`/`GenericReverseDiffADHvprod` | -- | -- | -- |
| `directional_second_derivative` | `ForwardDiffADGHjvprod` | -- | -- | -- | -- |

The functions `hess_structure!`, `hess_coord!`, `jac_structure!` and `jac_coord!` defined in `ad.jl` are generic to all the backends for now.
| package | ForwardDiff.jl | ReverseDiff.jl | Enzyme.jl | Zygote.jl | Mooncake.jl | Diffractor.jl | Tracker.jl | Symbolics.jl | ChainRules.jl | FastDifferentiation.jl | FiniteDiff.jl | FiniteDifferences.jl | PolyesterForwardDiff.jl |
|--------|----------------|----------------|-----------|-----------|-------------|---------------|------------|--------------|----------------------|------------------------|---------------|----------------------|-------------------------|
| $\nabla f(x)$ | `ForwardDiffADGradient` | `ReverseDiffADGradient` | `EnzymeADGradient` | `ZygoteADGradient` | `MooncakeADGradient` | `DiffractorADGradient` | `TrackerADGradient` | `SymbolicsADGradient` | `ChainRulesADGradient` | `FastDifferentiationADGradient` | `FiniteDiffADGradient` | `FiniteDifferencesADGradient` | `PolyesterForwardDiffADGradient` |
| $J_c(x)*v$ | `ForwardDiffADJprod` | `ReverseDiffADJprod` | `EnzymeADJprod` | `ZygoteADJprod` | `MooncakeADJprod` | `DiffractorADJprod` | `TrackerADJprod` | `SymbolicsADJprod` | `ChainRulesADJprod` | `FastDifferentiationADJprod` | `FiniteDiffADJprod` | `FiniteDifferencesADJprod` | `PolyesterForwardDiffADJprod` |
| $J_c(x)^T*v$ | `ForwardDiffADJtprod` | `ReverseDiffADJtprod` | `EnzymeADJtprod` | `ZygoteADJtprod` | `MooncakeADJtprod` | `DiffractorADJtprod` | `TrackerADJtprod` | `SymbolicsADJtprod` | `ChainRulesADJtprod` | `FastDifferentiationADJtprod` | `FiniteDiffADJtprod` | `FiniteDifferencesADJtprod` | `PolyesterForwardDiffADJtprod` |
| $J_c(x)$ | `ForwardDiffADJacobian` | `ReverseDiffADJacobian` | `EnzymeADJacobian` | `ZygoteADJacobian` | `MooncakeADJacobian` | `DiffractorADJacobian` | `TrackerADJacobian` | `SymbolicsADJacobian` | `ChainRulesADJacobian` | `FastDifferentiationADJacobian` | `FiniteDiffADJacobian` | `FiniteDifferencesADJacobian` | `PolyesterForwardDiffADJacobian` |
| $\nabla^2 \mathcal{L}(x)*v$ | `ForwardDiffADHvprod` | `ReverseDiffADHvprod` | `EnzymeADHvprod` | `ZygoteADHvprod` | `MooncakeADHvprod` | `DiffractorADHvprod` | `TrackerADHvprod` | `SymbolicsADHvprod` | `ChainRulesADHvprod` | `FastDifferentiationADHvprod` | `FiniteDiffADHvprod` | `FiniteDifferencesADHvprod` | `PolyesterForwardDiffADHvprod` |
| $\nabla^2 \mathcal{L}(x)$ | `ForwardDiffADHessian` | `ReverseDiffADHessian` | `EnzymeADHessian` | `ZygoteADHessian` | `MooncakeADHessian` | `DiffractorADHessian` | `TrackerADHessian` | `SymbolicsADHessian` | `ChainRulesADHessian` | `FastDifferentiationADHessian` | `FiniteDiffADHessian` | `FiniteDifferencesADHessian` | `PolyesterForwardDiffADHessian` |

Except for the backends based on `ForwardDiff.jl` and `ReverseDiff.jl`, all other backends require the associated AD package to be manually installed by the user to work.
Note that the jacobians and hessians computed by the backends above are dense.
The backends `SparseADJacobian`, `SparseADHessian` and `SparseReverseADHessian` are available if sparse jacobians and hessians are needed.

```@example ex1
using ADNLPModels
Expand Down
1 change: 1 addition & 0 deletions test/backend/ChainRules.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
1 change: 1 addition & 0 deletions test/backend/Diffractor.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
1 change: 1 addition & 0 deletions test/backend/Enzyme.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
1 change: 1 addition & 0 deletions test/backend/FastDifferentiation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
1 change: 1 addition & 0 deletions test/backend/FiniteDiff.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
1 change: 1 addition & 0 deletions test/backend/FiniteDifferences.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
1 change: 1 addition & 0 deletions test/backend/ForwardDiff.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
1 change: 1 addition & 0 deletions test/backend/Mooncake.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
1 change: 1 addition & 0 deletions test/backend/PolyesterForwardDiff.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
1 change: 1 addition & 0 deletions test/backend/ReverseDiff.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
1 change: 1 addition & 0 deletions test/backend/Symbolics.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
1 change: 1 addition & 0 deletions test/backend/Tracker.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
1 change: 1 addition & 0 deletions test/backend/Zygote.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("utils.jl")
Empty file added test/backend/utils.jl
Empty file.
File renamed without changes.

0 comments on commit 4b51746

Please sign in to comment.