qpe_toolbox.tensor.mpomps_tools¶
Functions¶
|
Build the MPO mapping the all-zero state to a target MPS. |
|
Construct the Kronecker (tensor) product of two MPOs. |
|
Construct the Kronecker (tensor) product of two MPS objects. |
|
Apply an MPO-defined gate to a circuit state and return a new CircuitMPS. |
|
Add a single control qubit to an MPO. |
|
Construct an MPO controlled on one of its qubits being in a given state. |
Module Contents¶
- qpe_toolbox.tensor.mpomps_tools.state_preparation_mpo(state_mps)[source]¶
Build the MPO mapping the all-zero state to a target MPS.
The MPO is the outer product \(2^n |\psi\rangle\langle 0|\) on \(n\) qubits. The \(2^n\) factor normalizes the transpilation overlap computed by
transpile_mpo_to_circuit().- Parameters:
state_mps (MatrixProductState) – Target MPS to be reproduced by some circuit Ansatz, with arrays in
'lpr'order.- Returns:
Reference MPO for circuit state preparation.
- Return type:
- Raises:
ValueError – If the arrays of
state_mpsare not in'lpr'order.
- qpe_toolbox.tensor.mpomps_tools.kron_mpos(mpo1, mpo2)[source]¶
Construct the Kronecker (tensor) product of two MPOs.
This returns an MPO representing \(\mathrm{MPO}_1 \otimes \mathrm{MPO}_2\), with tensors arranged in the left, right, up, down index ordering
The function supports both single-site and multi-site MPOs and handles boundary tensor reshaping explicitly.
- Parameters:
mpo1 (MatrixProductOperator) – First MPO operand.
mpo2 (MatrixProductOperator) – Second MPO operand.
- Returns:
The Kronecker product MPO acting on the concatenated Hilbert space.
- Return type:
- Raises:
ValueError – If the tensor shapes of either MPO are not compatible with the expected MPO boundary conventions.
- qpe_toolbox.tensor.mpomps_tools.kron_mps(mps1, mps2, *, verbosity=0)[source]¶
Construct the Kronecker (tensor) product of two MPS objects.
This returns an MPS representing \(\mathrm{MPS}_1 \otimes \mathrm{MPS}_2\), with tensors arranged in the left, right, physical index ordering.
- Parameters:
mps1 (MatrixProductState) – First MPS operand.
mps2 (MatrixProductState) – Second MPS operand.
verbosity (int, default
0) – If> 0, print the shapes of the resulting tensors.
- Returns:
The Kronecker product MPS on the combined physical register.
- Return type:
- Raises:
ValueError – If the tensor shapes of either MPS are not compatible with the expected MPS boundary conventions.
- qpe_toolbox.tensor.mpomps_tools.apply_gate_from_mpo(circ, mpo, *, compress=False, cutoff=1e-10, max_bond=0)[source]¶
Apply an MPO-defined gate to a circuit state and return a new CircuitMPS.
The MPO is applied to the circuit wavefunction
circ.psi. Optional compression can be performed during and/or after application.- Parameters:
circ (Circuit or CircuitMPS) – Input circuit whose state will be acted on.
mpo (MatrixProductOperator) – MPO representing the quantum gate or evolution operator.
compress (bool, default
False) – Whether to compress the resulting MPS during application.cutoff (float, default
1e-10) – Singular value cutoff used during compression.max_bond (int, default
0) – Maximum allowed bond dimension.0means no explicit limit.
- Returns:
New circuit with the updated MPS state.
- Return type:
Notes
This function does not modify the input circuit in place.
- qpe_toolbox.tensor.mpomps_tools.add_cqubit_mpo(mpo, location)[source]¶
Add a single control qubit to an MPO.
The control qubit is added either before or after the existing MPO, depending on register ordering.
- Parameters:
mpo (MatrixProductOperator) – Base MPO representing the target operation.
location ({"before", "after"}) – Whether to add the control qubit before or after the MPO qubits.
- Returns:
MPO augmented with a single control qubit.
- Return type:
- Raises:
ValueError – If
locationis not one of"before"or"after".
- qpe_toolbox.tensor.mpomps_tools.controlled_mpo(mpo, k_ctrl, *, ctrl=1)[source]¶
Construct an MPO controlled on one of its qubits being in a given state.
The control qubit must carry the identity in
mpo, which is replaced by a projector; the rest ofmpobecomes the controlled operation.- Parameters:
mpo (MatrixProductOperator) – Input MPO, acting as the identity on site
k_ctrl.k_ctrl (int) – Site index of the control qubit.
ctrl (int, default
1) – Control value (0or1) conditioning the operation.
- Returns:
Controlled MPO.
- Return type:
- Raises:
ValueError – If
mpodoes not factorize as the identity on sitek_ctrl.