qiu_mps_initializer.state_preparation
¶
Approximate state preparation with layers of MPS gates.
Each layer prepares the MPS of bond dimension 2 approximating the part of the state that
the layers before it leave: with the residual |r> = U_k^dagger ... U_1^dagger |state>
of k layers, the next layer U_(k+1) prepares the bond-2 approximation of |r>. The
circuit U_1 ... U_k then prepares |state> up to the error || |r> - |0...0> ||,
global phase included.
States of up to 3 qubits have bond dimension at most 2, so one layer prepares them exactly. For more qubits, the error decreases with the number of layers, though not always monotonically.
Classes:
-
MPSStatePreparation–A circuit preparing a state approximately from
|0...0>, with its error.
Functions:
-
mps_state_preparation–Return the circuit of at most
max_layersMPS layers preparing a state.
MPSStatePreparation
dataclass
¶
MPSStatePreparation(circuit: QuantumCircuit, layers: tuple[QuantumCircuit, ...], error: float, converged: bool)
A circuit preparing a state approximately from |0...0>, with its error.
Attributes:
-
circuit(QuantumCircuit) –The circuit, its layers applied in order.
-
layers(tuple[QuantumCircuit, ...]) –The layers of the circuit, in the order they are applied.
-
error(float) –The distance of the prepared state to the target, global phase included.
-
converged(bool) –Whether the prepared state reached the target within the tolerance.
-
num_layers(int) –The number of layers.
layers
instance-attribute
¶
layers: tuple[QuantumCircuit, ...]
The layers of the circuit, in the order they are applied.
error
instance-attribute
¶
error: float
The distance of the prepared state to the target, global phase included.
mps_state_preparation
¶
mps_state_preparation(state: Statevector | ArrayLike, max_layers: int, tolerance: float | None = None) -> MPSStatePreparation
Return the circuit of at most max_layers MPS layers preparing a state.
Layers are added until the prepared state reaches the target, or max_layers.
Parameters:
-
state(Statevector | ArrayLike) –The normalized state, of at least one qubit.
-
max_layers(int) –The maximum number of layers, at least 1.
-
tolerance(float | None, default:None) –The distance to the target, global phase included, below which the prepared state reaches it. By default, it reaches it when it equals the target as a Qiskit
Statevector, i.e. up to Qiskit's tolerances.
Returns:
-
MPSStatePreparation–The circuit, its layers and the error of the prepared state.
Raises:
-
ValueError–If
max_layersis smaller than 1, or if the state is not a normalized state of at least one qubit.
Source code in packages/qiu-mps-initializer/src/qiu_mps_initializer/state_preparation.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |