Skip to content

planarcontract! rejects a basic zero-contracted-index planar contraction as non-cyclic #551

Description

@lkdvos

planarcontract!/planar_contract_indices throws ArgumentError: ... is not a cyclic permutation for the simplest possible planar contraction between two (1,1) tensors with zero contracted indices (an outer-product-like call, as opposed to ⊗ itself) — even for the identity pAB. Found via the full MPSKit test suite (fast_tests=true) against this branch: breaks operators/projection, operators/mpohamiltonian (Adapt), algorithms/dynamical_dmrg, operators/lazysum, algorithms/changebonds, and their GPU variants — all going through environments/Jordan-form MPO Hamiltonian machinery for non-bosonic sector types (PlanarTrivial in the repro, but likely any BraidingStyle != Bosonic sector).

Minimal reproduction (bisects to #532, planar_contract_indices/_planar_rotate):

using TensorKit
using TensorKit: planarcontract!, planar_contract_indices
using TensorKitSectors: PlanarTrivial
using VectorInterface: One, Zero

V = Vect[PlanarTrivial](PlanarTrivial() => 1)
A = randn(ComplexF64, V ← V)
B = randn(ComplexF64, V ← V)
C = randn(ComplexF64, (V ⊗ V) ← (V ⊗ V))

pA = ((1, 2), ())
pB = ((), (1, 2))

planar_contract_indices(A, pA, B, pB, ((1, 2), (3, 4)))
# -> (((1, 2), ()), ((), (2, 1)), ((1, 2), (4, 3)))
#                          ^^^^^^ oindB reversed even though cindB is empty

planarcontract!(C, A, pA, B, pB, ((1, 2), (3, 4)), One(), Zero())
# ArgumentError: ((1, 2), (4, 3)) is not a cyclic permutation for ...

Even the identity pAB = ((1,2),(3,4)) (just concatenate A's legs then B's) fails. Suspect root cause: _planar_rotate(indB, cindB, oindB) with cindB empty (N₁ = 0) hits the 0 < N₁ < N guard as false and skips rotation, but still unconditionally does tail′ = reverse(rot[N₁+1:end]), reversing all of oindB — this reversal looks intended for the general case but seems wrong when there are no contracted indices at all on that operand.

This is a release blocker for the changes in #532/#526 (currently on the release-v0.17.2 branch / PR #550) — recommend fixing or reverting before that release ships.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions