qcmet.utils.PauliTwirl#
- class qcmet.utils.PauliTwirl(gates_to_twirl=None, seed=None)[source]#
Randomly insert Pauli twirls around chosen two-qubit gates.
For each targeted gate occurrence, the pass inserts a left and right Pauli so that the overall action is equivalent (up to global phase). By default, CX, ECR, and CZ are twirled.
- gates_to_twirl#
Iterable of two-qubit gate instances whose base classes define which gates are twirled.
- twirl_set#
Mapping from gate name to valid Pauli pairs on two qubits.
- __init__(gates_to_twirl=None, seed=None)[source]#
Initialise the pass.
- Parameters:
gates_to_twirl (optional, Iterable[Gate]) – Gates to twirl. If
None, twirls CX, ECR, and CZ.seed (optional, int) – Seeding random Pauli twirl pair selection. Defaults to None.
Methods
__init__([gates_to_twirl, seed])Initialise the pass.
Precompute valid two-qubit Pauli pairs for each target gate.
execute(passmanager_ir, state[, callback])Execute optimization task for input Qiskit IR.
name()Name of the pass.
run(dag)Insert Pauli twirls around matching two-qubit gate nodes.
update_status(state, run_state)Update workflow status.
Attributes
is_analysis_passCheck if the pass is an analysis pass.
is_transformation_passCheck if the pass is a transformation pass.
- build_twirl_set()[source]#
Precompute valid two-qubit Pauli pairs for each target gate.
A pair
(P_left, P_right)is kept ifOperator(P_left) @ Operator(gate)is equivalent toOperator(gate) @ Operator(P_right)up to global phase.
- run(dag)[source]#
Insert Pauli twirls around matching two-qubit gate nodes.
For each matched node, replace it by
P_left -> gate -> P_rightwith a uniformly random Pauli pair fromself.twirl_set. If a seed is set on initialization of class, then it will be used here.- Parameters:
dag (
DAGCircuit) – Input DAGCircuit.- Return type:
- Returns:
The modified DAGCircuit.