From 4b517468feb7cc61378f7cccb8968fb1f6301d1e Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Wed, 25 Sep 2024 19:09:25 -0500 Subject: [PATCH] Update pipeline.yml --- .buildkite/pipeline.yml | 183 ++++++++++++++++++++++++++- docs/Project.toml | 8 +- docs/src/backend.md | 25 ++-- test/backend/ChainRules.jl | 1 + test/backend/Diffractor.jl | 1 + test/backend/Enzyme.jl | 1 + test/backend/FastDifferentiation.jl | 1 + test/backend/FiniteDiff.jl | 1 + test/backend/FiniteDifferences.jl | 1 + test/backend/ForwardDiff.jl | 1 + test/backend/Mooncake.jl | 1 + test/backend/PolyesterForwardDiff.jl | 1 + test/backend/ReverseDiff.jl | 1 + test/backend/Symbolics.jl | 1 + test/backend/Tracker.jl | 1 + test/backend/Zygote.jl | 1 + test/backend/utils.jl | 0 test/{gpu.jl => gpu/nvidia.jl} | 0 18 files changed, 212 insertions(+), 17 deletions(-) create mode 100644 test/backend/ChainRules.jl create mode 100644 test/backend/Diffractor.jl create mode 100644 test/backend/Enzyme.jl create mode 100644 test/backend/FastDifferentiation.jl create mode 100644 test/backend/FiniteDiff.jl create mode 100644 test/backend/FiniteDifferences.jl create mode 100644 test/backend/ForwardDiff.jl create mode 100644 test/backend/Mooncake.jl create mode 100644 test/backend/PolyesterForwardDiff.jl create mode 100644 test/backend/ReverseDiff.jl create mode 100644 test/backend/Symbolics.jl create mode 100644 test/backend/Tracker.jl create mode 100644 test/backend/Zygote.jl create mode 100644 test/backend/utils.jl rename test/{gpu.jl => gpu/nvidia.jl} (100%) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 18248789..2d22ffb3 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -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")' diff --git a/docs/Project.toml b/docs/Project.toml index 2d003cbd..57ff01f6 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -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" diff --git a/docs/src/backend.md b/docs/src/backend.md index 6c4a5a85..d21d3e90 100644 --- a/docs/src/backend.md +++ b/docs/src/backend.md @@ -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 diff --git a/test/backend/ChainRules.jl b/test/backend/ChainRules.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/ChainRules.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/Diffractor.jl b/test/backend/Diffractor.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/Diffractor.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/Enzyme.jl b/test/backend/Enzyme.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/Enzyme.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/FastDifferentiation.jl b/test/backend/FastDifferentiation.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/FastDifferentiation.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/FiniteDiff.jl b/test/backend/FiniteDiff.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/FiniteDiff.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/FiniteDifferences.jl b/test/backend/FiniteDifferences.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/FiniteDifferences.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/ForwardDiff.jl b/test/backend/ForwardDiff.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/ForwardDiff.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/Mooncake.jl b/test/backend/Mooncake.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/Mooncake.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/PolyesterForwardDiff.jl b/test/backend/PolyesterForwardDiff.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/PolyesterForwardDiff.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/ReverseDiff.jl b/test/backend/ReverseDiff.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/ReverseDiff.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/Symbolics.jl b/test/backend/Symbolics.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/Symbolics.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/Tracker.jl b/test/backend/Tracker.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/Tracker.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/Zygote.jl b/test/backend/Zygote.jl new file mode 100644 index 00000000..66af2bf4 --- /dev/null +++ b/test/backend/Zygote.jl @@ -0,0 +1 @@ +include("utils.jl") diff --git a/test/backend/utils.jl b/test/backend/utils.jl new file mode 100644 index 00000000..e69de29b diff --git a/test/gpu.jl b/test/gpu/nvidia.jl similarity index 100% rename from test/gpu.jl rename to test/gpu/nvidia.jl