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

remove the hack #129

Merged
merged 1 commit into from
Mar 29, 2023
Merged

remove the hack #129

merged 1 commit into from
Mar 29, 2023

Conversation

aviatesk
Copy link
Member

It looks like we no longer need the hack..

It looks like we no longer need the hack..
@aviatesk aviatesk requested a review from Keno March 28, 2023 16:51
@@ -226,8 +226,7 @@ z45, delta45 = frule_via_ad(DiffractorRuleConfig(), (0,1), x -> log(exp(x)), 2)
@test gradient(x -> sum(sqrt.(atan.(x, transpose(x)))), [1,2,3])[1] ≈ [0.2338, -0.0177, -0.0661] atol=1e-3
@test gradient(x -> sum(exp.(log.(x))), [1,2,3]) == ([1,1,1],)

# XXX the world-age limitation is preventing this test from passing
# @test gradient(x -> sum((exp∘log).(x)), [1,2,3]) == ([1,1,1],) # frule_via_ad
@test_broken gradient(x -> sum((exp∘log).(x)), [1,2,3]) == ([1,1,1],) # frule_via_ad
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case causes BoundsError now, which makes me doubt this is related to world-age anymore.

julia> using Diffractor

julia> gradient(x -> sum((explog).(x)), [1,2,3])
ERROR: BoundsError: attempt to access Tuple{Diffractor.TangentBundle{1, ComposedFunction{typeof(exp), typeof(log)}, Diffractor.ExplicitTangent{Tuple{ChainRulesCore.NoTangent}}}, Diffractor.TangentBundle{1, Int64, Diffractor.ExplicitTangent{Tuple{Int64}}}} at index [3]
Stacktrace:
  [1] (::Diffractor.∂☆recurse{1})(::Diffractor.TangentBundle{1, ComposedFunction{typeof(exp), typeof(log)}, Diffractor.ExplicitTangent{Tuple{ChainRulesCore.NoTangent}}}, ::Diffractor.TangentBundle{1, Int64, Diffractor.ExplicitTangent{Tuple{Int64}}})
    @ Diffractor ~/julia/packages/Diffractor/src/stage1/recurse_fwd.jl:53
  [2] (::Diffractor.∂☆internal{1})(::Diffractor.TangentBundle{1, ComposedFunction{typeof(exp), typeof(log)}, Diffractor.ExplicitTangent{Tuple{ChainRulesCore.NoTangent}}}, ::Vararg{Diffractor.AbstractTangentBundle{1}})
    @ Diffractor ~/julia/packages/Diffractor/src/stage1/forward.jl:112
  [3] frule_via_ad(::Diffractor.DiffractorRuleConfig, ::Tuple{ChainRulesCore.NoTangent, Int64}, ::Function, ::Vararg{Any})
    @ Diffractor ~/julia/packages/Diffractor/src/stage1/forward.jl:120
  [4] (::ChainRules.var"#1733#1735"{typeof(ChainRulesCore.frule_via_ad), Diffractor.DiffractorRuleConfig, ComposedFunction{typeof(exp), typeof(log)}})(a::Int64)
    @ ChainRules ~/.julia/packages/ChainRules/RZYEu/src/rulesets/Base/broadcast.jl:109
  [5] _broadcast_getindex_evalf
    @ ./broadcast.jl:697 [inlined]
  [6] _broadcast_getindex
    @ ./broadcast.jl:670 [inlined]
  [7] getindex
    @ ./broadcast.jl:624 [inlined]
  [8] iterate
    @ ./broadcast.jl:261 [inlined]
  [9] iterate
    @ ./broadcast.jl:255 [inlined]
 [10] #collect_structarray#94
    @ ~/.julia/packages/StructArrays/F5fDf/src/collect.jl:39 [inlined]
 [11] collect_structarray
    @ ~/.julia/packages/StructArrays/F5fDf/src/collect.jl:37 [inlined]
 [12] #StructArray#29
    @ ~/.julia/packages/StructArrays/F5fDf/src/structarray.jl:255 [inlined]
 [13] StructArray
    @ ~/.julia/packages/StructArrays/F5fDf/src/structarray.jl:254 [inlined]
 [14] unzip_broadcast
    @ ~/.julia/packages/ChainRules/RZYEu/src/unzipped.jl:39 [inlined]
 [15] split_bc_inner
    @ ~/.julia/packages/ChainRules/RZYEu/src/rulesets/Base/broadcast.jl:108 [inlined]
 [16] split_bc_forwards
    @ ~/.julia/packages/ChainRules/RZYEu/src/rulesets/Base/broadcast.jl:104 [inlined]
 [17] rrule
    @ ~/.julia/packages/ChainRules/RZYEu/src/rulesets/Base/broadcast.jl:41 [inlined]
 [18] ∂⃖
    @ ~/julia/packages/Diffractor/src/stage1/generated.jl:207 [inlined]
 [19] ∂⃖
    @ ~/julia/packages/Diffractor/src/stage1/generated.jl:372 [inlined]
 [20] broadcasted
    @ ./broadcast.jl:1325 [inlined]
 [21] (::Diffractor.∂⃖recurse{1})(::typeof(Base.Broadcast.broadcasted), ::ComposedFunction{typeof(exp), typeof(log)}, ::Vector{Int64})
    @ Diffractor ~/julia/packages/Diffractor/src/stage1/generated.jl:0
 [22] (::∂⃖{1})(::typeof(Base.Broadcast.broadcasted), ::Function, ::Vararg{Any})
    @ Diffractor ~/julia/packages/Diffractor/src/stage1/generated.jl:209
 [23] #3
    @ ./REPL[2]:1 [inlined]
 [24] (::Diffractor.∂⃖recurse{1})(::var"#3#4", ::Vector{Int64})
    @ Diffractor ~/julia/packages/Diffractor/src/stage1/generated.jl:0
 [25] ∂⃖
    @ ~/julia/packages/Diffractor/src/stage1/generated.jl:209 [inlined]
 [26] ∂⃖
    @ ~/julia/packages/Diffractor/src/interface.jl:25 [inlined]
 [27] (::Diffractor.∇{var"#3#4"})(args::Vector{Int64})
    @ Diffractor ~/julia/packages/Diffractor/src/interface.jl:123
 [28] Diffractor.(::Function, ::Vector{Int64})
    @ Diffractor ~/julia/packages/Diffractor/src/interface.jl:130
 [29] top-level scope
    @ REPL[2]:1

@codecov
Copy link

codecov bot commented Mar 28, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.45 🎉

Comparison is base (84ea690) 48.06% compared to head (21b02f1) 48.51%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #129      +/-   ##
==========================================
+ Coverage   48.06%   48.51%   +0.45%     
==========================================
  Files          27       27              
  Lines        2657     2659       +2     
==========================================
+ Hits         1277     1290      +13     
+ Misses       1380     1369      -11     
Impacted Files Coverage Δ
src/Diffractor.jl 100.00% <ø> (ø)
src/codegen/forward.jl 86.07% <100.00%> (+7.28%) ⬆️
src/stage1/generated.jl 73.95% <100.00%> (-0.36%) ⬇️
src/stage1/recurse.jl 96.41% <100.00%> (+0.15%) ⬆️
src/stage1/recurse_fwd.jl 61.53% <100.00%> (-12.15%) ⬇️

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@aviatesk aviatesk merged commit 87731ed into main Mar 29, 2023
@aviatesk aviatesk deleted the avi/nohacks branch March 29, 2023 00:29
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

Successfully merging this pull request may close these issues.

1 participant