Skip to content

Boil down indexmanip rules to add_transform#486

Draft
kshyatt wants to merge 1 commit into
mainfrom
ksh/enz_im
Draft

Boil down indexmanip rules to add_transform#486
kshyatt wants to merge 1 commit into
mainfrom
ksh/enz_im

Conversation

@kshyatt

@kshyatt kshyatt commented Jul 14, 2026

Copy link
Copy Markdown
Member

Enzyme can't reverse diff through add_transform (yet) without some rules for the OhMyThreads.jl functions, which I was a little lazy about adding. But it can make a nice forward rule, it seems.

@kshyatt
kshyatt requested a review from lkdvos July 14, 2026 17:28
TC = VectorInterface.promote_scale(Cval, α.val)
if scalartype(A.dval) <: Real && !(TC <: Real)
ΔAc = TO.tensoralloc_add(TC, C.dval, pΔA, false, Val(false))
TK.add_transform!(ΔAc, C.dval, pΔA, transformer.val, conj(α.val), Zero(), bavs...)

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'm really surprised this works though - the transformer is the metadata needed to efficiently permute and recouple, but this depends on the value of p so unless this is accidentally a self-inverse permutation where C and A have the same structure, this should probably give wrong results?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was testing this on spaces that are "too easy" maybe, for the A4 ones it doesn't work :(

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.

Yeah, the problem is that at this point we no longer have access to what kind of transformer it is, so it is not possible to construct the reverse one from that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

But my negative lines diff!!!!!!

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
ext/TensorKitEnzymeExt/indexmanipulations.jl 0.00% 15 Missing ⚠️
Files with missing lines Coverage Δ
ext/TensorKitEnzymeExt/indexmanipulations.jl 64.83% <0.00%> (+64.83%) ⬆️

... and 56 files with indirect coverage changes

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

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