generate_boxing_pass_manager¶
- samplomatic.transpiler.generate_boxing_pass_manager(enable_gates: bool = True, enable_measures: bool = True, measure_annotations: str = 'twirl', twirling_strategy: TwirlingStrategy | Literal['active', 'active_accum', 'all', 'active_circuit'] = 'active', inject_noise_targets: Literal['none', 'gates', 'measures', 'all'] = 'none', inject_noise_strategy: NoiseInjectionStrategy | Literal['no_modification', 'uniform_modification', 'individual_modification'] = 'no_modification', remove_barriers: bool = True) PassManager[source]¶
Construct a pass manager to group the operations in a circuit into boxes.
This function can be used to construct a new
qiskit.transpiler.PassManagerthat puts the instructions of the circuit into annotated boxes.>>> from qiskit.circuit import QuantumCircuit >>> from samplomatic.transpiler import generate_boxing_pass_manager >>> >>> # Create a simple circuit to test with >>> circuit = QuantumCircuit(3) >>> circuit.cz(0, 1) >>> circuit.cz(1, 2) >>> circuit.measure_all() >>> >>> pm = generate_boxing_pass_manager() >>> >>> boxed_circuit = pm.run(circuit) >>> boxed_circuit.draw("mpl")
To group instructions into boxes, a pass manager returned by this function takes the following steps in order:
If
remove_barriersisTrue, it removes all the barriers in the input circuit using theqiskit.transpiler.passes.RemoveBarrierspass.If
enable_gatesisTrue, using theGroupGatesIntoBoxespass, it creates boxes containing two-qubit gates and the single-qubit gates that preceed them. The resulting boxes are twirl-annotated and left-dressed, and contain a single layer of two-qubit gates.If
enable_measuresisTrue, it uses theGroupMeasIntoBoxespass to group the measurements. All the resulting boxes are left dressed. Depending on the value ofmeasure_annotations, they own aTwirlannotation, aChangeBasisannotation, or both.It adds idling qubits to the boxes following the given
twirling_strategy.Using the
AddTerminalRightDressedBoxespass, it adds right-dressed boxes to ensure that the resulting pass manager can produce circuits that can be successfully turned into a template/samplex pair by thesamplomatic.build()function.If
inject_noise_targetsis not'none', it uses theAddInjectNoisepass to add inject noiseInjectNoiseannotations.
- Parameters:
enable_gates – Whether to collect single- and multi-qubit gates into boxes using the
GroupGatesIntoBoxespass.enable_measures – Whether to collect measurements into boxes using the
GroupMeasIntoBoxespass.measure_annotations –
The annotations placed on the measurement boxes by
GroupMeasIntoBoxeswhenenable_measuresisTrue. The supported values are:'twirl'for aTwirlannotation.'change_basis'for aChangeBasisannotation with modemeasure.'all'for bothTwirlandChangeBasisannotations.
twirling_strategy – The twirling strategy.
inject_noise_targets –
The boxes to annotate with an
InjectNoiseannotation using theAddInjectNoisepass. The supported values are:'none'to avoid annotating boxes of any kind.'gates'to annotate all the twirled boxes that contain entanglers, such as those created by theGroupGatesIntoBoxespass, and avoid annotating all the other boxes.'measures'to annotate all the twirled boxes that own a classical register, such as those created by theGroupMeasIntoBoxespass, and avoid annotating all the other boxes.'all'to target all the twirl-annotated boxes that contain entanglers and/or own classical registers.
inject_noise_strategy – The noise injection strategy for the
AddInjectNoisepass.remove_barriers – Whether to apply the
qiskit.transpiler.passes.RemoveBarrierspass to the input circuit before beginning to group gates and measurements into boxes. Setting this toTruegenerally leads to a smaller number of boxes in the output circuits.
- Returns:
A pass manager that groups operations into boxes.
- Raises:
TranspilerError – If the user selects a combination of inputs that is not supported.