EnzymeAD / Enzyme.jl

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

Float16 argument errors #870

Closed jgreener64 closed 9 months ago

jgreener64 commented 1 year ago

I am on Julia 1.8.5 and Enzyme main (16818fd3d39d0583915aee38595b54a7fcce6b58). The following work:

using Enzyme
autodiff(Reverse, x -> x * 2.0, Active, Active(Float64(1.0))) # ((2.0,),)
autodiff(Reverse, x -> x * 2.0, Active, Active(Float32(1.0))) # ((2.0f0,),)

But it errors with Float16:

autodiff(Reverse, x -> x * 2.0, Active, Active(Float16(1.0)))
JIT session error: Symbols not found: [ __truncdfhf2 ]
JIT session error: Symbols not found: [ __truncdfhf2 ]
JIT session error: Symbols not found: [ __truncdfhf2 ]
JIT session error: Symbols not found: [ __truncdfhf2 ]
JIT session error: Symbols not found: [ __truncdfhf2 ]
ERROR: LLVM error: Failed to materialize symbols: { (main, { diffejulia__5_5100_inner_1wrap }) }
Stacktrace:
  [1] macro expansion
    @ C:\Users\Joe\.julia\packages\LLVM\bsdku\src\executionengine\utils.jl:32 [inlined]
  [2] lookup
    @ C:\Users\Joe\.julia\packages\LLVM\bsdku\src\orcv2.jl:238 [inlined]
  [3] lookup
    @ C:\Users\Joe\.julia\dev\Enzyme\src\compiler\orcv2.jl:232 [inlined]
  [4] _link(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, ::Tuple{LLVM.Module, String, Nothing, LLVM.Context, DataType})
    @ Enzyme.Compiler C:\Users\Joe\.julia\dev\Enzyme\src\compiler.jl:9533
  [5] cached_compilation
    @ C:\Users\Joe\.julia\dev\Enzyme\src\compiler.jl:9594 [inlined]
  [6] #s273#222
    @ C:\Users\Joe\.julia\dev\Enzyme\src\compiler.jl:9651 [inlined]
  [7] var"#s273#222"(FA::Any, A::Any, TT::Any, Mode::Any, ModifiedBetween::Any, width::Any, ReturnPrimal::Any, ShadowInit::Any, World::Any, ::Any, ::Any, ::Any, ::Any, tt::Any, ::Any, ::Any, ::Any, ::Any, ::Any)
    @ Enzyme.Compiler .\none:0
  [8] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
    @ Core .\boot.jl:582
  [9] thunk
    @ C:\Users\Joe\.julia\dev\Enzyme\src\compiler.jl:9610 [inlined]
 [10] autodiff(#unused#::EnzymeCore.ReverseMode{false}, f::Const{var"#5#6"}, #unused#::Type{Active}, args::Active{Float16})
    @ Enzyme C:\Users\Joe\.julia\dev\Enzyme\src\Enzyme.jl:199
 [11] autodiff(::EnzymeCore.ReverseMode{false}, ::var"#5#6", ::Type, ::Active{Float16})
    @ Enzyme C:\Users\Joe\.julia\dev\Enzyme\src\Enzyme.jl:214
 [12] top-level scope
    @ REPL[4]:1
vchuravy commented 1 year ago

Yeah we haven't done Float16 yet. Interesting that it fails that way... What is versioninfo?

jgreener64 commented 1 year ago

I am on Windows this time:

Julia Version 1.8.5
Commit 17cfb8e65e (2023-01-08 06:45 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 6 × Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, skylake)
  Threads: 4 on 6 virtual cores
Environment:
  JULIA_NUM_THREADS = 4
wsmoses commented 9 months ago

@jgreener64 I no longer can reproduce this (at least on 1.10). Reopen if it persists?

jgreener64 commented 9 months ago

Yes seems fixed.