Skip to content

variance() throws SpaceMismatch for real-scalartype long-range InfiniteMPOHamiltonian #524

Description

@lkdvos

Summary

variance(::InfiniteMPS, ::InfiniteMPOHamiltonian) throws a SpaceMismatch when the Hamiltonian is real-scalartype and has a long-range (non-nearest-neighbour) term, while the state is complex-scalartype.

Reproduction

using MPSKit, TensorKit
using TensorKit: ℙ

g, D, L = 4.0, 6, 3
H = force_planar(long_range_ising_infinite(Float64; g, L))  # or any real, long-range InfiniteMPOHamiltonian
ψ₀ = InfiniteMPS(fill(ℙ^2, L), fill(ℙ^D, L))
variance(ψ₀, H)  # throws

(long_range_ising_infinite/force_planar are test helpers from test/setup/testsetup.jl; any real, long-range InfiniteMPOHamiltonian combined with a complex state should reproduce this.)

Error

SpaceMismatch: ((ℙ^1 ⊞ ℙ^1 ⊞ ℙ^1) ⊗ ⊞(ℙ^2)) ← (⊞(ℙ^2) ⊗ (ℙ^1 ⊞ ℙ^1 ⊞ ℙ^1)) ≠ ((ℙ^1 ⊞ ℙ^1) ⊗ ⊞(ℙ^2)) ← (⊞(ℙ^2) ⊗ (ℙ^1 ⊞ ℙ^1))
Stacktrace:
  [1] add(ty::BlockTensorKit.SparseBlockTensorMap{TensorMap{Float64, ...}}, tx::BlockTensorKit.SparseBlockTensorMap{TensorMap{ComplexF64, ...}}, ...)
    @ BlockTensorKit ~/.julia/packages/BlockTensorKit/DSAP5/src/tensors/vectorinterface.jl:27
  ...
  [16] +(A::InfiniteMPOHamiltonian{JordanMPOTensor{Float64,...}}, B::InfiniteMPOHamiltonian{JordanMPOTensor{ComplexF64,...}})
    @ Base ./arraymath.jl:8
  [17] -(H1::InfiniteMPOHamiltonian{JordanMPOTensor{Float64,...}}, H2::InfiniteMPOHamiltonian{JordanMPOTensor{ComplexF64,...}})
    @ MPSKit ~/src/operators/mpohamiltonian.jl:1005
  [18] variance(state::InfiniteMPS{...ComplexF64...}, H::InfiniteMPOHamiltonian{JordanMPOTensor{Float64,...}}, envs::...)
    @ MPSKit ~/src/algorithms/toolbox.jl:122

Diagnosis

variance computes something like ⟨H²⟩ - ⟨H⟩² and ends up subtracting two InfiniteMPOHamiltonians: one built by squaring H (which ends up complex, presumably promoted through contraction with the complex environments/state) and one derived from H itself (real). The two InfiniteMPOHamiltonians' shared virtual leg (a SumSpace) end up with a different number of blocks (3 vs 2) once the long-range (1, L) coupling is included, so the elementwise +/- on their JordanMPOTensors hits a genuine structural SpaceMismatch, not just a scalartype-promotion issue.

This reproduces independent of find_groundstate/any optimization algorithm — it's purely in variance's own Hamiltonian arithmetic for long-range + real/complex-mismatched combinations.

Context

Found while adding long-range Hamiltonian coverage to test/groundstate/groundstate.jl in #493. The affected checks there are marked @test_broken referencing this issue.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions