EnzymeAD / Enzyme.jl

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

No augmented forward pass found for Faddeeva_erfcx_re #578

Closed tpapp closed 1 year ago

tpapp commented 1 year ago

With Enzyme v0.10.15 on Julia 1.8.5, I get

No augmented forward pass found for Faddeeva_erfcx_re
declare double @Faddeeva_erfcx_re(double) local_unnamed_addr

on a function.

If this is not sufficient information, I can prepare an MWE, it is a complicated (log) posterior but I can put it in a self-contained repository.

wsmoses commented 1 year ago

Did the error log provide more information? If so do you mind posting that?

Regardless, this shouldn't be a hard fix -- but I need to figure out exactly what "Faddeeva_erfcx_re" is meant to compute.

tpapp commented 1 year ago

It provided a ton of information, which I didn't paste in, but here is an MWE.

MWE

using Enzyme, Distributions
f(x) = logcdf(Normal(x[1], abs2(x[2])), x[3])
x = [1.0, 1.0, 1.0]
f(x)
d = zero(x)
y = Enzyme.autodiff(Reverse, f, Enzyme.Active, Enzyme.Duplicated(x, d))

Version information

(jl_1oljho) pkg> st
Status `/tmp/jl_1oljho/Project.toml`
  [31c24e10] Distributions v0.25.80
  [7da242da] Enzyme v0.10.16

julia> VERSION
v"1.8.5"

output

I am just pasting in the last few lines and the stack, tell me if you need more.

!900 = distinct !DISubprogram(name: "normlogcdf", linkageName: "julia_normlogcdf_3867", scope: null, file: !16, line: 66, type: !20, scopeLine: 66, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !15, retainedNodes: !4)
!901 = !DILocation(line: 412, scope: !774, inlinedAt: !902)
!902 = !DILocation(line: 66, scope: !900)
!903 = !DILocation(line: 385, scope: !777, inlinedAt: !904)
!904 = !DILocation(line: 389, scope: !779, inlinedAt: !902)
!905 = !DILocation(line: 39, scope: !781, inlinedAt: !906)
!906 = !DILocation(line: 37, scope: !784, inlinedAt: !902)
!907 = !DILocation(line: 386, scope: !786, inlinedAt: !908)
!908 = !DILocation(line: 391, scope: !788, inlinedAt: !902)
!909 = distinct !{}
!910 = !DILocation(line: 385, scope: !777, inlinedAt: !911)
!911 = !DILocation(line: 177, scope: !791, inlinedAt: !902)
!912 = !DILocation(line: 384, scope: !793, inlinedAt: !902)
!913 = !DILocation(line: 15, scope: !795, inlinedAt: !914)
!914 = !DILocation(line: 13, scope: !797, inlinedAt: !902)

No augmented forward pass found for Faddeeva_erfcx_re
declare double @Faddeeva_erfcx_re(double) local_unnamed_addr

Stacktrace:
  [1] julia_error(cstr::Cstring, val::Ptr{LLVM.API.LLVMOpaqueValue}, errtype::Enzyme.API.ErrorType, data::Ptr{Nothing})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/tU030/src/compiler.jl:3598
  [2] EnzymeCreatePrimalAndGradient(logic::Enzyme.Logic, todiff::LLVM.Function, retType::Enzyme.API.CDIFFE_TYPE, constan
t_args::Vector{Enzyme.API.CDIFFE_TYPE}, TA::Enzyme.TypeAnalysis, returnValue::Bool, dretUsed::Bool, mode::Enzyme.API.CDe
rivativeMode, width::Int64, additionalArg::Ptr{Nothing}, typeInfo::Enzyme.FnTypeInfo, uncacheable_args::Vector{Bool}, au
gmented::Ptr{Nothing}, atomicAdd::Bool)
    @ Enzyme.API ~/.julia/packages/Enzyme/tU030/src/api.jl:123
  [3] enzyme!(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams, GPUCompil
er.FunctionSpec{typeof(f), Tuple{Vector{Float64}}}}, mod::LLVM.Module, primalf::LLVM.Function, adjoint::GPUCompiler.Func
tionSpec{typeof(f), Tuple{Duplicated{Vector{Float64}}}}, mode::Enzyme.API.CDerivativeMode, width::Int64, parallel::Bool,
 actualRetType::Type, dupClosure::Bool, wrap::Bool, modifiedBetween::Bool, returnPrimal::Bool, jlrules::Vector{String})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/tU030/src/compiler.jl:5049
  [4] codegen(output::Symbol, job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerP
arams, GPUCompiler.FunctionSpec{typeof(f), Tuple{Vector{Float64}}}}; libraries::Bool, deferred_codegen::Bool, optimize::
Bool, ctx::LLVM.Context, strip::Bool, validate::Bool, only_entry::Bool, parent_job::Nothing)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/tU030/src/compiler.jl:6245
  [5] _thunk
    @ ~/.julia/packages/Enzyme/tU030/src/compiler.jl:6732 [inlined]
  [6] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams, GPUCompile
r.FunctionSpec{typeof(f), Tuple{Vector{Float64}}}})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/tU030/src/compiler.jl:6726
  [7] cached_compilation(job::GPUCompiler.CompilerJob, key::UInt64, specid::UInt64)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/tU030/src/compiler.jl:6770
  [8] #s879#169
    @ ~/.julia/packages/Enzyme/tU030/src/compiler.jl:6830 [inlined]
  [9] var"#s879#169"(F::Any, Fn::Any, DF::Any, A::Any, TT::Any, Mode::Any, ModifiedBetween::Any, width::Any, specid::Any
, ReturnPrimal::Any, ShadowInit::Any, ::Any, #unused#::Type, f::Any, df::Any, #unused#::Type, tt::Any, #unused#::Type, #
unused#::Type, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Any)
    @ Enzyme.Compiler ./none:0
 [10] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
    @ Core ./boot.jl:582
 [11] thunk
    @ ~/.julia/packages/Enzyme/tU030/src/compiler.jl:6863 [inlined]
 [12] thunk (repeats 3 times)
    @ ~/.julia/packages/Enzyme/tU030/src/compiler.jl:6856 [inlined]
 [13] autodiff(#unused#::EnzymeCore.ReverseMode, f::typeof(f), #unused#::Type{Active}, args::Duplicated{Vector{Float64}}
)
    @ Enzyme ~/.julia/packages/Enzyme/tU030/src/Enzyme.jl:211
 [14] top-level scope
    @ REPL[13]:1
wsmoses commented 1 year ago

Try again on main. This should now be fixed.