Skip to content

Comments

AD rules for (anti-) hermitian projection#174

Open
lkdvos wants to merge 25 commits intomainfrom
hermitian
Open

AD rules for (anti-) hermitian projection#174
lkdvos wants to merge 25 commits intomainfrom
hermitian

Conversation

@lkdvos
Copy link
Member

@lkdvos lkdvos commented Feb 17, 2026

Fixes #99.

Requires #175.

I played around a bit with also implementing the project_isometric, but since that was taking more significant changes (possibly writing an actual sylvester equation solver), I will leave that for a follow-up.
Also, I'm not actually smart enough for Enzyme rules, so will also ignore that for now. (Additionally I'm not sure we need them in that case, so don't want to pollute this PR)

@lkdvos lkdvos requested review from Jutho and kshyatt February 17, 2026 15:20
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 91.89189% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...gebraKitMooncakeExt/MatrixAlgebraKitMooncakeExt.jl 86.95% 3 Missing ⚠️
Files with missing lines Coverage Δ
ext/MatrixAlgebraKitChainRulesCoreExt.jl 83.33% <100.00%> (+1.19%) ⬆️
src/pullbacks/polar.jl 100.00% <100.00%> (ø)
...gebraKitMooncakeExt/MatrixAlgebraKitMooncakeExt.jl 61.97% <86.95%> (+1.21%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

lkdvos and others added 13 commits February 19, 2026 15:57
Guard `C .+= ΔP` with `!iszerotangent(ΔP)` in both
`left_polar_pullback!` and `right_polar_pullback!` to handle
the case where ΔP is `nothing`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace LAPACK trsyl!-based solver with a direct eigendecomposition
approach when both arguments are the same Hermitian matrix (as in polar
pullbacks). This avoids LAPACKException(1) for close eigenvalues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add rrules/pullbacks for `project_hermitian!`, `project_antihermitian!`,
and `project_isometric!` directly in each AD backend extension
(ChainRulesCore, Enzyme, Mooncake). The hermitian/antihermitian
pullbacks are self-adjoint, while the isometric pullback delegates to
`left_polar_pullback!` with zero ΔP.

Includes test utilities and tests for all three backends.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kshyatt
Copy link
Member

kshyatt commented Feb 23, 2026

This needs a rebase on top of main once the other branch is merged, I think? It's extremely hard to now see what's changed with a 36 file diff

@lkdvos
Copy link
Member Author

lkdvos commented Feb 23, 2026

Yes, indeed.

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.

[AD] rrules for project_(anti)hermitian

3 participants