SynthesizeRZRotations
class qiskit.transpiler.passes.SynthesizeRZRotations(*args, **kwargs)
Bases: TransformationPass
Replace RZ gates with Clifford+T decompositions.
This pass replaces all single-qubit RZ rotation gates with floating-point angles by equivalent Clifford+T sequences.
Internally, the pass synthesizes RZ(theta) for a general theta by reducing the angle modulo pi/2: the circuit for RZ(theta) can be constructed from a circuit for RZ(theta mod pi/2) by appending appropriate Clifford gates. Importantly, the pass also caches synthesis results and reuses them for angles that are within a given tolerance of each other.
For example:
from qiskit.circuit import QuantumCircuit
from qiskit.transpiler.passes import SynthesizeRZRotations
from qiskit.quantum_info import Operator
from numpy import pi
# The following quantum circuit consists of 5 Clifford gates
# and three single-qubit RZ rotations gates
qc = QuantumCircuit(4)
qc.cx(0, 1)
qc.rz(9*pi/4, 0)
qc.cz(0, 1)
qc.rz(3*pi/8, 1)
qc.h(1)
qc.s(2)
qc.rz(13*pi/2, 2)
qc.cz(2, 0)
qc.rz(5*pi/3, 3)
qct = SynthesizeRZRotations()(qc)
# The transformed circuit consists of Clifford, T and Tdg gates
clifford_t_names = get_clifford_gate_names() + ["t"] + ["tdg"]
assert(set(qct.count_ops().keys()).issubset(set(clifford_t_names)))
# The circuits before and after the transformation are equivalent
# (with the default value of approximation_degree used by SynthesizeRZRotations)
assert Operator(qc) == Operator(qct)If both synthesis_error and cache_error are provided, they specify the error budget for approximate synthesis and for caching respectively. If either value is not specified, the total allowed error is derived from approximation_degree, and suitable values for synthesis_error and cache_error are computed automatically.
Parameters
- approximation_degree – Controls the overall degree of approximation. Defaults to
1 - 1e-10. - synthesis_error – Maximum allowed error for the approximate synthesis of .
- cache_error – Maximum allowed error when reusing a cached synthesis result for angles close to .
Attributes
is_analysis_pass
Check if the pass is an analysis pass.
If the pass is an AnalysisPass, that means that the pass can analyze the DAG and write the results of that analysis in the property set. Modifications on the DAG are not allowed by this kind of pass.
is_transformation_pass
Check if the pass is a transformation pass.
If the pass is a TransformationPass, that means that the pass can manipulate the DAG, but cannot modify the property set (but it can be read).
Methods
execute
execute(passmanager_ir, state, callback=None)
Execute optimization task for input Qiskit IR.
Parameters
- passmanager_ir (Any) – Qiskit IR to optimize.
- state (PassManagerState) – State associated with workflow execution by the pass manager itself.
- callback (Callable | None) – A callback function which is called per execution of optimization task.
Returns
Optimized Qiskit IR and state of the workflow.
Return type
name
run
update_status
update_status(state, run_state)
Update workflow status.
Parameters
- state (PassManagerState) – Pass manager state to update.
- run_state (RunState) – Completion status of current task.
Returns
Updated pass manager state.
Return type