Skip to content

Add Enzyme rules for factorizations - #464

Merged
kshyatt merged 9 commits into
mainfrom
ksh/enz_fact
Oct 14, 2026
Merged

kshyatt merged 9 commits into
mainfrom
ksh/enz_fact

Conversation

@kshyatt

@kshyatt kshyatt commented Jun 26, 2026

Copy link
Copy Markdown
Member

For some reason svd_compact and svd_trunc_no_error don't play nicely with Enzyme here using the MAK rules, I think because of the DiagonalTensorMap output. I can try to investigate further if preferred. I also added some additional logic in pullbacks to match what the MAK pullbacks actually kick back.

@kshyatt
kshyatt requested a review from lkdvos June 26, 2026 00:48
@kshyatt

kshyatt commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

Oh crap lol I was working on top of a dev-ed MAK

@codecov

codecov Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 50 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ext/TensorKitEnzymeExt/factorizations.jl 0.00% 27 Missing ⚠️
src/factorizations/pullbacks.jl 0.00% 21 Missing ⚠️
ext/TensorKitEnzymeExt/utility.jl 0.00% 1 Missing ⚠️
src/factorizations/diagonal.jl 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
ext/TensorKitEnzymeExt/TensorKitEnzymeExt.jl 100.00% <ø> (ø)
ext/TensorKitEnzymeExt/utility.jl 18.18% <0.00%> (-0.21%) ⬇️
src/factorizations/diagonal.jl 67.64% <0.00%> (-2.05%) ⬇️
src/factorizations/pullbacks.jl 47.69% <0.00%> (-22.77%) ⬇️
ext/TensorKitEnzymeExt/factorizations.jl 0.00% <0.00%> (ø)

... and 6 files with indirect coverage changes

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

@kshyatt
kshyatt marked this pull request as draft June 26, 2026 14:10
@kshyatt

kshyatt commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

Weirdly the eig failures seem to go away on MatrixAlgebraKit master, let me try with some [sources] and see if it's reproducible outside of my laptop

@github-actions

github-actions Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Your PR no longer requires formatting changes. Thank you for your contribution!

@kshyatt
kshyatt force-pushed the ksh/enz_fact branch 4 times, most recently from e0a9f0c to 9742ab7 Compare July 6, 2026 18:14
@kshyatt
kshyatt force-pushed the ksh/enz_fact branch 3 times, most recently from 049c1a0 to a60a6ca Compare July 15, 2026 14:21
@kshyatt

kshyatt commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

This map business with block is not the nicest but I thought it was better than letting block(nothing, c) go through silently in other cases

Comment thread src/factorizations/pullbacks.jl Outdated
@kshyatt
kshyatt marked this pull request as draft September 30, 2026 18:26
@kshyatt

kshyatt commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

Gonna make this a draft since 1.10 is going to fail anyway and the forward mode stuff needs some love

@kshyatt

kshyatt commented Oct 13, 2026 •

Copy link
Copy Markdown
Member Author

I think the only method definitions that could be collapsed are the qr, polar and lq ones since the _vals ones are already handled by MAK. I'll do that then.

Comment thread src/factorizations/pushforwards.jl
@kshyatt
kshyatt enabled auto-merge (squash) October 13, 2026 13:33
Comment thread src/factorizations/pullbacks.jl
Comment thread src/factorizations/pullbacks.jl
Comment thread src/factorizations/pushforwards.jl
Comment thread src/factorizations/pullbacks.jl Outdated
Comment thread src/factorizations/pullbacks.jl
Comment thread src/factorizations/pullbacks.jl Outdated
Comment thread src/factorizations/pushforwards.jl Outdated
Comment thread src/factorizations/pullbacks.jl Outdated

@Jutho Jutho 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.

I think I've checked most things and approve. I haven't read all the tests. Out of curiosity, are these all hand-written or did you get 🤖 help?

@kshyatt

kshyatt commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

I wrote the tests but pulled a lot from the existing Mooncake and ChainRules ones

@kshyatt

kshyatt commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

the gpu fail is expected, i'm going to (finally!) merge this

@kshyatt
kshyatt disabled auto-merge October 14, 2026 09:37
@kshyatt
kshyatt merged commit ae8abfc into main Oct 14, 2026
99 of 102 checks passed
@kshyatt
kshyatt deleted the ksh/enz_fact branch October 14, 2026 09:38
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.

3 participants