Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguities with Base #448

Open
jishnub opened this issue Aug 26, 2021 · 6 comments
Open

Ambiguities with Base #448

jishnub opened this issue Aug 26, 2021 · 6 comments
Labels
good first issue Good for newcomers

Comments

@jishnub
Copy link

jishnub commented Aug 26, 2021

julia> Test.detect_ambiguities(ChainRulesCore, Base)
16-element Vector{Tuple{Method, Method}}:
 (*(s, comp::Tangent) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differential_arithmetic.jl:168, *(comp::Tangent, s) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differential_arithmetic.jl:169)
 (==(a, b::AbstractThunk) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:27, ==(::Missing, ::Any) in Base at missing.jl:75)
 (-(a::AbstractThunk, b) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:30, -(a, b::AbstractThunk) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:31)
 (/(z::AbstractZero, ::Any) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/abstract_zero.jl:25, /(a, b::AbstractThunk) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:33)
 (ger!(alpha, x::AbstractThunk, y, A) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:100, ger!(alpha, x, y::AbstractThunk, A) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:103)
 (/(::Any, x::ChainRulesCore.NotImplemented) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/notimplemented.jl:43, /(a::AbstractThunk, b) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:32)
 ((::ProjectTo{T, D} where D<:NamedTuple)(dx::AbstractZero) where T in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/projection.jl:127, (::ProjectTo{NoTangent, D} where D<:NamedTuple)(dx) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/projection.jl:135)
 (==(a::AbstractThunk, b) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:26, ==(::Any, ::Missing) in Base at missing.jl:76)
 (/(z::AbstractZero, ::Any) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/abstract_zero.jl:25, /(::Any, x::ChainRulesCore.NotImplemented) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/notimplemented.jl:43)
 (==(a, b::AbstractThunk) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:27, ==(w::WeakRef, v) in Base at gcutils.jl:4)
 (==(a::AbstractThunk, b) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:26, ==(w, v::WeakRef) in Base at gcutils.jl:5)
 (/(a::AbstractThunk, b) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:32, /(a, b::AbstractThunk) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:33)
 ((::ProjectTo{T, D} where D<:NamedTuple)(dx::ChainRulesCore.NotImplemented) where T in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/projection.jl:128, (::ProjectTo{NoTangent, D} where D<:NamedTuple)(dx) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/projection.jl:135)
 ((project::ProjectTo{T, D} where D<:NamedTuple)(dx::Tangent) where T in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/projection.jl:75, (::ProjectTo{NoTangent, D} where D<:NamedTuple)(dx) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/projection.jl:135)
 (/(x::ChainRulesCore.NotImplemented, ::Any) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/notimplemented.jl:42, /(a, b::AbstractThunk) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/differentials/thunks.jl:33)
 ((project::ProjectTo)(dx::Thunk) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/projection.jl:131, (::ProjectTo{NoTangent, D} where D<:NamedTuple)(dx) in ChainRulesCore at /home/jishnu/.julia/packages/ChainRulesCore/Voykb/src/projection.jl:135)
@oxinabox
Copy link
Member

oxinabox commented Aug 26, 2021

Are any of these causing problems for you in practice?

@jishnub
Copy link
Author

jishnub commented Aug 27, 2021

Not directly, but this leads to downstream test failures if a package checks for zero ambiguities without specifically excluding dependencies. This isn't a big issue as such, but would be nice to resolve this at some point.

@dlfivefifty
Copy link

dlfivefifty commented Dec 2, 2021

This is triggering a test failure in DualNumbers.jl:

Test Failed at /home/runner/work/DualNumbers.jl/DualNumbers.jl/test/runtests.jl:4
94
  Expression: isempty(detect_ambiguities(DualNumbers, Base, Core))
95
   Evaluated: isempty(Tuple{Method, Method}[((::Type{T})(xs::ChainRulesCore.AbstractZero...) where T<:Number in ChainRulesCore at /home/runner/.julia/packages/ChainRulesCore/7ZiwT/src/tangent_types/abstract_zero.jl:28, Complex{T}(re, im) where T<:Real in Base at complex.jl:12), ((::Type{T})(xs::ChainRulesCore.AbstractZero...) where T<:Number in ChainRulesCore at /home/runner/.julia/packages/ChainRulesCore/7ZiwT/src/tangent_types/abstract_zero.jl:28, Dual{T}(value, epsilon) where T<:Union{Real, Complex} in DualNumbers at /home/runner/work/DualNumbers.jl/DualNumbers.jl/src/dual.jl:4), (==(a, b::ChainRulesCore.AbstractThunk) in ChainRulesCore at /home/runner/.julia/packages/ChainRulesCore/7ZiwT/src/tangent_types/thunks.jl:27, ==(::Missing, ::Any) in Base at missing.jl:75), (==(a::ChainRulesCore.AbstractThunk, b) in ChainRulesCore at /home/runner/.julia/packages/ChainRulesCore/7ZiwT/src/tangent_types/thunks.jl:26, ==(::Any, ::Missing) in Base at missing.jl:76), (==(a::ChainRulesCore.AbstractThunk, b) in ChainRulesCore at /home/runner/.julia/packages/ChainRulesCore/7ZiwT/src/tangent_types/thunks.jl:26, ==(w, v::WeakRef) in Base at gcutils.jl:5), (==(a, b::ChainRulesCore.AbstractThunk) in ChainRulesCore at /home/runner/.julia/packages/ChainRulesCore/7ZiwT/src/tangent_types/thunks.jl:27, ==(w::WeakRef, v) in Base at gcutils.jl:4)])

https://github.com/JuliaDiff/DualNumbers.jl/runs/4397702757?check_suite_focus=true

@oxinabox oxinabox added the good first issue Good for newcomers label Dec 2, 2021
@oxinabox
Copy link
Member

oxinabox commented Dec 2, 2021

It is kinda annoying.
Like ambiguities that are never hit are not actually a problem; except that testing that way makes them a problem.
And keeping testing easy is important.
So we should resolve them.
So a PR to do so would be welcomed.
(and probably quite educational for the author to see how the tangent types work)

@dlfivefifty
Copy link

I just marked the test in DualNumbers as broken… I agree with you that the person who cares about it should fix it

@vtjnash
Copy link

vtjnash commented Dec 3, 2021

Why is DualNumbers checking for ambiguities in Base (not with Base, which is implied by the DualNumbers argument, but actually in Base, because of the Base argument)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants