Skip to content

Track native Enzyme dense matrix exp outside authored source (LAPACK.gebal!) #45

Open

Description

@nsiccha

Julia 1.10.12 with Enzyme 0.13.209 fails to differentiate the raw dense matrix exponential: EnzymeNoDerivativeError at LinearAlgebra.LAPACK.gebal!. The same boundary is observed on Enzyme 0.13.206 and discussed upstream in EnzymeAD/Enzyme.jl#1222.

Minimal backend-only reproduction (no ReactiveKernels required):

using Enzyme, LinearAlgebra
A = [0.13 -0.27; 0.31 0.08]
sum(exp(A)) # 2.1736017897647315
Enzyme.gradient(Enzyme.Reverse, M -> sum(exp(M)), A)

The repository reproducer is benchmark/repro_enzyme_matrix_exp.jl. Enzyme 0.13.209 was tested at commit 8d7355bc38be3297d1264f60d817cb0e9bcbb154 (tree 4728d95aa849fd6c8ff97bb74145588e07133ca4).

ReactiveKernels has an owned matrix exponential with derivatives generated from one mathematical graph. The accompanying repair makes compiler-visible native exp calls on Matrix{Float64} select that primitive, including lazy branches, plates, scans and traceable helpers. The original downstream model then passes all42 gradients at three points against Stan (max absolute discrepancy6.22e-15).

Raw exp inside an ordinary opaque helper, direct Enzyme calls, and other matrix domains retain upstream behavior. This issue tracks general upstream support for that remaining boundary. It is separate from compiled Reactant matrix-exponential support tracked in #34.

Completion requires the raw backend-only reproducer to differentiate correctly, with gradients agreeing with independent numerical checks across matrix sizes and nonsymmetric inputs. Retain the existing generated owned primitive until upstream covers the supported domain.

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