JuliaDiff / JuliaDiff/ChainRules.jl
`f/rrules` should support receiving `ZeroTangent()`
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 475
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
Similarly to https://github.com/JuliaDiff/ChainRules.jl/issues/408, ZeroTangent() is a valid input to the pullback, and we need to make sure it is supported.
Using https://github.com/JuliaDiff/ChainRulesTestUtils.jl/pull/176, there are at least three kinds of errors:
- Pullbacks are written such that they do not support taking in
ZeroTangent(), e.g.
MethodError: no method matching (::ChainRules.var"#transpose_pullback#1894")(::ZeroTangent). These just need to be fixed in ChainRules.jl - Places where we (I think?) have to
projecttheZeroTangent():
TypeError: in Hermitian, in S, expected S<:(AbstractArray{var"#s832", 2} where var"#s832"<:T), got Type{ZeroTangent}
and
MethodError: Cannot `convert` an object of type
ZeroTangent to an object of type
Matrix{T} where T
- Errors which could be solved by
projecting theZeroTangent()e.g.
MethodError: no method matching getindex(::ZeroTangent, ::Int64). The question is whether we actually want to project to an array, since that would allocate quite a bit. Alternatively, we could defineBase.getindex(::ZeroTangent, args...) = ZeroTangent(). There might be quite a few of these functions to define, but it would be much faster.
Some examples are:
MethodError: no method matching Complex(::ZeroTangent)MethodError: no method matching mapfoldl(::typeof(identity), ::typeof(Base.add_sum), ::ZeroTangent; dims=Colon())MethodError: no method matching tr(::ZeroTangent)MethodError: no method matching mul!(::ZeroTangent, ::Matrix{Float64}, ::ZeroTangent, ::Bool, ::Bool)MethodError: no method matching trsyl!(::Char, ::Char, ::Matrix{ComplexF64}, ::Matrix{ComplexF64}, ::ZeroTangent)MethodError: no method matching size(::ZeroTangent, ::Int64)MethodError: no method matching LowerTriangular(::ZeroTangent)
and the list goes on
This is just a quick (incomplete) dump of observations and first thoughts. I may have missed kinds of errors, or said things which are untrue.
Alltogether:
Test Summary: | Pass Error Broken Total
ChainRules | 24330 429 4 24763
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the failures gathered through ChainRulesTestUtils PR 176 and inspect the affected ChainRules.jl pullbacks and ZeroTangent handling. Reproduce the reported errors, determine which cases should project ZeroTangent versus support it directly, and consider the work done when the relevant test errors are resolved without unacceptable allocation tradeoffs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100