Skip to content
This repository was archived by the owner on Apr 25, 2026. It is now read-only.
This repository was archived by the owner on Apr 25, 2026. It is now read-only.

centercanonicalize! (and T4AMPOContractions.jl) don't seem to handle rank-defective site-tensors correctly #7

Description

@MFrankenbach

With the attached MPO and MPS, this code:

using LinearAlgebra
using T4ATensorTrain
using T4AMPOContractions
using JLD2

data = JLD2.load("debug_T4A_apply_mpo_mps_jld2.txt")
mpo = data["M_T4A"]
mps = data["mps_T4A"]
N = length(mpo.sitetensors)

# check link dimensions
mpo_sz = size.(mpo.sitetensors)
mps_sz = size.(mps.sitetensors)
for i in eachindex(mpo_sz)
    i==1 && continue 
    @assert mpo_sz[i][1]==mpo_sz[i-1][end]
end
for i in eachindex(mps_sz)
    i==1 && continue
    @assert mps_sz[i][1]==mps_sz[i-1][end]
end

# crashes
res = T4AMPOContractions.contract(
    mpo,
    mps;
    algorithm=:fit,
    method=:SVD,
    tolerance=1.e-7
    )

crashes. I think it's because the first MPO link has size (1,2,2,7), i.e., the block is rank-deficient after reshaping.

A similar problem occurs when calling

T4ATensorTrain.centercanonicalize!(mpo.sitetensors, N)
# crashes
T4ATensorTrain.centercanonicalize!(mps.sitetensors, N)

from T4ATensorTrain.jl. I think in this case line 396 in T4ATensorTrain.jl/src.tensor_train_representations.jl should be changed to something like

sitetensors[i+1] = reshape(tmptt, size(tmptt,1), Base.size(sitetensors[i+1][2:end])...)

and so forth.

debug_T4A_apply_mpo_mps_jld2.txt

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