IterativeCommuteAndMerge#
- class pennylane_calculquebec.processing.steps.optimization.IterativeCommuteAndMerge#
Bases:
OptimizeDecomposes iteratively until the circuit contains only rotations. For each decomposition step, applies commutations, merges and cancellations
Methods
HCZH_cnot(wires)Decomposition for a cnot using CZ and H
Y_to_ZXZ(operation)Turn RY into RZ, RX and RZ
ZXZ_Hadamard(wires)Turns H into a combination of S, SX and S
execute(tape)decomposes swaps, cnots and hadamards iteratively.
get_rid_of_y_rotations(tape)Transforms all Y rotations in a tape to X and Z rotations
swap_cnot(wires)turns swaps into cnots
- static HCZH_cnot(wires)#
Decomposition for a cnot using CZ and H
- Parameters:
wires (WireLike) – Which wires should we decompose with?
- Raises:
ValueError – There should be exactly two wires
- Returns:
the list of operations corresponding to a CNOT using CZ and H
- Return type:
list[Operation]
- static Y_to_ZXZ(operation)#
Turn RY into RZ, RX and RZ
- Parameters:
operation (Operation) – a RY gate with arbitrary angle
- Raises:
ValueError – There should be exactly one wire
ValueError – The gate should be in the Y basis
- Returns:
The equivalent sequence of X/Z gates for an arbitrary Y rotation
- Return type:
list[Operation]
- static ZXZ_Hadamard(wires)#
Turns H into a combination of S, SX and S
- Parameters:
wires (WireLike) – What wires should we decompose with?
- Raises:
ValueError – There should be exactly one wire
- Returns:
a list of operations corresponding to H
- Return type:
list[Operation]
- execute(tape)#
decomposes swaps, cnots and hadamards iteratively. Then turns everything to Z and X rotations.
at each iteration, apply commutations, rotation merges, and trivial and inverse gates cancellations
- Parameters:
tape (QuantumTape) – the tape to optimize
- Returns:
an optimized QuantumTape
- Return type:
QuantumTape
- static get_rid_of_y_rotations(tape: QuantumTape)#
Transforms all Y rotations in a tape to X and Z rotations
- Parameters:
tape (QuantumTape) – the tape to act on
- Returns:
the processed tape
- Return type:
QuantumTape
- static swap_cnot(wires)#
turns swaps into cnots
- Parameters:
wires (WireLike) – which wires do the swap act on
- Returns:
cnot(a, b) cnot(b, a) cnot(a, b)
- Return type:
list[Operation]