Skip to content

Enzyme v0.13.69 broke second-order differentiation with constant matrix #2523

@gdalle

Description

@gdalle

Here's an MWE which fails on v0.13.69

(_Scratchpad) pkg> st
Status `~/Documents/GitHub/Julia/_Scratchpad/Project.toml`
  [7da242da] Enzyme v0.13.69

julia> using Enzyme, LinearAlgebra

julia> const A = ones(3, 3);

julia> f(x) = dot(x, A, x);

julia> x, dx = ones(3), ones(3);

julia> Enzyme.hvp(f, x, dx)  # should not be zero
3-element Vector{Float64}:
 0.0
 0.0
 0.0

and works on v0.13.68

(_Scratchpad2) pkg> st
Status `~/Documents/GitHub/Julia/_Scratchpad2/Project.toml`
⌃ [7da242da] Enzyme v0.13.68
Info Packages marked with ⌃ have new versions available and may be upgradable.

julia> using Enzyme, LinearAlgebra

julia> const A = ones(3, 3);

julia> f(x) = dot(x, A, x);

julia> x, dx = ones(3), ones(3);

julia> Enzyme.hvp(f, x, dx)
3-element Vector{Float64}:
 6.0
 6.0
 6.0

I spotted it because it broke the Enzyme tests for DI, so any help would be greatly appreciated.

Additional details:

julia> versioninfo()
Julia Version 1.11.6
Commit 9615af0f269 (2025-07-09 12:58 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 11 × Apple M3 Pro
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m2)
Threads: 1 default, 0 interactive, 1 GC (on 5 virtual cores)

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