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

test_rrule leads to MethodError: Base.ArithmeticStyle(::Type{Union{}}) is ambiguous #232

Open
mcabbott opened this issue Jan 17, 2022 · 2 comments

Comments

@mcabbott
Copy link
Member

mcabbott commented Jan 17, 2022

I don't have a MWE, but the original case was here: https://github.com/JuliaDiff/ChainRules.jl/pull/570/files#diff-14d216cb53721d9360bbbcc399d93fff67f2594bd388162abbbe82c59ad1ba9fR236.

Maybe JuliaDiff/ChainRules.jl@944cced#diff-14d216cb53721d9360bbbcc399d93fff67f2594bd388162abbbe82c59ad1ba9fR236 is the right link.

@mzgubic
Copy link
Member

mzgubic commented Jan 18, 2022

Hmm, do you mean the error is

test_rrule: filter on Base.Fix2{typeof(>), Float64},Vector{Float64}: Error During Test at /Users/mzgubic/JuliaEnvs/ChainRules.jl/dev/ChainRulesTestUtils/src/testers.jl:195
  Got exception outside of a @test
  MethodError: no method matching zero(::Base.Fix2{typeof(>), Float64})
  Closest candidates are:
    zero(::Union{Type{P}, P}) where P<:Dates.Period at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Dates/src/periods.jl:53
    zero(::T) where T<:Dates.TimeType at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Dates/src/types.jl:450
    zero(::CartesianIndex{N}) where N at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/multidimensional.jl:106
    ...

I think it comes from the fact that >(0.5) is essentially a closure over 0.5, and CRTU tries to wiggle it. I don't think this is what we want here, but in general I don't think we want to not wiggle closures, so adding the ⊢ NoTangent() is appropriate. IMO. Admittedly, the error message is bad, and I have no ideas on how to improve it.

@mcabbott
Copy link
Member Author

Oh no, I thought I was linking to a commit, not just a line number.

No, Fix1 is another thing. Ideally it would perturb it, as you say, and deduce that it has no continuous effect, and thus accept Zero as the gradient.

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

No branches or pull requests

2 participants