GroupGatesIntoBoxes¶
- class samplomatic.transpiler.passes.GroupGatesIntoBoxes(*args, **kwargs)[source]¶
Bases:
TransformationPassCollect the two-qubit gates in a circuit inside left-dressed boxes.
This pass collects all 2-qubit gates in the input circuit into left-dressed boxes. To assign the gates to these boxes, it uses a greedy collection strategy that tries to collect gates in the earliest possible box that they can fit.
Note
Barriers and boxes that are present in the input circuit act as delimiters. This means that when the pass encounters one of these delimiters acting on a subset of qubits, it immediately terminates the collection for those qubits and flushes the collected gates into a left-dressed box. The delimiters themselves remain present in the output circuit, but are placed outside of any boxes.
Note
Measurements also act as delimiters.
Note
The circuits returned by this pass may not be buildable. To make them buildable, one can either use :class`~.AddTerminalRightDressedBoxes` to add right-dressed “collector” boxes.
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 two-qubit gate 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 topological ordering.
When looping is complete, replace each group with a box.