FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix contraction of tensors with mixed elementary space types by leburgel · Pull Request #531 · QuantumKitHub/TensorKit.jl · GitHub

Fix contraction of tensors with mixed elementary space types - #531

Closed
leburgel wants to merge 1 commit into
mainfrom
lb/contractedspace-mixed-spacetypes
Closed

leburgel wants to merge 1 commit into
mainfrom
lb/contractedspace-mixed-spacetypes

Conversation

Copy link
Copy Markdown
Member

#515 replaced permute(compose(permute(A, pA), permute(B, pB)), pAB) with a helper whose signature pins both hom-spaces to one elementary space type S. This breaks contractions of tensors with mixed elementary space types, for example when contracting a BlockTensorMap with a TensorMap (observed when trying to run MPSKit.jl off the current TensorKit.jl main).

For example:

using TensorKit, BlockTensorKit, TensorOperations

V = Vect[FermionParity ⊠ U1Irrep]((0, 0) => 2, (1, 1) => 2, (1, -1) => 2)
Vsum = SumSpace(V, V)

GL = rand(ComplexF64, Vsum ⊗ Vsum ← SumSpace(V))   # BlockTensorMap, (2, 1)
A  = rand(ComplexF64, V ← V ⊗ V)                   # plain TensorMap,  (1, 2)

@tensor y[-1 -2; -3 -4] := GL[-1 -2; 1] * A[1; -3 -4]

results in

MethodError: no method matching _contractedspace(::TensorMapSpace{SumSpace{…}, 2, 1}, …, ::TensorMapSpace{GradedSpace{…}, 1, 2}, …)

This adds a generic fallback for _contractedspace which composes the intermediate spaces.

lkdvos commented Sep 11, 2026

Copy link
Copy Markdown
Member

The main issue and why that function was introduced is that the intermediate permutations might not be planar, therefore breaking with the checks on multifusion spaces. I've been putting off properly fixing this, but I'll have a look at a more durable fix.

codecov Bot commented Sep 11, 2026 •
edited
Loading

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/spaces/homspace.jl 87.34% <100.00%> (-5.34%) ⬇️

... and 12 files with indirect coverage changes

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

Copy link
Copy Markdown
Member Author

Closing in favor of #532.

leburgel closed this Sep 14, 2026
lkdvos mentioned this pull request Sep 20, 2026
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL