jcmgray / quimb

A python library for quantum information and many-body calculations including tensor networks.
http://quimb.readthedocs.io
Other
455 stars 107 forks source link

Infinite loop in antidiag_gauge() function #117

Closed steve-jeffrey closed 2 years ago

steve-jeffrey commented 2 years ago

There may be a bug in the antidiag_gauge function in tensor/tensor_core.py

When calling full_simplify(seq="AC") on the tensor network shown below:

import numpy as np
import quimb.tensor as qtn

data_0 = np.array([1.0, 0.0])
data_1 = np.array([1.0, 0.0])
data_2 = np.array([1.0, 0.0])
data_3 = np.array([1.0, 0.0])
data_4 = np.array([1.0, 0.0])
data_5 = np.array([1.0, 0.0])
data_6 = np.array([1.0, 0.0])
data_7 = np.array([1.0, 0.0])
data_8 = np.array([1.0, 0.0])
data_9 = np.array([0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0])
data_9 = data_9.reshape((2, 2, 2, 2, 2, 2, ))
data_10 = np.array([0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0])
data_10 = data_10.reshape((2, 2, 2, 2, 2, 2, ))
data_11 = np.array([1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0])
data_11 = data_11.reshape((2, 2, 2, 2, 2, 2, ))
data_12 = np.array([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0])
data_12 = data_12.reshape((2, 2, 2, 2, ))
data_13 = np.array([1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0])
data_13 = data_13.reshape((2, 2, 2, 2, 2, 2, ))

tensor_0 = qtn.Tensor(data=data_0, inds=('index_0_tensor_i',))
tensor_1 = qtn.Tensor(data=data_1, inds=('index_1_tensor_i',))
tensor_2 = qtn.Tensor(data=data_2, inds=('index_2_tensor_i',))
tensor_3 = qtn.Tensor(data=data_3, inds=('index_3_tensor_i',))
tensor_4 = qtn.Tensor(data=data_4, inds=('index_4_tensor_i',))
tensor_5 = qtn.Tensor(data=data_5, inds=('index_5_tensor_i',))
tensor_6 = qtn.Tensor(data=data_6, inds=('index_6_tensor_i',))
tensor_7 = qtn.Tensor(data=data_7, inds=('index_7_tensor_i',))
tensor_8 = qtn.Tensor(data=data_8, inds=('index_8_tensor_i',))
tensor_9 = qtn.Tensor(data=data_9, inds=('index_1_tensor_9', 'index_6_tensor_9', 'index_7_tensor_f', 'index_1_tensor_i', 'index_6_tensor_i', 'index_7_tensor_i'))
tensor_10 = qtn.Tensor(data=data_10, inds=('index_2_tensor_10', 'index_4_tensor_10', 'index_5_tensor_f', 'index_2_tensor_i', 'index_4_tensor_i', 'index_5_tensor_i'))
tensor_11 = qtn.Tensor(data=data_11, inds=('index_0_tensor_11', 'index_3_tensor_f', 'index_4_tensor_f', 'index_0_tensor_i', 'index_3_tensor_i', 'index_4_tensor_10'))
tensor_12 = qtn.Tensor(data=data_12, inds=('index_1_tensor_f', 'index_0_tensor_f', 'index_1_tensor_9', 'index_0_tensor_11'))
tensor_13 = qtn.Tensor(data=data_13, inds=('index_2_tensor_f', 'index_6_tensor_f', 'index_8_tensor_f', 'index_2_tensor_10', 'index_6_tensor_9', 'index_8_tensor_i'))

TN = tensor_0 & tensor_1 & tensor_2 & tensor_3 & tensor_4 & tensor_5 & tensor_6 & tensor_7 & tensor_8 & tensor_9 & tensor_10 & tensor_11 & tensor_12 & tensor_13

# This function call never returns
tn = TN.full_simplify(seq="AC")

I am using Quimb version 1.3.0 and Python 3.8.12 on Fedora 35.

jcmgray commented 2 years ago

Thanks for the issue! I believe this has been fixed at some point - at least, it runs for me with a recent version from github. Apologies that the pypi version is quite out of date.

jcmgray commented 2 years ago

I've updated the pypi version of quimb and will do so more regularly going forward - closing for now, but feel free to re-open.