Toolbox for converting matrix product states to Qiskit quantum circuits.
Assuming you have a Quimb MatrixProductState object, you can
extract the individual tensors as three-dimensional NumPy arrays using the snippet below.
mps_arrays = mps.arraysYou can now convert the list of tensors to a Qiskit QuantumCircuit using the mps_to_circuit
interface function, specifying the shape as shape).
For example, using the "exact" method [Shoen2006]:
qc = mps_to_circuit(mps_arrays, method="exact", shape="lrp")Or using the "approximate" method [Ran2019]:
qc = mps_to_circuit(mps_arrays, method="approximate", shape="lrp", num_layers=3)Assuming you have a TenPy MPS object, you can extract the
individual tensors as three-dimensional NumPy arrays using the snippet below.
mps_arrays = [mps.get_B(i).to_ndarray() for i in range(L)]You can now convert the list of tensors to a Qiskit QuantumCircuit using the mps_to_circuit
interface function, specifying the shape as
For example, using the "exact" method [Shoen2006]:
qc = mps_to_circuit(mps_arrays, method="exact", shape="lpr")Or using the "approximate" method [Ran2019]:
qc = mps_to_circuit(mps_arrays, method="approximate", shape="lpr", num_layers=3)This package and all dependencies can be installed using uv.
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.12
uv venv --python 3.12
uv python pin 3.12
uv pip install -e .One can test the code using pytest .
uv run pytestOne can lint the code using the Ruff Linter.
uv run ruff checkOne can format the code using the Ruff Formatter.
uv run ruff formatAll members of this project agree to adhere to the Qiskit Code of Conduct listed here.
If you use mps-to-circuit please cite as per the BibTeX below.
@software{mpstocircuit2025,
author = {Millar, D. A. and
Pennington, G. W. and
Siow, N. T. M. and
Thomson, S. J. },
title = {qiskit-community/mps-to-circuit},
year = 2025,
publisher = {Zenodo},
doi = {10.5281/zenodo.14920028},
url = {https://doi.org/10.5281/zenodo.14920028},
}This work was supported by the Hartree National Centre for Digital Innovation, a collaboration between the Science and Technology Facilities Council and IBM.