You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Parallel gradient, Cannot determine ordering of Dual tags #320
Going through the serializer is probably always going to be tricky, although there are also some more basic cases where the tag system fails (not silently though, thankfully).
I ran into this error as well; passing arguments to my function as vectors rather than NTuples solved it as then there were no user-defined types that were being serialized. I'm not sure the tagging system will be 100% correct in a distributed environment at this time, as tagcount() in config.jl is based on an atomic int that is per-process.
using KernelFunctions: Kernel, KernelFunctions as KF
using OneHotArrays: OneHotVector
import ForwardDiff as FD
struct Pt{Dim}
pos::AbstractArray
partial
endPt(x;partial=()) =Pt{length(x)}(x, partial)
for T insubtypes(Kernel)
(k::T)(x::Pt{Dim}, y::Pt{Dim}) where {Dim} =evaluate_(k, x, y)
(k::T)(x::Pt{Dim}, y) where {Dim} =evaluate_(k, x, Pt(y))
(k::T)(x, y::Pt{Dim}) where {Dim} =evaluate_(k, Pt(x), y)
endfunctionevaluate_(k::Kernel, x::Pt{Dim}, y::Pt{Dim}) where {Dim}
if!isnothing(local next =iterate(x.partial))
ii, state = next # take partial derivative in direction iireturn FD.derivative(0) do dx
evaluate_( # recursion
k,
Pt(
x.pos .+ dx *OneHotVector(ii, Dim), # directional variation
partial=Base.rest(x.partial, state) # remaining partial derivatives
),
y
)
endendif!isnothing(local next =iterate(y.partial))
jj, state = next # take partial derivative in direction jjreturn FD.derivative(0) do dy
evaluate_( # recursion
k,
x,
Pt(
y.pos .+ dy *OneHotVector(jj, Dim), # directional variation
partial=Base.rest(y.partial, state) # remaining partial derivatives
)
)
endendk(x.pos, y.pos)
end
k = KF.MaternKernel()
k(Pt([1], partial=(1)), Pt([2], partial=1))
Activity
MikeInnes commentedon Jul 3, 2018
Going through the serializer is probably always going to be tricky, although there are also some more basic cases where the tag system fails (not silently though, thankfully).
MasonProtter commentedon Dec 22, 2018
I'm also hitting this issue with ForwardDiff and NLsolve.
mattwigway commentedon Nov 29, 2021
I ran into this error as well; passing arguments to my function as vectors rather than NTuples solved it as then there were no user-defined types that were being serialized. I'm not sure the tagging system will be 100% correct in a distributed environment at this time, as
tagcount()inconfig.jlis based on an atomic int that is per-process.FelixBenning commentedon May 12, 2023
Here is a MWE I think:
resulting in