Enzyme.jl icon indicating copy to clipboard operation
Enzyme.jl copied to clipboard

"Enzyme: The original primal code hits this error condition, thus differentiating it does not make sense" very unhelpful

Open vchuravy opened this issue 1 month ago • 4 comments

I have never felt so gaslit by an exception: What error, why? how?

ERROR: LoadError: Enzyme execution failed.
Enzyme: The original primal code hits this error condition, thus differentiating it does not make sense

Stacktrace:
  [1] construct
    @ ~/.julia/packages/KernelAbstractions/X5fk1/src/KernelAbstractions.jl:779 [inlined]
  [2] _esvolumeterm_dir!
    @ ~/.julia/packages/KernelAbstractions/X5fk1/src/macros.jl:61 [inlined]
  [3] esvolumeterm_dir!
    @ ~/.julia/packages/KernelAbstractions/X5fk1/src/macros.jl:68 [inlined]
  [4] #launch_volumeterm#8
    @ ~/src/Raven/src/balancelaws/dgsem.jl:208
  [5] launch_volumeterm
    @ ~/src/Raven/src/balancelaws/dgsem.jl:163 [inlined]
  [6] #_#4
    @ ~/src/Raven/src/balancelaws/dgsem.jl:97
  [7] DGSEM
    @ ~/src/Raven/src/balancelaws/dgsem.jl:84 [inlined]
  [8] rhs
    @ ~/src/Raven/ext/RavenSciMLBaseExt.jl:6 [inlined]
  [9] ODEFunction
    @ ~/.julia/packages/SciMLBase/RPW6n/src/scimlfunctions.jl:2597 [inlined]
 [10] F!
    @ ~/src/Ariadne/libs/Theseus/src/rosenbrock/rosenbrock.jl:35 [inlined]
 [11] F!
    @ ~/src/Ariadne/libs/Theseus/src/rosenbrock/rosenbrock.jl:0 [inlined]
 [12] fwddiffejulia_F__27283_inner_19wrap
    @ ~/src/Ariadne/libs/Theseus/src/rosenbrock/rosenbrock.jl:0
 [13] macro expansion
    @ ~/src/Enzyme/src/compiler.jl:5887 [inlined]
 [14] enzyme_call
    @ ~/src/Enzyme/src/compiler.jl:5421 [inlined]
 [15] ForwardModeThunk
    @ ~/src/Enzyme/src/compiler.jl:5323 [inlined]
 [16] autodiff
    @ ~/src/Enzyme/src/Enzyme.jl:673 [inlined]

https://github.com/EnzymeAD/Enzyme.jl/blob/3e48bb3d07cb2087c8decc46786c690d147baaf5/src/compiler.jl#L5157

vchuravy avatar Nov 07 '25 21:11 vchuravy

somehow you have made it past what was believed to be an ijl_throw or similar

wsmoses avatar Nov 07 '25 21:11 wsmoses

probably the thing to do here is to upgrade the exception [like I did recently for others] to retain the string of the llvm function, and MI for being able to code_typed [in our interp] of the inside

wsmoses avatar Nov 07 '25 21:11 wsmoses

or sorry, rephrasing. you hit an unreachable, that did not have an ijl_throw before it.

how you hit the unreachable....is a question

wsmoses avatar Nov 07 '25 21:11 wsmoses

In a different program (related though)

I see:

julia +1.11 --project=. semdg_advection_2d.jl
ERROR: LoadError: 
No forward mode derivative found for jl_get_builtin_fptr
 at context:   %133 = call {} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* @jl_get_builtin_fptr({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 139742159320480 to {}*) to {} addrspace(10)*)) #27, !dbg !206

Stacktrace:
 [1] construct
   @ ~/.julia/packages/KernelAbstractions/X5fk1/src/KernelAbstractions.jl:779
 [2] _rhs_volume_kernel!
   @ ~/.julia/packages/KernelAbstractions/X5fk1/src/macros.jl:61
 [3] rhs_volume_kernel!
   @ ~/.julia/packages/KernelAbstractions/X5fk1/src/macros.jl:68
 [4] rhs!
   @ ~/src/Raven/examples/advection/semdg_advection_2d.jl:236
 [5] rhs!
   @ ~/src/Raven/examples/advection/semdg_advection_2d.jl:0


Stacktrace:
  [1] construct
    @ ~/.julia/packages/KernelAbstractions/X5fk1/src/KernelAbstractions.jl:779 [inlined]
  [2] _rhs_volume_kernel!
    @ ~/.julia/packages/KernelAbstractions/X5fk1/src/macros.jl:61 [inlined]
  [3] rhs_volume_kernel!
    @ ~/.julia/packages/KernelAbstractions/X5fk1/src/macros.jl:68 [inlined]
  [4] rhs!
    @ ~/src/Raven/examples/advection/semdg_advection_2d.jl:236 [inlined]
  [5] rhs!
    @ ~/src/Raven/examples/advection/semdg_advection_2d.jl:0 [inlined]
  [6] fwddiffejulia_rhs__14377_inner_1wrap
    @ ~/src/Raven/examples/advection/semdg_advection_2d.jl:0
  [7] macro expansion
    @ ~/.julia/packages/Enzyme/LCg4E/src/compiler.jl:5887 [inlined]
  [8] enzyme_call
    @ ~/.julia/packages/Enzyme/LCg4E/src/compiler.jl:5421 [inlined]
  [9] ForwardModeThunk

Which is very similar if my menory doesn't betray me to Joe issue on Oceanangians. This works on 1.10 so something fishy is going on with KA and 1.11

vchuravy avatar Nov 07 '25 23:11 vchuravy