Skip to content

Commit 7d1fbc1

Browse files
authored
Create monorepo (#136)
* Move everything * More moving around * More moving * Try out tests * Try with docs * Rename * Fix codecov * De-toggle tests * Remove Manifests * Remove all Manifests * License symlinks * Remove index * Rm test true * Semicolons * Interpolation * Dev both at once * Fix parse * Unique * Ahem * Bracket * Add Licenses, untoggle tests * Tag prefix * Manual buildpkg * Clean up * Fix
1 parent 2ee1bf1 commit 7d1fbc1

95 files changed

Lines changed: 470 additions & 324 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/CI.yml

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
name: CI
2+
23
on:
34
push:
45
branches:
56
- main
67
tags: ['*']
78
pull_request:
89
workflow_dispatch:
10+
911
concurrency:
1012
# Skip intermediate builds: always.
1113
# Cancel intermediate builds: only if it is a pull request build.
1214
group: ${{ github.workflow }}-${{ github.ref }}
1315
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
16+
1417
jobs:
18+
1519
test:
16-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
20+
name: Test - ${{ matrix.pkg.name }} - Julia ${{ matrix.version }}
1721
runs-on: ${{ matrix.os }}
1822
timeout-minutes: 60
1923
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
@@ -22,59 +26,76 @@ jobs:
2226
strategy:
2327
fail-fast: false
2428
matrix:
29+
pkg:
30+
- name: DifferentiationInterface
31+
dir: './DifferentiationInterface'
32+
- name: DifferentiationInterfaceTest
33+
dir: './DifferentiationInterfaceTest'
2534
version:
2635
- '1.10'
2736
os:
2837
- ubuntu-latest
2938
arch:
3039
- x64
40+
3141
steps:
3242
- uses: actions/checkout@v4
3343
- uses: julia-actions/setup-julia@v1
3444
with:
3545
version: ${{ matrix.version }}
3646
arch: ${{ matrix.arch }}
3747
- uses: julia-actions/cache@v1
38-
- uses: julia-actions/julia-buildpkg@v1
48+
- name: Install dependencies (replaces buildpkg)
49+
run: julia --project=${{ matrix.pkg.dir}}/ -e '
50+
using Pkg;
51+
if "${{ matrix.pkg.name}}" == "DifferentiationInterfaceTest";
52+
Pkg.develop(PackageSpec(path="./DifferentiationInterface"));
53+
end;
54+
Pkg.instantiate();'
3955
- uses: julia-actions/julia-runtest@v1
56+
with:
57+
project: ${{ matrix.pkg.dir }}
4058
- uses: julia-actions/julia-processcoverage@v1
4159
with:
42-
directories: src,ext,lib
60+
directories: ${{ matrix.pkg.dir }}/src,${{ matrix.pkg.dir }}/ext
4361
- uses: codecov/codecov-action@v4
4462
with:
4563
files: lcov.info
4664
token: ${{ secrets.CODECOV_TOKEN }}
4765
fail_ci_if_error: true
66+
4867
docs:
49-
name: Documentation
68+
name: Docs - ${{ matrix.pkg.name }}
5069
runs-on: ubuntu-latest
5170
permissions:
52-
actions: write # needed to allow julia-actions/cache to proactively delete old caches that it has created
5371
contents: write
5472
statuses: write
73+
strategy:
74+
fail-fast: false
75+
matrix:
76+
pkg:
77+
- name: DifferentiationInterface
78+
dir: './DifferentiationInterface'
79+
- name: DifferentiationInterfaceTest
80+
dir: './DifferentiationInterfaceTest'
81+
5582
steps:
5683
- uses: actions/checkout@v4
5784
- uses: julia-actions/setup-julia@v1
5885
with:
5986
version: '1'
6087
- uses: julia-actions/cache@v1
61-
- name: Configure doc environment
62-
shell: julia --project=docs --color=yes {0}
63-
run: |
64-
using Pkg
65-
Pkg.Registry.update() # TODO: remove? useful for fresh releases
66-
Pkg.develop(PackageSpec(path=pwd()))
67-
Pkg.develop(PackageSpec(path=joinpath(pwd(), "lib", "DifferentiationInterfaceTest")))
68-
Pkg.instantiate()
69-
- uses: julia-actions/julia-buildpkg@v1
70-
- uses: julia-actions/julia-docdeploy@v1
88+
- name: Install dependencies
89+
run: julia --project=${{ matrix.pkg.dir}}/docs/ -e '
90+
using Pkg;
91+
if "${{ matrix.pkg.name}}" == "DifferentiationInterface";
92+
Pkg.develop(PackageSpec(path="./DifferentiationInterface"));
93+
else;
94+
Pkg.develop([PackageSpec(path="./DifferentiationInterface"), PackageSpec(path="${{ matrix.pkg.dir}}")]);
95+
end;
96+
Pkg.instantiate();'
97+
- name: Build and deploy
7198
env:
72-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73-
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
74-
- name: Run doctests
75-
shell: julia --project=docs --color=yes {0}
76-
run: |
77-
using Documenter: DocMeta, doctest
78-
using DifferentiationInterface
79-
DocMeta.setdocmeta!(DifferentiationInterface, :DocTestSetup, :(using DifferentiationInterface); recursive=true)
80-
doctest(DifferentiationInterface)
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
100+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
101+
run: julia --project=${{ matrix.pkg.dir}}/docs/ ${{ matrix.pkg.dir}}/docs/make.jl

.github/workflows/CompatHelper.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ jobs:
1313
env:
1414
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1515
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
16-
run: julia -e 'using CompatHelper; CompatHelper.main()'
16+
run: julia -e 'using CompatHelper; CompatHelper.main(subdirs=["DifferentiationInterface", "DifferentiationInterfaceTest"])'
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Doc Preview Cleanup
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
# Ensure that only one "Doc Preview Cleanup" workflow is force pushing at a time
8+
concurrency:
9+
group: doc-preview-cleanup
10+
cancel-in-progress: false
11+
12+
jobs:
13+
doc-preview-cleanup:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
steps:
18+
- name: Checkout gh-pages branch
19+
uses: actions/checkout@v4
20+
with:
21+
ref: gh-pages
22+
- name: Delete preview and history + push changes
23+
run: |
24+
if [ -d "${preview_dir}" ]; then
25+
git config user.name "Documenter.jl"
26+
git config user.email "documenter@juliadocs.github.io"
27+
git rm -rf "${preview_dir}"
28+
git commit -m "delete preview"
29+
git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree})
30+
git push --force origin gh-pages-new:gh-pages
31+
fi
32+
env:
33+
preview_dir: previews/PR${{ github.event.number }}

.github/workflows/TagBot.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
*.jl.cov
33
*.jl.mem
44

5-
/.benchmarkci
6-
/benchmark/*.json
5+
**/docs/build/
6+
**/docs/src/index.md
77

8-
/docs/build/
9-
/docs/src/index.md
10-
11-
Manifest.toml
8+
**/Manifest.toml
9+
**/docs/Manifest.toml
1210

1311
*.csv

DifferentiationInterface/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Guillaume Dalle, Adrian Hill
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
2828

2929
[extensions]
3030
DifferentiationInterfaceChainRulesCoreExt = "ChainRulesCore"
31-
DifferentiationInterfaceDiffractorExt = ["AbstractDifferentiation", "Diffractor"]
31+
DifferentiationInterfaceDiffractorExt = [
32+
"AbstractDifferentiation",
33+
"Diffractor",
34+
]
3235
DifferentiationInterfaceEnzymeExt = "Enzyme"
3336
DifferentiationInterfaceFastDifferentiationExt = "FastDifferentiation"
3437
DifferentiationInterfaceFiniteDiffExt = "FiniteDiff"
@@ -67,8 +70,6 @@ julia = "1.10"
6770
[extras]
6871
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
6972
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
70-
Chairmarks = "0ca39b1e-fe0b-4e98-acfc-b1656634c4de"
71-
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
7273
Diffractor = "9f5e2b26-1114-432f-b630-d3fe2085c51c"
7374
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
7475
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
@@ -90,4 +91,26 @@ Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
9091
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
9192

9293
[targets]
93-
test = ["ADTypes", "Aqua", "Chairmarks", "DataFrames", "Diffractor", "Documenter", "Enzyme", "FastDifferentiation", "FiniteDiff", "FiniteDifferences", "ForwardDiff", "JET", "JuliaFormatter", "Pkg", "PolyesterForwardDiff", "ReverseDiff", "SparseArrays", "SparseDiffTools", "Symbolics", "Tapir", "Test", "Tracker", "Zygote"]
94+
test = [
95+
"ADTypes",
96+
"Aqua",
97+
"Diffractor",
98+
"Documenter",
99+
"Enzyme",
100+
"FastDifferentiation",
101+
"FiniteDiff",
102+
"FiniteDifferences",
103+
"ForwardDiff",
104+
"JET",
105+
"JuliaFormatter",
106+
"Pkg",
107+
"PolyesterForwardDiff",
108+
"ReverseDiff",
109+
"SparseArrays",
110+
"SparseDiffTools",
111+
"Symbolics",
112+
"Tapir",
113+
"Test",
114+
"Tracker",
115+
"Zygote",
116+
]

DifferentiationInterface/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# DifferentiationInterface
2+
3+
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://gdalle.github.io/DifferentiationInterface.jl/DifferentiationInterface/dev/)
4+
[![Build Status](https://github.com/gdalle/DifferentiationInterface.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/gdalle/DifferentiationInterface.jl/actions/workflows/CI.yml?query=branch%3Amain)
5+
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
6+
7+
An interface to various automatic differentiation (AD) backends in Julia.
8+
9+
## Goal
10+
11+
This package provides a backend-agnostic syntax to differentiate functions of the following types:
12+
13+
- _allocating_: `f(x) = y`
14+
- _mutating_: `f!(y, x) = nothing`
15+
16+
## Features
17+
18+
- First and second order operators
19+
- In-place and out-of-place differentiation
20+
- Preparation mechanism (e.g. to create a config or tape)
21+
- Thorough validation on standard inputs and outputs (scalars, vectors, matrices)
22+
- Testing and benchmarking utilities accessible to users with [DifferentiationInterfaceTest](https://gdalle.github.io/DifferentiationInterface.jl/DifferentiationInterfaceTest/)
23+
24+
## Compatibility
25+
26+
We support most of the backends defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl):
27+
28+
| backend | object |
29+
| :------------------------------------------------------------------------------ | :--------------------------------------------------------- |
30+
| [ChainRulesCore.jl](https://github.com/JuliaDiff/ChainRulesCore.jl) | `AutoChainRules(ruleconfig)` |
31+
| [Diffractor.jl](https://github.com/JuliaDiff/Diffractor.jl) | `AutoDiffractor()` |
32+
| [Enzyme.jl](https://github.com/EnzymeAD/Enzyme.jl) | `AutoEnzyme(Enzyme.Forward)`, `AutoEnzyme(Enzyme.Reverse)` |
33+
| [FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl) | `AutoFiniteDiff()` |
34+
| [FiniteDifferences.jl](https://github.com/JuliaDiff/FiniteDifferences.jl) | `AutoFiniteDifferences(fdm)` |
35+
| [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) | `AutoForwardDiff()` |
36+
| [PolyesterForwardDiff.jl](https://github.com/JuliaDiff/PolyesterForwardDiff.jl) | `AutoPolyesterForwardDiff(; chunksize)` |
37+
| [ReverseDiff.jl](https://github.com/JuliaDiff/ReverseDiff.jl) | `AutoReverseDiff()` |
38+
| [SparseDiffTools.jl](https://github.com/JuliaDiff/SparseDiffTools.jl) | `AutoSparseForwardDiff()`, `AutoSparseFiniteDiff()` |
39+
| [Tracker.jl](https://github.com/FluxML/Tracker.jl) | `AutoTracker()` |
40+
| [Zygote.jl](https://github.com/FluxML/Zygote.jl) | `AutoZygote()` |
41+
42+
We also provide some experimental backends ourselves:
43+
44+
| backend | object |
45+
| :------------------------------------------------------------------------------- | :------------------------------------------------------------- |
46+
| [FastDifferentiation.jl](https://github.com/brianguenter/FastDifferentiation.jl) | `AutoFastDifferentiation()`, `AutoSparseFastDifferentiation()` |
47+
| [Tapir.jl](https://github.com/withbayes/Tapir.jl) | `AutoTapir()` |
48+
49+
## Example
50+
51+
```jldoctest readme
52+
julia> import ForwardDiff
53+
54+
julia> using DifferentiationInterface
55+
56+
julia> backend = AutoForwardDiff();
57+
58+
julia> f(x) = sum(abs2, x);
59+
60+
julia> value_and_gradient(f, backend, [1., 2., 3.])
61+
(14.0, [2.0, 4.0, 6.0])
62+
```
63+
64+
## Related packages
65+
66+
- [AbstractDifferentiation.jl](https://github.com/JuliaDiff/AbstractDifferentiation.jl) is the original inspiration for DifferentiationInterface.jl.
67+
- [AutoDiffOperators.jl](https://github.com/oschulz/AutoDiffOperators.jl) is an attempt to bridge ADTypes.jl with AbstractDifferentiation.jl.

docs/Project.toml renamed to DifferentiationInterface/docs/Project.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
33
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
44
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
5-
Chairmarks = "0ca39b1e-fe0b-4e98-acfc-b1656634c4de"
6-
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
75
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
86
Diffractor = "9f5e2b26-1114-432f-b630-d3fe2085c51c"
97
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
@@ -17,12 +15,10 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1715
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
1816
PolyesterForwardDiff = "98d1487c-24ca-40b6-b7ab-df2af84e126b"
1917
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
20-
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2118
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
2219
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
2320
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
2421
Tapir = "07d77754-e150-4737-8c94-cd238a1fb45b"
25-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2622
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
2723
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
2824

0 commit comments

Comments
 (0)