Skip to content

Enzyme_jll 0.0.302 segfaults native reverse gradients on Julia 1.10 (excluded through compat until a fixed binary ships) #46

Open

Description

@nsiccha

Summary

Enzyme_jll 0.0.302, which Enzyme 0.13.211 requires, segfaults native
AutoEnzyme(mode = Enzyme.Reverse) gradients on Julia 1.10 whenever a
differentiated function returns a freshly allocated array, for example an
index gather in a per-cell @plate likelihood. Enzyme 0.13.210 /
Enzyme_jll 0.0.301 computes the correct gradients. Julia 1.12 and 1.13 are
not affected.

Upstream: EnzymeAD/Enzyme.jl#3776 (the cause is EnzymeAD/Enzyme#3418; the fix
is EnzymeAD/Enzyme#3445, which will ship in a later Enzyme_jll).

Observed

  • The example-packages CI job on main fails with Package ReactiveKernelsPPL errored during testing (received signal: 11) in the eight-schools gradient
    testset (packages/ReactiveKernelsPPL/test/test_generator.jl). Run
    37459391494 on 5692477f.
  • Native gradients of BayesianRegressionModels grouped-effect models crash the
    same way.

Minimal reproducer (Enzyme only, from EnzymeAD/Enzyme.jl#3776)

using StaticArrays, Enzyme

const P = SVector(-0.5, 0.2, 0.9, -1.3)
f = y -> collect(SVector{4,Float64}(
    y[1]*P[1] - y[2]*P[2] - y[3]*P[3] - y[4]*P[4],
    y[1]*P[2] + y[2]*P[1] + y[3]*P[4] - y[4]*P[3],
    y[1]*P[3] - y[2]*P[4] + y[3]*P[1] + y[4]*P[2],
    y[1]*P[4] + y[2]*P[3] - y[3]*P[2] + y[4]*P[1]))
g = let f = f
    y -> f(y)[1]
end

Enzyme.gradient(Reverse, g, [1.2, -0.7, 0.5, 0.3])

Upstream reports that Julia 1.10.12 with Enzyme 0.13.211 crashes with signal (11), and that Enzyme 0.13.210 returns ([-0.5, -0.2, -0.9, 1.3],). On gordito, Julia 1.10.12, the ReactiveKernelsPPL eight-schools gradient segfaults in _unsafe_getindex inside diffejulia__ADKernelCall with Enzyme 0.13.211 / Enzyme_jll 0.0.302. With Enzyme 0.13.210 / 0.0.301 it matches central differences to 8e-10.

What ReactiveKernels does now

Since ebe13e40 (merged to main as 5652a556), the root Project.toml declares Enzyme_jll as a weak dependency used only
for compat, with Enzyme_jll = "0.0.0 - 0.0.301, 0.0.303 - 0.0". Every
environment that contains ReactiveKernels therefore resolves Enzyme 0.13.210
today and admits the next binary without another edit.
test/test_package_boundary.jl keeps the exclusion in place, and reactivekernels-use §7ah documents it for consumers, including how an environment that already holds 0.0.302 moves off it.

Close when

  1. An Enzyme_jll release containing Make callers of local read-only-or-throw callees local when memory can flow back EnzymeAD/Enzyme#3445 is registered, and
    the example-packages job passes on it.
  2. The Enzyme_jll weak dependency, its compat entry and the guard are
    removed together, along with the reactivekernels-use note.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions