SubstitutePi4Rotations
class qiskit.transpiler.passes.SubstitutePi4Rotations(*args, **kwargs)
Bases: TransformationPass
Convert single-qubit rotation gates RZGate, RXGate and RYGate, whose angles are integer multiples of into discrete sets of Clifford, TGate and TdgGate gates.
Note that odd multiples of require a single TGate or TdgGate, as well as some Clifford gates, while even multiples of , or equivalently, integer multiples of , can be written using only Clifford gates. The output contains at most one TGate or TdgGate, and an optimal number of Clifford gates.
For example:
from qiskit.circuit import QuantumCircuit
from qiskit.transpiler.passes import SubstitutePi4Rotations
from qiskit.quantum_info import Operator
# The following quantum circuit consists of 5 Clifford gates
# and three single-qubit rotation gates whose angles are integer multiples of pi/4.
qc = QuantumCircuit(3)
qc.cx(0, 1)
qc.rz(pi/4, 0)
qc.cz(0, 1)
qc.rx(3*pi/4, 1)
qc.h(1)
qc.s(2)
qc.ry(2*pi/4, 2)
qc.cz(2, 0)
# The transformed circuit consists of Clifford, T and Tdg gates
qct = SubstitutePi4Rotations()(qc)
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
assert Operator(qc) == Operator(qct)Parameters
approximation_degree – Used in the tolerance computations. This gives the threshold for the average gate fidelity.
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 caller per execution of optimization task.
Returns
Optimized Qiskit IR and state of the workflow.
Return type
tuple[Any, qiskit.passmanager.compilation_status.PassManagerState]
name
run
run(dag)
Run the Substitute Pi4-Rotations optimization pass on dag.
Parameters
dag (DAGCircuit) – the input DAG.
Returns
The output DAG.
Return type
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