English
Languages
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

BlockCollector

class BlockCollector(dag)[source]

Bases: object

Class for implementing block collection on a DAG.

This class implements various strategies of dividing a DAG (direct acyclic graph) into blocks of nodes that satisfy certain criteria. It works both with the DAGCircuit and DAGDependency representations of a DAG, where DagDependency takes into account commutativity between nodes.

Collecting nodes from DAGDependency generally leads to more optimal results, but is slower, as it requires to construct a DAGDependency beforehand. Thus, DAGCircuit should be used with lower transpiler settings, and DAGDependency should be used with higher transpiler settings.

In general, there are multiple ways to collect maximal blocks. The approaches used here are of the form ‘starting from the input nodes of a DAG, greedily collect the largest block of nodes that match certain criteria’. For additional details, see https://github.com/Qiskit/qiskit-terra/issues/5775.

Parameters

dag (Union[DAGCircuit, DAGDependency]) – The input DAG.

Raises

DAGCircuitError – the input object is not a DAG.

Methods

collect_all_matching_blocks

Collects all blocks that match a given filtering function filter_fn.

collect_matching_block

Iteratively collects the largest block of input nodes