Forward and reverse Enzyme rules and tests for TensorOperations#451
Merged
Conversation
kshyatt
marked this pull request as draft
June 12, 2026 09:09
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
Jutho
reviewed
Jun 18, 2026
Member
Author
|
Good points on both. I’ve tried moving the shared functions into the main
part of TK and encountered very strange errors (also for Mooncake) that I
punted on investigating too hard. I can try asking enzyme to generate its
own rules but given that wasn’t a blocker for the Mooncake version I’d be
ok with keeping this for now so at least something is working, then
iteratively pruning both sets of roles back.
…On Thu, Jun 18, 2026 at 11:01 AM Jutho ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In ext/TensorKitEnzymeExt/tensoroperations.jl
<#451 (comment)>
:
> +function blas_contract_pullback_ΔA!(
+ ΔA, ΔC, A, pA, B, pB, pAB, α, backend, allocator
+ )
+ ipAB = invperm(linearize(pAB))
+ pΔC = _repartition(ipAB, TO.numout(pA))
+ ipA = _repartition(invperm(linearize(pA)), A)
+
+ tB = twist(
+ B,
+ TupleTools.vcat(
+ filter(x -> !isdual(space(B, x)), pB[1]),
+ filter(x -> isdual(space(B, x)), pB[2])
+ ); copy = false
+ )
+
+ project_contract!(
+ ΔA,
+ ΔC, pΔC, false,
+ tB, reverse(pB), true,
+ ipA, conj(α), backend, allocator
+ )
+
+ return nothing
+end
These generic rules should probably appear somewhere more centrally, in
the main TensorKit module? Also, same question as always: do we really need
to redefine all these rules? Can't AD do this for us, using only the rules
for the lower level primitives?
—
Reply to this email directly, view it on GitHub
<#451?email_source=notifications&email_token=AAGKJY7XTXYHV5EXTFC7E4D5AOVUXA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINJSGMZTGMBQGM22M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#pullrequestreview-4523330035>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGKJY6PUDFHVQ5BOM72MNL5AOVUXAVCNFSNUABFKJSXA33TNF2G64TZHMYTANJXGAYDAMZRHNEXG43VMU5TINRUG44TCMBZGEY2C5QC>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AAGKJY77N7OUPIT2CQFARP35AOVUXA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINJSGMZTGMBQGM22M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KUZTPN52GK4S7NFXXG>
and Android
<https://github.com/notifications/mobile/android/AAGKJYYST5IMFVJGXE73HI35AOVUXA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINJSGMZTGMBQGM22M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2K4ZTPN52GK4S7MFXGI4TPNFSA>.
Download it today!
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
kshyatt
marked this pull request as draft
June 18, 2026 16:34
kshyatt
force-pushed
the
ksh/enz_to
branch
2 times, most recently
from
June 25, 2026 14:50
23cae68 to
9ea5a42
Compare
kshyatt
marked this pull request as ready for review
June 25, 2026 14:51
kshyatt
force-pushed
the
ksh/enz_to
branch
6 times, most recently
from
July 1, 2026 14:19
aeafda0 to
5f3cdf4
Compare
Merged
lkdvos
referenced
this pull request
Jul 15, 2026
* Update changelog for v0.17.1 * Bump version to v0.17.1 * Update CITATION.cff for v0.17.1 * Document #485 and MatrixAlgebraKit 0.6.9 bump in changelog * Address review comments: clarify Enzyme index-manip mode, note cuTENSOR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.