Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare_jacobian error for OOP function with type unspecified output #641

Closed
ErikQQY opened this issue Nov 25, 2024 · 3 comments
Closed

Comments

@ErikQQY
Copy link

ErikQQY commented Nov 25, 2024

MWE from https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/stable/tutorials/advanced/#Sparsity-speedup, not sure if this is intended or a bug

using DifferentiationInterface, SparseConnectivityTracer, SparseMatrixColorings
dense_first_order_backend = AutoForwardDiff()
sparse_first_order_backend = AutoSparse(
    dense_first_order_backend;
    sparsity_detector=SparseConnectivityTracer.TracerLocalSparsityDetector(),
    coloring_algorithm=GreedyColoringAlgorithm(LargestFirst()),
)
function f_sparse_vector(x::AbstractVector)
	n = length(x)
    ret = []
    for i in 1:n-1
        append!(ret, abs2(x[i + 1]) - abs2(x[i]) + abs2(x[n - i]) - abs2(x[n - i + 1]))
    end
    return ret
end
xbig = rand(1000)
jac_prep_sparse_nonallocating = prepare_jacobian(f_sparse_vector, sparse_first_order_backend, zero(xbig))
ERROR: MethodError: no method matching jacobian_pattern_to_mat(::Vector{SparseConnectivityTracer.Dual{Float64, SparseConnectivityTracer.GradientTracer{…}}}, ::Vector{Any})

Closest candidates are:
  jacobian_pattern_to_mat(::AbstractArray{D}, ::AbstractArray{<:Real}) where {P, T<:SparseConnectivityTracer.GradientTracer, D<:SparseConnectivityTracer.Dual{P, T}}
   @ SparseConnectivityTracer ~/.julia/packages/SparseConnectivityTracer/4CmIb/src/trace_functions.jl:122

Stacktrace:
 [1] _local_jacobian_sparsity(f::Function, x::Vector{Float64}, ::Type{SparseConnectivityTracer.GradientTracer{SparseConnectivityTracer.IndexSetGradientPattern{Int64, BitSet}}})
   @ SparseConnectivityTracer ~/.julia/packages/SparseConnectivityTracer/4CmIb/src/trace_functions.jl:91
 [2] jacobian_sparsity(f::Function, x::Vector{Float64}, ::TracerLocalSparsityDetector{SparseConnectivityTracer.GradientTracer{…}, SparseConnectivityTracer.HessianTracer{…}})
   @ SparseConnectivityTracer ~/.julia/packages/SparseConnectivityTracer/4CmIb/src/adtypes_interface.jl:149
 [3] _prepare_sparse_jacobian_aux(::DifferentiationInterface.PushforwardFast, ::Vector{…}, ::Tuple{…}, ::AutoSparse{…}, ::Vector{…})
   @ DifferentiationInterfaceSparseMatrixColoringsExt ~/.julia/packages/DifferentiationInterface/gSdHF/ext/DifferentiationInterfaceSparseMatrixColoringsExt/jacobian.jl:61
 [4] prepare_jacobian(::typeof(f_sparse_vector), ::AutoSparse{AutoForwardDiff{…}, TracerLocalSparsityDetector{…}, GreedyColoringAlgorithm{…}}, ::Vector{Float64})
   @ DifferentiationInterfaceSparseMatrixColoringsExt ~/.julia/packages/DifferentiationInterface/gSdHF/ext/DifferentiationInterfaceSparseMatrixColoringsExt/jacobian.jl:41
 [5] top-level scope
   @ REPL[19]:1
Some type information was truncated. Use `show(err)` to see complete types.
@adrhill
Copy link
Collaborator

adrhill commented Nov 25, 2024

Looks like an SCT error. Could you reopen in there?

@adrhill
Copy link
Collaborator

adrhill commented Nov 25, 2024

Closing in favor of adrhill/SparseConnectivityTracer.jl#216.

@adrhill adrhill closed this as completed Nov 25, 2024
@adrhill
Copy link
Collaborator

adrhill commented Nov 25, 2024

Fixed in SCT v0.6.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants