Skip to content
Closed
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
6 changes: 5 additions & 1 deletion .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
group:
- ChainRules
- DifferentiateWith
# - Diffractor
- Diffractor
- Enzyme
- FastDifferentiation
- FiniteDiff
Expand All @@ -111,6 +111,10 @@ jobs:
exclude:
- skip_past: true
version: '1.10'
- version: '1.12'
group: Diffractor
- version: '1.13'
group: Diffractor
env:
JULIA_DI_TEST_TYPE: 'Back'
JULIA_DI_TEST_GROUP: ${{ matrix.group }}
Expand Down
1 change: 1 addition & 0 deletions DifferentiationInterface/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Speed up `pick_batchsize` when the batch size is only known at run time ([#1076](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/1076))
- Restore Diffractor support on Julia 1.10 and 1.11 by working around a broadcasting bug ([#1079](https://github.com/JuliaDiff/DifferentiationInterface.jl/pull/1079))

## [0.7.21](https://github.com/JuliaDiff/DifferentiationInterface.jl/compare/DifferentiationInterface-v0.7.20...v0.7.21)

Expand Down
2 changes: 1 addition & 1 deletion DifferentiationInterface/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Adapt = "4.5.0"
ADTypes = "1.23.0"
ChainRulesCore = "1.23.0"
DiffResults = "1.1.0"
Diffractor = "=0.2.6"
Diffractor = "=0.2.10"
Enzyme = "0.13.39"
EnzymeCore = "0.8.8"
FastDifferentiation = "0.4.3"
Expand Down
2 changes: 1 addition & 1 deletion DifferentiationInterface/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This package provides a unified syntax to differentiate functions, including:
We support the following backends defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl):

- [ChainRulesCore.jl](https://github.com/JuliaDiff/ChainRulesCore.jl)
- [Diffractor.jl](https://github.com/JuliaDiff/Diffractor.jl) (currently broken)
- [Diffractor.jl](https://github.com/JuliaDiff/Diffractor.jl) (only on Julia 1.10 and 1.11)
- [Enzyme.jl](https://github.com/EnzymeAD/Enzyme.jl) (see below)
- [FastDifferentiation.jl](https://github.com/brianguenter/FastDifferentiation.jl)
- [FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl)
Expand Down
5 changes: 3 additions & 2 deletions DifferentiationInterface/docs/src/explanation/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ Same-point preparation runs the forward sweep and returns the pullback closure.

We only implement `pushforward`.

!!! danger
!!! warning

The latest releases of Diffractor [broke DifferentiationInterface](https://github.com/JuliaDiff/Diffractor.jl/issues/290).
The latest release of Diffractor (v0.2.10) cannot be loaded on Julia 1.12 and above, so this backend only works on Julia 1.10 and 1.11.
To make broadcasting work, our extension has to patch [a Diffractor bug](https://github.com/JuliaDiff/Diffractor.jl/issues/290) with a bit of type piracy.

### Enzyme

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ module DifferentiationInterfaceDiffractorExt

using ADTypes: ADTypes, AutoDiffractor
import DifferentiationInterface as DI
using Diffractor: DiffractorRuleConfig, TaylorTangentIndex, ZeroBundle, bundle, ∂☆
using Diffractor:
Diffractor, AbstractTangentBundle, FwdMap, TaylorTangentIndex, ZeroBundle, bundle, ∂☆

#=
Workaround for https://github.com/JuliaDiff/Diffractor.jl/issues/290 (type piracy).
The forward broadcast rule of Diffractor v0.2.7 to v0.2.10 calls `FwdMap{E}(f)` instead of `FwdMap{N,E}(f)`, which has no method.
=#
function Diffractor.FwdMap{E}(f::T) where {E, N, T <: AbstractTangentBundle{N}}
return FwdMap{N, E, T}(f)
end

DI.check_available(::AutoDiffractor) = true
DI.inplace_support(::AutoDiffractor) = DI.InPlaceNotSupported()
Expand Down
12 changes: 12 additions & 0 deletions DifferentiationInterface/test/Back/Diffractor/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
DifferentiationInterfaceTest = "a82114a7-5aa3-49a8-9643-716bb13727a3"
Diffractor = "9f5e2b26-1114-432f-b630-d3fe2085c51c"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources]
DifferentiationInterface = { path = "../../.." }
26 changes: 26 additions & 0 deletions DifferentiationInterface/test/Back/Diffractor/test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
include("../../testutils.jl")

using DifferentiationInterface, DifferentiationInterfaceTest
using Diffractor: Diffractor
using Test

using ExplicitImports
check_no_implicit_imports(DifferentiationInterface)

for backend in [AutoDiffractor()]
@test check_available(backend)
@test !check_inplace(backend)
end

@testset "Broadcast" begin
# https://github.com/JuliaDiff/Diffractor.jl/issues/290
x, dx = [1.0, 2.0], [3.0, 4.0]
@test pushforward(x -> sin.(x), AutoDiffractor(), x, (dx,))[1] ≈ cos.(x) .* dx
end

test_differentiation(
AutoDiffractor(),
default_scenarios(; linalg = false);
excluded = SECOND_ORDER,
logging = LOGGING,
);
Loading