JuliaDiff / JuliaDiff/ForwardDiff.jl

missing method AD'ing through a QR decomposition

Open
#286 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
1k
Forks
160
PR merge metrics
No merged PRs in 30d

Description

Could not reduce this to a MWE yet, but I get this error message when using ForwardDiff.jacobian on a problem that uses the QR decomposition for least squares.

ERROR: MethodError: no method matching A_ldiv_B!(::Base.LinAlg.QRCompactWY{ForwardDiff.Dual{ForwardDiff.Tag{IndirectLikelihood.##3#4{IndirectLikelihood.IndirectLikelihoodProblem{SinglesModel{Float64},AuxModel,SinglesData{Float64,Float64}}},Float64},Float64,4},Array{ForwardDiff.Dual{ForwardDiff.Tag{IndirectLikelihood.##3#4{IndirectLikelihood.IndirectLikelihoodProblem{SinglesModel{Float64},AuxModel,SinglesData{Float64,Float64}}},Float64},Float64,4},2}}, ::Array{ForwardDiff.Dual{ForwardDiff.Tag{IndirectLikelihood.##3#4{IndirectLikelihood.IndirectLikelihoodProblem{SinglesModel{Float64},AuxModel,SinglesData{Float64,Float64}}},Float64},Float64,4},2})
Closest candidates are:
  A_ldiv_B!(::Base.LinAlg.QR{T,S} where S<:(AbstractArray{T,2} where T), ::Union{Base.ReshapedArray{T,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T}, DenseArray{T,2}, SubArray{T,2,A,I,L} where L} where I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex, Int64, Range{Int64}},N} where N} where A<:Union{Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T} where N where T, DenseArray}) where T at linalg/qr.jl:730
  A_ldiv_B!(::Base.LinAlg.QRPivoted, ::Union{Base.ReshapedArray{T,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T}, DenseArray{T,2}, SubArray{T,2,A,I,L} where L} where I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex, Int64, Range{Int64}},N} where N} where A<:Union{Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T} where N where T, DenseArray} where T) at linalg/qr.jl:782
  A_ldiv_B!(::Base.LinAlg.LQ{T,S} where S<:(AbstractArray{T,2} where T), ::Union{Union{Base.ReshapedArray{T,1,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T}, DenseArray{T,1}, SubArray{T,1,A,I,L} where L} where I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex, Int64, Range{Int64}},N} where N} where A<:Union{Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T} where N where T, DenseArray}, Union{Base.ReshapedArray{T,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T}, DenseArray{T,2}, SubArray{T,2,A,I,L} where L} where I<:Tuple{Vararg{Union{Base.AbstractCartesianIndex, Int64, Range{Int64}},N} where N} where A<:Union{Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{DenseArray, SubArray{T,N,P,I,true} where I<:Tuple{Union{Base.Slice, UnitRange},Vararg{Any,N} where N} where P where N where T} where N where T, DenseArray}}) where T at linalg/lq.jl:234
  ...
Stacktrace:
 [1] \(::Base.LinAlg.QRCompactWY{Float64,Array{Float64,2}}, ::Array{ForwardDiff.Dual{ForwardDiff.Tag{IndirectLikelihood.##3#4{IndirectLikelihood.IndirectLikelihoodProblem{SinglesModel{Float64},AuxModel,SinglesData{Float64,Float64}}},Float64},Float64,4},2}) at ./linalg/qr.jl:819

Importantly, in the X \ Y the Y is a matrix, not a vector (multiple independent variables).

Using Julia v0.6.1, tried both ForwardDiff master and 0.7.0. A workaround would also help.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported Julia v0.6.1 stack trace in linalg/qr.jl:819 and reproduce the failure using ForwardDiff.jacobian with QR decomposition and a matrix right-hand side. A minimal reproducer is needed before determining whether support is missing or a workaround is appropriate; done means the reported operation works or the workaround is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.