Skip to content

Allow not checking hermiticity in eigh functions - #321

Open
kshyatt wants to merge 1 commit into
mainfrom
ksh/herm_check
Open

kshyatt wants to merge 1 commit into
mainfrom
ksh/herm_check

Conversation

@kshyatt

@kshyatt kshyatt commented Nov 5, 2026

Copy link
Copy Markdown
Member

I was really torn about what to call this check. check_hermiticity seems accurate but is ugly, but check_hermitian is already taken by the function itself.

The idea here is to allow users to avoid the check_hermitian calls if they are sure the input matrix is hermitian, ie if they just called project_hermitian! on it. This comes up for example in the C4v CTMRG case where we compute eigh_vals on something that was just projected.

@kshyatt
kshyatt requested a review from lkdvos November 5, 2026 10:16
@kshyatt
kshyatt force-pushed the ksh/herm_check branch 2 times, most recently from 8c4ffde to 4a76d70 Compare November 5, 2026 13:29
@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.05797% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ixAlgebraKitEnzymeExt/MatrixAlgebraKitEnzymeExt.jl 84.44% 7 Missing ⚠️
src/implementations/eigh.jl 83.33% 4 Missing ⚠️
Files with missing lines Coverage Δ
src/implementations/eigh.jl 95.04% <83.33%> (ø)
...ixAlgebraKitEnzymeExt/MatrixAlgebraKitEnzymeExt.jl 78.96% <84.44%> (+0.82%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos lkdvos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall definitely fine by me, although maybe we can discuss the API of this a little bit:

In general, my idea was that the algorithm struct holds all of the settings, so no additional keywords are needed for the f!(in, out, alg) methods. This mostly is beneficial to reason about signatures etc, for example I think the non-inplace methods wouldn't properly pass on the check_hermiticity keyword and instead would pass that to the select_algorithm function. I think most of our algorithm structs are generic so you can do something like get(alg.kwargs, :check_hermiticity, true) to get it out generically?

For the name, do you think it might make sense to just have a package-wide unsafe keyword that basically disables all checks, or something similar?

@kshyatt

kshyatt commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Extremely open to API changes. I didn't go with generic unsafe since only eigh has a similar check (e.g. I think no other function checks for posdef or something). But putting it in the alg can also be done and we just ignore that for eig and co. I'll try that and we can see if we like how it looks, it will simplify things for Enzyme too.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants