-
-
Notifications
You must be signed in to change notification settings - Fork 67
Enzyme LLVM crash differentiating through NonlinearSolve on Julia 1.12 #877
Description
Problem
Enzyme.gradient through NonlinearSolve.solve crashes with Illegal inttoptr in LLVM's GC invariant verifier on Julia 1.12. This affects both explicit algorithms (NewtonRaphson()) and the default PolyAlgorithm. The NonlinearSolveBaseEnzymeExt extension loads correctly — the crash happens during Enzyme's LLVM code generation.
Note: Enzyme.gradient through LinearSolve.solve works fine on the same Julia version, so this is specific to NonlinearSolve.
MWE
using NonlinearSolve, Enzyme
f(u, p) = u .^ 2 .- p
function loss(p)
prob = NonlinearProblem(f, [1.0], p)
sol = solve(prob, NewtonRaphson())
sum(sol.u)
end
# Crashes with: Illegal inttoptr
Enzyme.gradient(Enzyme.Reverse, loss, [2.0])Stack trace (truncated)
Illegal inttoptr
%13 = inttoptr i64 %.unpack3 to ptr addrspace(10), !dbg !87
signal 6 (-6): Aborted
...
run at .../llvm-gc-invariant-verifier.cpp:196
...
post_optimize! at .../Enzyme/src/compiler/optimize.jl:454
_thunk at .../Enzyme/src/compiler.jl:6775
...
augmented_julia_loss_...wrap at ./none:0
Versions
- Julia 1.12.4
- Enzyme v0.13.134
- NonlinearSolve v4.16.0 (at commit 3510f84 from Fix type inference for polyalgorithm solve!() #870)
- LinearSolve v3.67.0
Context
This was discovered while verifying the fix for #869 (polyalgorithm type inference). The inference fix (#870) resolves the MixedReturnException on Julia 1.10 where the Enzyme extension works. This issue tracks the separate LLVM-level crash on Julia 1.12.
🤖 Generated with Claude Code
Co-Authored-By: Chris Rackauckas accounts@chrisrackauckas.com