Qiskit MPS Initializer
State preparation with layers of one- and two-qubit gates from matrix product states (MPS), for circuits much shallower than exact state preparation at the cost of an approximation. Its releases up to 0.2.4 are on PyPI as qiskit-mps-initializer.
Installation
pip install qiu-mps-initializer
Layers of MPS gates
mps builds the layers (Ran, Phys. Rev. A 101, 032310, 2020):
bond2_mps_approximation(state)truncates a state of 2 qubits or more to an MPS of bond dimension at most 2.disentangler_matrices(mps)completes the tensors of such an MPS to unitaries, a two-qubit one per site but the last and a single-qubit one for the last.mps_layer(mps)places them into the circuitUwithU|0...0>the state of the MPS: the two-qubit gates on neighboring qubits from the most significant one down, then the single-qubit gate on qubit 0.
State preparation
state_preparation.mps_state_preparation(state, max_layers, tolerance=None) prepares a state with at most max_layers layers. Each layer prepares the bond-2 approximation of what the layers before it leave, the residual U_k^dagger ... U_1^dagger |state>, until the residual reaches |0...0>: by default when it equals it as a Qiskit Statevector, up to Qiskit's tolerances, or within the distance tolerance. The result holds the circuit, its layers, the error of the prepared state, i.e. its distance to the target including the global phase, and whether it converged.
States of up to 3 qubits and product states are prepared exactly by one layer. For more qubits, the error decreases with the number of layers, though not always monotonically, and slowly for highly entangled states.
Usage
import numpy as np
from qiskit.quantum_info import Statevector
from qiu_mps_initializer.state_preparation import mps_state_preparation
rng = np.random.default_rng(0)
state = rng.normal(size=32) + 1j * rng.normal(size=32)
state /= np.linalg.norm(state)
preparation = mps_state_preparation(state, max_layers=20)
fidelity = abs(np.vdot(Statevector(preparation.circuit).data, state)) ** 2
assert fidelity > 0.99 and preparation.num_layers == 20
The state of an intensity signal f = alpha |psi|**2, e.g. of a qiu-signals signal, follows from qiu_quantum_computing.phase_propagator.sample_based.sample_based_decomposition(signal).
Changes from version 0.2
The functionality of version 0.2 is carried over onto the packages of this monorepo:
| 0.2 | now |
|---|---|
QuantumState.from_dense_data(data, normalize) |
a Qiskit Statevector, validated by qiu_qiskit_encore |
QuantumState.generate_mps_initializer_circuit(layers) |
mps_state_preparation(state, max_layers).circuit |
QuantumIntensity |
qiu_quantum_computing.phase_propagator.sample_based.sample_based_decomposition |
helpers.mps_technique.G_matrices |
mps.disentangler_matrices |
helpers.mps_technique.multi_layered_circuit_for_non_approximated |
mps_state_preparation |
helpers.sampling_and_data_preperation |
qiu_signals axes and AlgebraicSignal.from_sympy |
utils.simulate_statevector, simulate_quantum_info |
Statevector(circuit), or qiu_qiskit_aer_encore.simulator.aer_simulator |
Besides:
max_layersis required and bounds the number of layers; formerly, one layer more than asked for could be added, and without a maximum the construction could run forever.- Single-qubit states are supported.
- The package no longer depends on
pydantic,pydantic-numpyandqiskit-aer.
Documentation
The documentation, with the API reference from the docstrings, is built from docs/ with MkDocs and published at https://blackwild.github.io/qiu/qiu-mps-initializer/. To serve it locally, from the repository root:
uv run mkdocs serve -f packages/qiu-mps-initializer/mkdocs.yml
Tests
From the repository root:
uv run pytest packages/qiu-mps-initializer
Release files for qiu-mps-initializer 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qiu_mps_initializer-0.3.0.tar.gz | 6.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qiu_mps_initializer-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.8 kB
Release files / qiu_mps_initializer-0.3.0.tar.gz
| Download URL | qiu_mps_initializer-0.3.0.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b006f822d82eaef088baad4b73802f9abfca0283c3a12e0be3668122dc8b02eb
|
|
BLAKE2b-256 checksum How to use checksums |
2d885e5281393e465472fd26ab4015c7e31556f900fb008aa0e8a1882da1e8f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / qiu_mps_initializer-0.3.0-py3-none-any.whl
| Download URL | qiu_mps_initializer-0.3.0-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa6c09f407f655a4a22c509814853937b4d3ce5116d35d4f54b8fd70b99772bc
|
|
BLAKE2b-256 checksum How to use checksums |
eae190f088514e9740cd6a4620f058dea6f24f8fb145a26fee030d87847ec8c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|