fiqci.ems.transpiler_passes.pauli_twirl#
Functions
|
Generate twirled circuits from input circuits. |
Classes
|
Add Pauli twirls to two-qubit gates. |
- class PauliTwirl(*args, **kwargs)#
Bases:
TransformationPassAdd Pauli twirls to two-qubit gates.
- __init__(gates_to_twirl: Iterable[Gate] | None = None, seed=None)#
- Parameters:
gates_to_twirl – Gates to twirl. The default behavior is to twirl all two-qubit basis gates.
seed – Seed or numpy Generator for the random twirl selection. Passing an existing Generator shares its state (and is returned unchanged by
np.random.default_rng), so a single Generator can drive many twirls reproducibly.
- run(dag: DAGCircuit) DAGCircuit#
Run a pass on the DAGCircuit. This is implemented by the pass developer.
- Parameters:
dag – the dag on which the pass is run.
- Raises:
NotImplementedError – when this is left unimplemented for a pass.
- get_twirled_circuits(circuits: list[QuantumCircuit], num_twirls: int, gates_to_twirl: Iterable[Gate] | None = None, backend: IQMBackendBase | None = None, seed=None) list[QuantumCircuit]#
Generate twirled circuits from input circuits.
For each input circuit, produces the original circuit followed by num_twirls twirled copies, giving groups of (num_twirls + 1) circuits in a flat list.
- Parameters:
circuits – List of QuantumCircuits to generate twirled circuits from.
num_twirls – Number of twirled circuits to generate per input circuit.
gates_to_twirl – Optional list of gates to twirl, if None, all two-qubit basis gates will be twirled. backend: The backend to transpile the circuits for.
seed – Seed for the random twirl selection. One Generator is shared across every generated circuit, so each twirl differs while the run as a whole is reproducible.
- Returns:
[orig_0, twirl_0_1, …, twirl_0_T, orig_1, twirl_1_1, …, twirl_1_T, …].
- Return type:
Flat list of circuits