DistributionsAD.jl icon indicating copy to clipboard operation
DistributionsAD.jl copied to clipboard

Incompatible with AbstractGPs.jl

Open torfjelde opened this issue 4 years ago • 2 comments

AbstractGPs.jl has the following default implementation (https://github.com/JuliaGaussianProcesses/AbstractGPs.jl/blob/04e4c53a3a66c62c83cdb4f47aabcfb04543acf4/src/abstract_gp/finite_gp.jl#L298-L309):

function Distributions._logpdf(f::FiniteGP, y::AbstractVector{<:Real})
    return first(logpdf(f, reshape(y, :, 1)))
end
...
function Distributions.logpdf(f::FiniteGP, Y::AbstractMatrix{<:Real})
    m, C_mat = mean_and_cov(f)
    C = cholesky(_symmetric(C_mat))
    T = promote_type(eltype(m), eltype(C), eltype(Y))
    return -((size(Y, 1) * T(log(2π)) + logdet(C)) .+ diag_Xt_invA_X(C, Y .- m)) ./ 2
end

This means that

https://github.com/TuringLang/DistributionsAD.jl/blob/fe2070012167b78c84a49733a0a64997e9533812/src/zygote.jl#L70-L79

will recursive indefinitively :confused:

Should we maybe remove that the adjoint above? TBH it seems a bit too general.

torfjelde avatar Jul 16 '21 22:07 torfjelde

@yebai @mohamed82008 @devmotion

torfjelde avatar Jul 17 '21 12:07 torfjelde

Try removing it, see if tests fail.

mohamed82008 avatar Jul 17 '21 13:07 mohamed82008