-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
coreRelated to the core utilities of the packageRelated to the core utilities of the package
Description
Find this while implementing SciML/BoundaryValueDiffEq.jl#258
This MWE is just proof of the idea and may not be meaningful, but I think it can still prove that the current DI lacks support for sparse Jacobian of complex numbers.
using ForwardDiff, DifferentiationInterface, SparseMatrixColorings, ADTypes
const DI = DifferentiationInterface
#backend = AutoForwardDiff() # this works
backend = AutoSparse(
AutoForwardDiff(),
sparsity_detector = ADTypes.KnownJacobianSparsityDetector(ones(3, 3)),
coloring_algorithm = ConstantColoringAlgorithm(ones(3, 3), ones(Int64, 3))
)
u0 = [1.0; 0.0; 0.0] .+1im
jac_cache = DI.prepare_jacobian(nothing, similar(u0), backend, u0)
stack trace
ERROR: MethodError: no method matching DifferentiationInterfaceSparseMatrixColoringsExt.PushforwardSparseJacobianPrep(::DifferentiationInterface.BatchSizeSettings{…}, ::SparseMatrixColorings.ColumnColoringResult{…}, ::Matrix{…}, ::Vector{…}, ::Vector{…}, ::DifferentiationInterfaceForwardDiffExt.ForwardDiffTwoArgPushforwardPrep{…})
Closest candidates are:
DifferentiationInterfaceSparseMatrixColoringsExt.PushforwardSparseJacobianPrep(::BS, ::C, ::M, ::S, ::R, ::E) where {BS<:DifferentiationInterface.BatchSizeSettings, C<:(AbstractColoringResult{:nonsymmetric, :column}), M<:(AbstractMatrix{<:Real}), S<:(AbstractVector{<:Tuple{Vararg{T, N}} where {N, T}}), R<:(AbstractVector{<:Tuple{Vararg{T, N}} where {N, T}}), E<:DifferentiationInterface.PushforwardPrep}
@ DifferentiationInterfaceSparseMatrixColoringsExt ~/.julia/packages/DifferentiationInterface/bulUW/ext/DifferentiationInterfaceSparseMatrixColoringsExt/jacobian.jl:11
Stacktrace:
[1] _prepare_sparse_jacobian_aux_aux(::DifferentiationInterface.BatchSizeSettings{…}, ::SparseMatrixColorings.ColumnColoringResult{…}, ::Vector{…}, ::Tuple{…}, ::AutoSparse{…}, ::Vector{…})
@ DifferentiationInterfaceSparseMatrixColoringsExt ~/.julia/packages/DifferentiationInterface/bulUW/ext/DifferentiationInterfaceSparseMatrixColoringsExt/jacobian.jl:107
[2] _prepare_sparse_jacobian_aux(::DifferentiationInterface.PushforwardFast, ::Vector{…}, ::Tuple{…}, ::AutoSparse{…}, ::Vector{…})
@ DifferentiationInterfaceSparseMatrixColoringsExt ~/.julia/packages/DifferentiationInterface/bulUW/ext/DifferentiationInterfaceSparseMatrixColoringsExt/jacobian.jl:81
[3] prepare_jacobian(::Nothing, ::Vector{…}, ::AutoSparse{…}, ::Vector{…})
@ DifferentiationInterfaceSparseMatrixColoringsExt ~/.julia/packages/DifferentiationInterface/bulUW/ext/DifferentiationInterfaceSparseMatrixColoringsExt/jacobian.jl:49
[4] top-level scope
@ ~/Random/test2.jl:27
Some type information was truncated. Use `show(err)` to see complete types.
I believe the culprit is the annotation of the compressed matrix being too restricted in the SparseMatrixColorings extensions, I locally changed this into more generic ones and the errors are gone.
Lines 3 to 33 in cc8818a
struct PushforwardSparseJacobianPrep{ | |
BS<:BatchSizeSettings, | |
C<:AbstractColoringResult{:nonsymmetric,:column}, | |
M<:AbstractMatrix{<:Real}, | |
S<:AbstractVector{<:NTuple}, | |
R<:AbstractVector{<:NTuple}, | |
E<:PushforwardPrep, | |
} <: SparseJacobianPrep | |
batch_size_settings::BS | |
coloring_result::C | |
compressed_matrix::M | |
batched_seeds::S | |
batched_results::R | |
pushforward_prep::E | |
end | |
struct PullbackSparseJacobianPrep{ | |
BS<:BatchSizeSettings, | |
C<:AbstractColoringResult{:nonsymmetric,:row}, | |
M<:AbstractMatrix{<:Real}, | |
S<:AbstractVector{<:NTuple}, | |
R<:AbstractVector{<:NTuple}, | |
E<:PullbackPrep, | |
} <: SparseJacobianPrep | |
batch_size_settings::BS | |
coloring_result::C | |
compressed_matrix::M | |
batched_seeds::S | |
batched_results::R | |
pullback_prep::E | |
end |
Metadata
Metadata
Assignees
Labels
coreRelated to the core utilities of the packageRelated to the core utilities of the package