EnzymeAD / Enzyme.jl

Julia bindings for the Enzyme automatic differentiator
https://enzyme.mit.edu
MIT License
439 stars 62 forks source link

`Set` error with x86 #975

Closed jgreener64 closed 1 year ago

jgreener64 commented 1 year ago

This works on Julia 1.9.2 and Enzyme main (b35703b):

using Enzyme
f(x) = sum(Set([1.0, x, 2x, x]))
autodiff(Reverse, f, Active, Active(2.0))[1][1] # 3.0
autodiff(Forward, f, Duplicated(2.0, 1.0))[1]   # 3.0

But it seems to fail on x86 architectures. https://github.com/EnzymeAD/Enzyme.jl/actions/runs/5727131372/job/15518926482?pr=969 gives:

[2257] signal (11.1): Segmentation fault
in expression starting at /home/runner/work/Enzyme.jl/Enzyme.jl/test/runtests.jl:258
unknown function (ip: 0xce2727cc)
unknown function (ip: 0xce26fc67)
macro expansion at /home/runner/work/Enzyme.jl/Enzyme.jl/src/compiler.jl:9575 [inlined]
enzyme_call at /home/runner/work/Enzyme.jl/Enzyme.jl/src/compiler.jl:9253 [inlined]
CombinedAdjointThunk at /home/runner/work/Enzyme.jl/Enzyme.jl/src/compiler.jl:9216 [inlined]
autodiff at /home/runner/work/Enzyme.jl/Enzyme.jl/src/Enzyme.jl:213
unknown function (ip: 0xd5c8faf5)
_jl_invoke at /cache/build/default-amdci4-3/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci4-3/julialang/julia-release-1-dot-9/src/gf.c:2940
autodiff at /home/runner/work/Enzyme.jl/Enzyme.jl/src/Enzyme.jl:222
 [1] pkgerror(msg::String)
   @ Pkg.Types /opt/hostedtoolcache/julia/1.9.2/x86/share/julia/stdlib/v1.9/Pkg/src/Types.jl:69
 [2] test(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; coverage::Bool, julia_args::Cmd, test_args::Cmd, test_fn::Nothing, force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool)
   @ Pkg.Operations /opt/hostedtoolcache/julia/1.9.2/x86/share/julia/stdlib/v1.9/Pkg/src/Operations.jl:2021
 [3] test
   @ /opt/hostedtoolcache/julia/1.9.2/x86/share/julia/stdlib/v1.9/Pkg/src/Operations.jl:1902 [inlined]
 [4] test(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; coverage::Bool, test_fn::Nothing, julia_args::Vector{String}, test_args::Cmd, force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool, kwargs::Base.Pairs{Symbol, IOContext{Base.PipeEndpoint}, Tuple{Symbol}, NamedTuple{(:io,), Tuple{IOContext{Base.PipeEndpoint}}}})
   @ Pkg.API /opt/hostedtoolcache/julia/1.9.2/x86/share/julia/stdlib/v1.9/Pkg/src/API.jl:441
 [5] test(pkgs::Vector{Pkg.Types.PackageSpec}; io::IOContext{Base.PipeEndpoint}, kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:julia_args, :coverage, :force_latest_compatible_version), Tuple{Vector{String}, Bool, Bool}}})
   @ Pkg.API /opt/hostedtoolcache/julia/1.9.2/x86/share/julia/stdlib/v1.9/Pkg/src/API.jl:156
 [6] test(; name::Nothing, uuid::Nothing, version::Nothing, url::Nothing, rev::Nothing, path::Nothing, mode::Pkg.Types.PackageMode, subdir::Nothing, kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:julia_args, :coverage, :force_latest_compatible_version), Tuple{Vector{String}, Bool, Bool}}})
   @ Pkg.API /opt/hostedtoolcache/julia/1.9.2/x86/share/julia/stdlib/v1.9/Pkg/src/API.jl:171
 [7] top-level scope
   @ ~/work/_actions/julia-actions/julia-runtest/v1/test_harness.jl:15
 [8] include(fname::String)
   @ Base.MainInclude ./client.jl:478
 [9] top-level scope
   @ none:1
in expression starting at /home/runner/work/_actions/julia-actions/julia-runtest/v1/test_harness.jl:7
Error: Process completed with exit code 1.

It seems to work on Julia 1.8.5 though.

wsmoses commented 1 year ago

I think this should be resolved on current main, can you confirm?

jgreener64 commented 1 year ago

Yes seems fixed according to CI in #969.