Skip to content

MPS shape conventions mismatch between MPS_computational_state and DMRG #304

@thibxlv

Description

@thibxlv

What is your issue?

I'm trying to use DMRG to initialize a quantum circuit with ancillas. I am trying to prepare a state $|k\rangle|\psi\rangle$ where $|k\rangle$ is a computational basis state and $|\psi\rangle$ is the DMRG approximation of the ground state.

Quimb uses the 'lpr' shape convention for the DMRG output indices, but everywhere else it seems to use the 'lrp' convention. Besides, calling quimb.tensor.MPS_computational_state with the option shape='lpr' produces a TypeError:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[271], line 1
----> 1 zero_mps = qtn.MPS_computational_state('0'*m_L, shape='lpr')

File ~/*****/lib/python3.12/site-packages/quimb/tensor/tensor_builder.py:3802, in MPS_computational_state(binary, dtype, cyclic, **mps_opts)
   3799     for s in binary:
   3800         yield array_map[str(s)]
-> 3802 return MPS_product_state(tuple(gen_arrays()), cyclic=cyclic, **mps_opts)

File ~/*****/lib/python3.12/site-packages/quimb/tensor/tensor_builder.py:3772, in MPS_product_state(arrays, cyclic, **mps_opts)
   3765     yield (*cyc_dim, 1, -1)
   3767 mps_arrays = (
   3768     asarray(array).reshape(*shape)
   3769     for array, shape in zip(arrays, gen_array_shapes())
   3770 )
-> 3772 return MatrixProductState(mps_arrays, shape="lrp", **mps_opts)

TypeError: quimb.tensor.tensor_1d.MatrixProductState() got multiple values for keyword argument 'shape'

It would be nice either to have a way to change the shape convention of the DMRG.state MPS, or to unify conventions by default. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions