Skip to content

performance regression in x1.x? with GenericLinearAlgebra/sqrt or eigen #780

Closed

Description

@daviehh

Codes that calculates sqrt or eigen on Hermitian matrices works in the v0.10.39 branch, but hangs in the v1.x releases, example mwe:

using GenericLinearAlgebra
using ForwardDiff

const sx = Matrix{ComplexF64}([0 1; 1 0])
const sy = Matrix{ComplexF64}([0 -im; im 0])
const sz = Matrix{ComplexF64}([1 0; 0 -1])
const ms = [sx, sy, sz]

const hs = [kron(x, x) for x in ms]

function f(g; hs)
    m = sin(g) * hs[1] + cos(g^2) * hs[2] + sin(cos(g / 2)) * hs[3]
    mh = Hermitian(m)
    mhs = Hermitian(sqrt(mh))
    l = abs.(eigvals(mhs))
    sum(l) - maximum(l) / 2
end

g(x) = f(x; hs)
@time ForwardDiff.derivative(g, 0.1)

may be more related to sqrt since it works fine it's not there, test with mhs = mh.

Activity

  1. devmotion commented on Oct 6, 2025

    @devmotion
    Member

    This might be a duplicate of #756 and be fixed by #757.

    Edit: Indeed, I can reproduce the problem on the master branch but with #757 I get

    julia> @time ForwardDiff.derivative(g, 0.1)
      0.005034 seconds (92 allocations: 18.500 KiB)
    0.207978299889861
    
    julia> using FiniteDifferences
    
    julia> FiniteDifferences.grad(FiniteDifferences.central_fdm(5, 1), g ∘ only, [0.1])
    ([0.2079782998901855],)
  2. devmotion commented on Sep 11, 2026

    @devmotion
    Member

    Closed by #757

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