Skip to content

Commit 08d5708

Browse files
authored
chore: format Markdown and docstrings (#838)
* chore: format markdown * Apply new formatter
1 parent 63820d4 commit 08d5708

32 files changed

Lines changed: 330 additions & 293 deletions

.JuliaFormatter.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
style = "blue"
2-
align_assignment = true
3-
align_struct_field = true
4-
align_conditional = true
5-
align_pair_arrow = true
6-
align_matrix = true
2+
format_docstrings = true
3+
format_markdown = true

.pre-commit-config.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
33
rev: v3.2.0
44
hooks:
5-
- id: trailing-whitespace
6-
- id: end-of-file-fixer
75
- id: check-yaml
86
- id: check-added-large-files
97
- id: check-merge-conflict

DifferentiationInterface/CHANGELOG.md

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,92 +5,67 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## [Unreleased](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.5...main)
99

10-
## [0.7.5]
10+
## [0.7.5](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.4...DifferentiationInterface-v0.7.5)
1111

1212
### Added
1313

14-
- Support forward-mode Mooncake with `AutoMooncakeForward` ([#813])
14+
- Support forward-mode Mooncake with `AutoMooncakeForward` ([#813](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/813))
1515

16-
## [0.7.4]
16+
## [0.7.4](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.3...DifferentiationInterface-v0.7.4)
1717

1818
### Added
1919

20-
- Make `AutoForwardFromPrimitive` and `AutoReverseFromPrimitive` public ([#825])
20+
- Make `AutoForwardFromPrimitive` and `AutoReverseFromPrimitive` public ([#825](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/825))
2121

2222
### Fixed
2323

24-
- Replace `one` with `oneunit` in basis computation ([#826])
24+
- Replace `one` with `oneunit` in basis computation ([#826](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/826))
2525

26-
## [0.7.3]
26+
## [0.7.3](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.2...DifferentiationInterface-v0.7.3)
2727

2828
### Fixed
2929

30-
- Bump compat for SparseConnectivityTracer v1 ([#823])
30+
- Bump compat for SparseConnectivityTracer v1 ([#823](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/823))
3131

32-
## [0.7.2]
32+
## [0.7.2](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.1...DifferentiationInterface-v0.7.2)
3333

3434
### Feat
3535

36-
- Backend switching for Mooncake ([#768])
36+
- Backend switching for Mooncake ([#768](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/768))
3737

3838
### Fixed
3939

40-
- Speed up sparse preparation for GPU arrays ([#818])
40+
- Speed up sparse preparation for GPU arrays ([#818](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/818))
4141

42-
## [0.7.1]
42+
## [0.7.1](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.0...DifferentiationInterface-v0.7.1)
4343

4444
### Feat
4545

46-
- Use Mooncake's internal copy utilities ([#809])
46+
- Use Mooncake's internal copy utilities ([#809](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/809))
4747

4848
### Fixed
4949

50-
- Take `absstep` into account for FiniteDiff ([#812])
51-
- Make basis work for `CuArray` ([#810])
50+
- Take `absstep` into account for FiniteDiff ([#812](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/812))
51+
- Make basis work for `CuArray` ([#810](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/810))
5252

53-
## [0.7.0]
53+
## [0.7.0](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.6.54...DifferentiationInterface-v0.7.0)
5454

5555
### Changed
5656

57-
- Preparation is now strict by default ([#799])
58-
- New Arxiv preprint for citation ([#795])
57+
- Preparation is now strict by default ([#799](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/799))
58+
- New Arxiv preprint for citation ([#795](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/795))
5959

60-
## [0.6.54] - 2025-05-11
60+
## [0.6.54](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.6.53...DifferentiationInterface-v0.6.54) - 2025-05-11
6161

6262
### Added
6363

64-
- Dependency compat bounds for extras ([#790])
65-
- Error hints for Enzyme ([#788])
64+
- Dependency compat bounds for extras ([#790](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/790))
65+
- Error hints for Enzyme ([#788](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/788))
6666

67-
## [0.6.53] - 2025-05-07
67+
## [0.6.53](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.6.52...DifferentiationInterface-v0.6.53) - 2025-05-07
6868

6969
### Changed
7070

71-
- Allocate Enzyme shadow memory during preparation ([#782])
72-
73-
[unreleased]: https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.5...main
74-
[0.7.5]: https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.4...DifferentiationInterface-v0.7.5
75-
[0.7.4]: https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.3...DifferentiationInterface-v0.7.4
76-
[0.7.3]: https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.2...DifferentiationInterface-v0.7.3
77-
[0.7.2]: https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.1...DifferentiationInterface-v0.7.2
78-
[0.7.1]: https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.0...DifferentiationInterface-v0.7.1
79-
[0.7.0]: https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.6.54...DifferentiationInterface-v0.7.0
80-
[0.6.54]: https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.6.53...DifferentiationInterface-v0.6.54
81-
[0.6.53]: https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.6.52...DifferentiationInterface-v0.6.53
82-
83-
[#826]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/826
84-
[#825]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/825
85-
[#823]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/823
86-
[#818]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/818
87-
[#813]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/813
88-
[#812]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/812
89-
[#810]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/810
90-
[#809]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/809
91-
[#799]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/799
92-
[#795]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/795
93-
[#790]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/790
94-
[#788]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/788
95-
[#782]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/782
96-
[#768]: https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/768
71+
- Allocate Enzyme shadow memory during preparation ([#782](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/782))

DifferentiationInterface/README.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
[![Build Status](https://github.com/JuliaDiff/DifferentiationInterface.jl/actions/workflows/Test.yml/badge.svg?branch=main)](https://github.com/JuliaDiff/DifferentiationInterface.jl/actions/workflows/Test.yml?query=branch%3Amain)
66
[![Coverage](https://codecov.io/gh/JuliaDiff/DifferentiationInterface.jl/branch/main/graph/badge.svg?flag=DI)](https://app.codecov.io/gh/JuliaDiff/DifferentiationInterface.jl)
77
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/JuliaDiff/BlueStyle)
8-
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
8+
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
99
[![DOI](https://zenodo.org/badge/740973714.svg)](https://zenodo.org/doi/10.5281/zenodo.11092033)
1010

11-
| Package | Docs |
12-
| :--------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
13-
| DifferentiationInterface | [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/stable/) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/dev/) |
11+
| Package | Docs |
12+
|:----------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
13+
| DifferentiationInterface | [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/stable/) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/dev/) |
1414
| DifferentiationInterfaceTest | [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterfaceTest/stable/) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterfaceTest/dev/) |
1515

1616
An interface to various automatic differentiation (AD) backends in Julia.
@@ -19,31 +19,31 @@ An interface to various automatic differentiation (AD) backends in Julia.
1919

2020
This package provides a unified syntax to differentiate functions, including:
2121

22-
- First- and second-order operators (gradients, Jacobians, Hessians and more)
23-
- In-place and out-of-place differentiation
24-
- Preparation mechanism (e.g. to pre-allocate a cache or record a tape)
25-
- Built-in sparsity handling
26-
- Thorough validation on standard inputs and outputs (numbers, vectors, matrices)
27-
- Testing and benchmarking utilities accessible to users with [DifferentiationInterfaceTest](https://github.com/JuliaDiff/DifferentiationInterface.jl/tree/main/DifferentiationInterfaceTest)
22+
- First- and second-order operators (gradients, Jacobians, Hessians and more)
23+
- In-place and out-of-place differentiation
24+
- Preparation mechanism (e.g. to pre-allocate a cache or record a tape)
25+
- Built-in sparsity handling
26+
- Thorough validation on standard inputs and outputs (numbers, vectors, matrices)
27+
- Testing and benchmarking utilities accessible to users with [DifferentiationInterfaceTest](https://github.com/JuliaDiff/DifferentiationInterface.jl/tree/main/DifferentiationInterfaceTest)
2828

2929
## Compatibility
3030

3131
We support the following backends defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl):
3232

33-
- [ChainRulesCore.jl](https://github.com/JuliaDiff/ChainRulesCore.jl)
34-
- [Diffractor.jl](https://github.com/JuliaDiff/Diffractor.jl) (currently broken)
35-
- [Enzyme.jl](https://github.com/EnzymeAD/Enzyme.jl) (see below)
36-
- [FastDifferentiation.jl](https://github.com/brianguenter/FastDifferentiation.jl)
37-
- [FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl)
38-
- [FiniteDifferences.jl](https://github.com/JuliaDiff/FiniteDifferences.jl)
39-
- [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl)
40-
- [GTPSA.jl](https://github.com/bmad-sim/GTPSA.jl)
41-
- [Mooncake.jl](https://github.com/chalk-lab/Mooncake.jl)
42-
- [PolyesterForwardDiff.jl](https://github.com/JuliaDiff/PolyesterForwardDiff.jl)
43-
- [ReverseDiff.jl](https://github.com/JuliaDiff/ReverseDiff.jl)
44-
- [Symbolics.jl](https://github.com/JuliaSymbolics/Symbolics.jl)
45-
- [Tracker.jl](https://github.com/FluxML/Tracker.jl)
46-
- [Zygote.jl](https://github.com/FluxML/Zygote.jl)
33+
- [ChainRulesCore.jl](https://github.com/JuliaDiff/ChainRulesCore.jl)
34+
- [Diffractor.jl](https://github.com/JuliaDiff/Diffractor.jl) (currently broken)
35+
- [Enzyme.jl](https://github.com/EnzymeAD/Enzyme.jl) (see below)
36+
- [FastDifferentiation.jl](https://github.com/brianguenter/FastDifferentiation.jl)
37+
- [FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl)
38+
- [FiniteDifferences.jl](https://github.com/JuliaDiff/FiniteDifferences.jl)
39+
- [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl)
40+
- [GTPSA.jl](https://github.com/bmad-sim/GTPSA.jl)
41+
- [Mooncake.jl](https://github.com/chalk-lab/Mooncake.jl)
42+
- [PolyesterForwardDiff.jl](https://github.com/JuliaDiff/PolyesterForwardDiff.jl)
43+
- [ReverseDiff.jl](https://github.com/JuliaDiff/ReverseDiff.jl)
44+
- [Symbolics.jl](https://github.com/JuliaSymbolics/Symbolics.jl)
45+
- [Tracker.jl](https://github.com/FluxML/Tracker.jl)
46+
- [Zygote.jl](https://github.com/FluxML/Zygote.jl)
4747

4848
> [!CAUTION]
4949
> 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](https://enzymead.github.io/Enzyme.jl/stable/) instead.
@@ -63,25 +63,27 @@ To install the development version, run this instead:
6363
```julia
6464
using Pkg
6565

66-
Pkg.add(
66+
Pkg.add(;
6767
url="https://github.com/JuliaDiff/DifferentiationInterface.jl",
68-
subdir="DifferentiationInterface"
68+
subdir="DifferentiationInterface",
6969
)
7070
```
7171

7272
## Example
7373

7474
```julia
7575
using DifferentiationInterface
76-
import ForwardDiff, Enzyme, Zygote # AD backends you want to use
76+
using ForwardDiff: ForwardDiff
77+
using Enzyme: Enzyme
78+
using Zygote: Zygote # AD backends you want to use
7779

7880
f(x) = sum(abs2, x)
7981

8082
x = [1.0, 2.0]
8183

8284
value_and_gradient(f, AutoForwardDiff(), x) # returns (5.0, [2.0, 4.0]) with ForwardDiff.jl
83-
value_and_gradient(f, AutoEnzyme(), x) # returns (5.0, [2.0, 4.0]) with Enzyme.jl
84-
value_and_gradient(f, AutoZygote(), x) # returns (5.0, [2.0, 4.0]) with Zygote.jl
85+
value_and_gradient(f, AutoEnzyme(), x) # returns (5.0, [2.0, 4.0]) with Enzyme.jl
86+
value_and_gradient(f, AutoZygote(), x) # returns (5.0, [2.0, 4.0]) with Zygote.jl
8587
```
8688

8789
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.
@@ -90,8 +92,8 @@ To improve your performance by up to several orders of magnitude compared to thi
9092

9193
Whenever you refer to this package or the ideas it contains, please cite:
9294

93-
1. our preprint [*A Common Interface for Automatic Differentiation*](https://arxiv.org/abs/2505.05542);
94-
2. our inspiration [AbstractDifferentiation.jl](https://github.com/JuliaDiff/AbstractDifferentiation.jl).
95+
1. our preprint [*A Common Interface for Automatic Differentiation*](https://arxiv.org/abs/2505.05542);
96+
2. our inspiration [AbstractDifferentiation.jl](https://github.com/JuliaDiff/AbstractDifferentiation.jl).
9597

9698
You can use the provided [`CITATION.cff`](https://github.com/JuliaDiff/DifferentiationInterface.jl/blob/main/CITATION.cff) file or the following BibTeX entries:
9799

DifferentiationInterface/docs/src/assets/logo.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ end
1313
# ╔═╡ d1b44dac-8487-4581-82fd-ece0ce89f8e2
1414
begin
1515
const purple = Luxor.julia_purple
16-
const red = Luxor.julia_red
17-
const green = Luxor.julia_green
18-
const blue = Luxor.julia_blue
19-
const white = RGB(1, 1, 1)
20-
const black = RGB(0, 0, 0)
16+
const red = Luxor.julia_red
17+
const green = Luxor.julia_green
18+
const blue = Luxor.julia_blue
19+
const white = RGB(1, 1, 1)
20+
const black = RGB(0, 0, 0)
2121
const colors = (purple, red, green)
2222
end;
2323

DifferentiationInterface/docs/src/dev_guide.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ It is not part of the public API and the content below may become outdated, in w
77

88
The package is structured around 8 [operators](@ref Operators):
99

10-
- [`derivative`](@ref)
11-
- [`second_derivative`](@ref)
12-
- [`gradient`](@ref)
13-
- [`jacobian`](@ref)
14-
- [`hessian`](@ref)
15-
- [`pushforward`](@ref)
16-
- [`pullback`](@ref)
17-
- [`hvp`](@ref)
10+
- [`derivative`](@ref)
11+
- [`second_derivative`](@ref)
12+
- [`gradient`](@ref)
13+
- [`jacobian`](@ref)
14+
- [`hessian`](@ref)
15+
- [`pushforward`](@ref)
16+
- [`pullback`](@ref)
17+
- [`hvp`](@ref)
1818

1919
Most operators have 4 variants, which look like this in the first order: `operator`, `operator!`, `value_and_operator`, `value_and_operator!`.
2020

@@ -39,14 +39,15 @@ In the main package, you should define a new struct `SuperDiffBackend` which sub
3939
You also have to define [`ADTypes.mode`](@extref) and [`DifferentiationInterface.inplace_support`](@ref) on `SuperDiffBackend`.
4040

4141
!!! info
42+
4243
In the end, this backend struct will need to be contributed to [ADTypes.jl](https://github.com/SciML/ADTypes.jl).
4344
However, putting it in the DifferentiationInterface.jl PR is a good first step for debugging.
4445

4546
In a [package extension](https://pkgdocs.julialang.org/v1/creating-packages/#Conditional-loading-of-code-in-packages-(Extensions)) named `DifferentiationInterfaceSuperDiffExt`, you need to implement at least [`pushforward`](@ref) or [`pullback`](@ref) (and their variants).
4647
The exact requirements depend on the differentiation mode you chose:
4748

4849
| backend mode | pushforward necessary | pullback necessary |
49-
| :------------------------------------------------ | :-------------------- | :----------------- |
50+
|:------------------------------------------------- |:--------------------- |:------------------ |
5051
| [`ADTypes.ForwardMode`](@extref ADTypes) | yes | no |
5152
| [`ADTypes.ReverseMode`](@extref ADTypes) | no | yes |
5253
| [`ADTypes.ForwardOrReverseMode`](@extref ADTypes) | yes | yes |

0 commit comments

Comments
 (0)