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

Gradient of diff gives StackOverflowError #1941

Closed
jgreener64 opened this issue Oct 7, 2024 · 2 comments
Closed

Gradient of diff gives StackOverflowError #1941

jgreener64 opened this issue Oct 7, 2024 · 2 comments

Comments

@jgreener64
Copy link
Contributor

On Enzyme main (3c0871d) and Julia 1.10.3:

using Enzyme
f(x) = sum(diff([0.0 x; 1.0 2x]; dims=2))
autodiff(Forward, f, Duplicated(2.0, 1.0))
ERROR: StackOverflowError:
Stacktrace:
     [1] fwddiffejulia_hvcat_2632_inner_1wrap
       @ ~/soft/julia/julia-1.10.3/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:0
     [2] macro expansion
       @ ~/.julia/dev/Enzyme/src/compiler.jl:8839 [inlined]
     [3] enzyme_call
       @ ~/.julia/dev/Enzyme/src/compiler.jl:8405 [inlined]
     [4] ForwardModeThunk
       @ ~/.julia/dev/Enzyme/src/compiler.jl:8194 [inlined]
     [5] runtime_generic_fwd(activity::Type{…}, runtimeActivity::Val{…}, width::Val{…}, RT::Val{…}, f::typeof(hvcat), df::Nothing, primal_1::Tuple{…}, shadow_1_1::Nothing, primal_2::Float64, shadow_2_1::Float64, primal_3::Float64, shadow_3_1::Float64, primal_4::Float64, shadow_4_1::Float64, primal_5::Float64, shadow_5_1::Float64)
       @ Enzyme.Compiler ~/.julia/dev/Enzyme/src/rules/jitrules.jl:305
     [6] hvcat
       @ ~/soft/julia/julia-1.10.3/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:1269 [inlined]
     [7] hvcat
       @ ~/soft/julia/julia-1.10.3/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:0 [inlined]
--- the last 7 lines are repeated 11375 more times ---
 [79633] fwddiffejulia_hvcat_2459_inner_1wrap
       @ ~/soft/julia/julia-1.10.3/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:0
 [79634] macro expansion
       @ ~/.julia/dev/Enzyme/src/compiler.jl:8839 [inlined]
 [79635] enzyme_call
       @ ~/.julia/dev/Enzyme/src/compiler.jl:8405 [inlined]
 [79636] ForwardModeThunk
       @ ~/.julia/dev/Enzyme/src/compiler.jl:8194 [inlined]
 [79637] runtime_generic_fwd(activity::Type{…}, runtimeActivity::Val{…}, width::Val{…}, RT::Val{…}, f::typeof(hvcat), df::Nothing, primal_1::Tuple{…}, shadow_1_1::Nothing, primal_2::Float64, shadow_2_1::Nothing, primal_3::Float64, shadow_3_1::Float64, primal_4::Float64, shadow_4_1::Nothing, primal_5::Float64, shadow_5_1::Float64)
       @ Enzyme.Compiler ~/.julia/dev/Enzyme/src/rules/jitrules.jl:305
 [79638] hvcat
       @ ~/soft/julia/julia-1.10.3/share/julia/stdlib/v1.10/SparseArrays/src/sparsevector.jl:1269 [inlined]
 [79639] f
       @ ./REPL[2]:1 [inlined]
 [79640] fwddiffejulia_f_851wrap
       @ ./REPL[2]:0
 [79641] macro expansion
       @ ~/.julia/dev/Enzyme/src/compiler.jl:8839 [inlined]
 [79642] enzyme_call
       @ ~/.julia/dev/Enzyme/src/compiler.jl:8405 [inlined]
 [79643] ForwardModeThunk
       @ ~/.julia/dev/Enzyme/src/compiler.jl:8194 [inlined]
 [79644] autodiff
       @ ~/.julia/dev/Enzyme/src/Enzyme.jl:647 [inlined]
 [79645] autodiff
       @ ~/.julia/dev/Enzyme/src/Enzyme.jl:537 [inlined]
 [79646] autodiff(mode::ForwardMode{false, FFIABI, false, false}, f::typeof(f), args::Duplicated{Float64})
       @ Enzyme ~/.julia/dev/Enzyme/src/Enzyme.jl:504
Some type information was truncated. Use `show(err)` to see complete types.

Similar for reverse mode.

@jgreener64
Copy link
Contributor Author

This also affects f(x) = rot180([x 2x; 3x 4x], 3)[1, 1] but it looks like a similar error.

@wsmoses
Copy link
Member

wsmoses commented Oct 23, 2024

Dup of #1134

@wsmoses wsmoses closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2024
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