Skip to content

rrule!! not picked up: Mooncake's is_primative is too rigid sometimes leading to false negatives #558

@thorek1

Description

@thorek1

I am trying and failing to make my package Mooncake compatible. It currently works with Zygote + custom rrules (ChainRulesCore).

I understand this is how I can make Mooncake aware of the rrule:

@from_rrule DefaultCtx Tuple{typeof(get_NSSS_and_parameters), ℳ, Vector{S}} where S <: AbstractFloat true

but calling it with DifferentiationInterface gives the following error

vj = DifferentiationInterface.jacobian(x->get_NSSS_and_parameters(m, x)[1], AutoMooncake(;config=nothing), m.parameter_values)

ERROR: No rrule!! available for foreigncall with primal argument types Tuple{Val{(:daxpy_64_, Symbol("@rpath/libblastrampoline.5.dylib"))}, Val{Nothing}, Tuple{Val{Ref{Int64}}, Val{Ref{Float64}}, Val{Ptr{Float64}}, Val{Ref{Int64}}, Val{Ptr{Float64}}, Val{Ref{Int64}}}, Val{0}, Val{:ccall}, Ptr{Int64}, Ptr{Float64}, Ptr{Float64}, Ptr{Int64}, Ptr{Float64}, Ptr{Int64}, Base.RefValue{Int64}, Ptr{Float64}, Base.RefValue{Int64}, Ptr{Float64}, Base.RefValue{Float64}, Base.RefValue{Int64}}. This problem has most likely arisen because there is a ccall somewhere in the function you are trying to differentiate, for which an rrule!! has not been explicitly written.You have three options: write an rrule!! for this foreigncall, write an rrule!! for a Julia function that calls this foreigncall, or re-write your code to avoid this foreigncall entirely. If you believe that this error has arisen for some other reason than the above, or the above does not help you to workaround this problem, please open an issue.

the rest of the error message shows that the rrule is not called but the function itself is (attempted to be) differentiated.

What I understand from the documentation is that the type might be a problem. is a large nested mutable struct with, lists, dictionaries, circular buffers, functions, arrays, and scalars among other types therein. See here for details.

I am sorry if I am overlooking something obvious here. Any help is much appreciated

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions