GroupMeasIntoBoxes¶
- class samplomatic.transpiler.passes.GroupMeasIntoBoxes(*args, **kwargs)[source]¶
Bases:
TransformationPassCollect the measurements in a circuit inside boxes.
This pass collects all of the measurements in the input circuit in boxes, together with the single-qubit gates that precede them. To assign the measurements to these boxes, it uses a greedy collection strategy that tries to collect measurements in the earliest possible box that they can fit.
- Parameters:
annotations –
The annotations placed on the measurement boxes. The supported values are:
'twirl'for aTwirlannotation.'change_basis'for aChangeBasisannotation with mode'measure'.'all'for bothTwirlandChangeBasisannotations.
prefix_ref – A prefix to all the
ChangeBasis.refgenerated by this class. Everyrefis generated by appending a counter toprefix_ref. In order to avoid collisions, the counter is shared across all the instances of this class and it is incremented every time that a newrefis created.
Note
Barriers, boxes, and multi-qubit gates that are present in the input circuit act as delimiters. This means that when one of these delimiters stands between a group of single-qubit gates and a measurement, those single-qubit gates are not added to the box.
Methods Summary
run(dag)Collect the operations in the dag inside left-dressed boxes.
Methods Documentation
- run(dag: DAGCircuit) DAGCircuit[source]¶
Collect the operations in the dag inside left-dressed boxes.
- The collection strategy undertakes the following steps:
Loop through the DAG’s op nodes in topological order.
Group together single-qubit gate nodes and measurement nodes that need to be placed in the same box.
Whenever a node can be placed in more than one group, place it in the earliest possible group–where “earliest” is with reference to opological ordering.
When looping is complete, replace each group with a box.