GroupMeasIntoBoxes
class samplomatic.transpiler.passes.GroupMeasIntoBoxes(*args, **kwargs)
Bases: TransformationPass
Collect the measurements in a circuit inside boxes.
This pass collects all of the measurements in the input circuit in boxes. 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.
-
decomposition –
The gate sequence into which single-qubit dressing gates are synthesized.
'rzsx'synthesizes single-qubit gates with rz-sx-rz-sx-rz.'rzrx'synthesizes single-qubit gates with rz-rx-rz.
-
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.
Barriers, boxes, two-qubit gates, and resets act as delimiters. This means that when the pass encounters one of these on a subset of qubits, it immediately terminates the collection for those qubits and flushes the collected measurements into a box.
Methods Summary
Column 1 | Column 2 |
|---|---|
run(dag) | Collect the operations in the dag inside left-dressed boxes. |
Methods Documentation
run
run(dag: DAGCircuit) → DAGCircuit
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 measurement nodes 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 topological ordering.
- When looping is complete, replace each group with a box.