Skip to main content

MPS to circuit

DOI

Toolbox for converting matrix product states to Qiskit quantum circuits.

Usage with Quimb

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.arrays

You can now convert the list of tensors to a Qiskit QuantumCircuit using the mps_to_circuit interface function, specifying the shape as $(v_L, v_R, p)$ (this is also the default argument for 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)

Usage with TenPy

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 $(v_L, p, v_R)$.

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)

Development

Installation

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 .

Testing

One can test the code using pytest .

uv run pytest

Linting

One can lint the code using the Ruff Linter.

uv run ruff check

Formatting

One can format the code using the Ruff Formatter.

uv run ruff format

Code of conduct

All members of this project agree to adhere to the Qiskit Code of Conduct listed here.

Citation

If you use mps-to-circuit please cite as per the BibTeX below.

@software{mpstocircuit2025,
  author       = {D. A. Millar,
                  G. W. Pennington,
                  N. T. M. Siow and
                  S. J. Thomson},
  title        = {qiskit-community/mps-to-circuit},
  month        = feb,
  year         = 2025,
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.14920029},
  url          = {https://doi.org/10.5281/zenodo.14920029},
}

Acknowledgements

This work was supported by the Hartree National Centre for Digital Innovation, a collaboration between the Science and Technology Facilities Council and IBM.

License

Apache-2.0 license

Metadata

Release files for mps-to-circuit 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mps-to-circuit 0.1.2
File Size Uploaded Provenance
mps_to_circuit-0.1.2.tar.gz 11.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mps-to-circuit 0.1.2
File Interpreter ABI Platform
mps_to_circuit-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 25.3 kB

Release files / mps_to_circuit-0.1.2.tar.gz

Download URL mps_to_circuit-0.1.2.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fb38f44013cc9939de3128d655f7ba7149b5c9d3abefe17548020c111db64521
BLAKE2b-256 checksum
How to use checksums
6152799003234f5d4ceac827e7b58f6dc92109e635a8d191c1f5ffdae39f66f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.6.5

Release files / mps_to_circuit-0.1.2-py3-none-any.whl

Download URL mps_to_circuit-0.1.2-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8647efe676562a69e0e0d1d64def22020644f8bdf8255603f9e9bd6fe1f44eb3
BLAKE2b-256 checksum
How to use checksums
981ee1bdaca063cb8501bd44e499184b2906eece0b599171a056eabc47937736
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.6.5

Security for mps-to-circuit 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page