mirror of https://github.com/Qiskit/qiskit.git
79 lines
3.8 KiB
YAML
79 lines
3.8 KiB
YAML
---
|
|
features:
|
|
- |
|
|
Added a new base transpiler pass, :class:`~CollectAndCollapse`, to collect and to consolidate
|
|
blocks of nodes in a circuit. To be completely general, this pass depends on two functions:
|
|
the collection function and the collapsing function. The collection function ``collect_function``
|
|
takes a DAG and returns a list of blocks. The collapsing function ``collapse_function``
|
|
takes a DAG and a list of blocks, consolidates each block, and returns the modified
|
|
DAG.
|
|
|
|
As two examples, the inherited :class:`~CollectLinearFunctions`
|
|
collects blocks of :class:`.CXGate` and :class:`.SwapGate` gates, and replaces
|
|
each block with a :class:`.LinearFunction`, while the inherited class
|
|
:class:`~CollectCliffords` collects blocks of "Clifford" gates and replaces
|
|
each block with a :class:`qiskit.quantum_info.Clifford`.
|
|
|
|
To allow code reuse between the collection and collapsing functions of inherited classes,
|
|
added a new class :class:`~BlockCollector` that implements various collection strategies,
|
|
and a new class :class:`~BlockCollapser` that implements various collapsing strategies.
|
|
Currently :class:`~BlockCollector` includes the strategy to greedily collect all gates
|
|
adhering to a given filter function (for example, collecting all Clifford gates), and
|
|
:class:`~BlockCollapser` includes the strategy to consolidate all gates in a block to a
|
|
single object (or example, a block of Clifford gates can be consolidated to a single
|
|
``Clifford``).
|
|
|
|
The interface also supports the option ``do_commutative_analysis``, which allows
|
|
to exploit commutativity between gates in order to collect larger blocks of nodes.
|
|
As an example, collecting blocks of CX gates in the following circuit::
|
|
|
|
qc = QuantumCircuit(2)
|
|
qc.cx(0, 1)
|
|
qc.z(0)
|
|
qc.cx(1, 0)
|
|
|
|
allows to consolidate the two CX gates, as the first CX gate and the Z-gate commute.
|
|
|
|
- |
|
|
Added a new :class:`~CollectCliffords` transpiler pass that collects blocks of clifford
|
|
gates and consolidates these blocks into :class:`qiskit.quantum_info.Clifford` objects.
|
|
This pass inherits from :class:`~CollectAndCollapse` and in particular supports the option
|
|
``do_commutative_analysis``.
|
|
It also supports two additional options ``split_blocks`` and ``min_block_size``.
|
|
See the release notes for :class:`~CollectAndCollapse` and :class:`~CollectLinearFunctions`
|
|
for additional details.
|
|
|
|
upgrade:
|
|
- |
|
|
Modified the :class:`~CollectLinearFunctions` transpiler pass to inherit from
|
|
:class:`~CollectAndCollapse`. In particular it supports the option
|
|
``do_commutative_analysis`` that allows to exploit commutativity between gates
|
|
in order to collect larger blocks of nodes. See the release notes
|
|
for :class:`~CollectAndCollapse` for an explicit example.
|
|
|
|
In addition, :class:`~CollectLinearFunctions` supports new
|
|
options ``split_blocks`` and ``min_block_size``.
|
|
|
|
The option ``split_blocks`` allows to split collected blocks into sub-blocks over
|
|
disjoint subsets of qubits. As an example, in the following circuit::
|
|
|
|
qc = QuantumCircuit(4)
|
|
qc.cx(0, 2)
|
|
qc.cx(1, 3)
|
|
qc.cx(2, 0)
|
|
qc.cx(3, 1)
|
|
qc.cx(1, 3)
|
|
|
|
the single block of CX gates over qubits ``{0, 1, 2, 3}`` can be split into two disjoint
|
|
sub-blocks, one over qubits ``{0, 2}`` and the other over qubits ``{1, 3}``.
|
|
|
|
The option ``min_block_size`` allows to specify the minimum size of the block to be consolidated,
|
|
blocks with fewer gates will not be modified. As an example, in the following circuit::
|
|
|
|
qc = QuantumCircuit(4)
|
|
qc.cx(1, 2)
|
|
qc.cx(2, 1)
|
|
|
|
the two CX gates will be consolidated when ``min_block_size`` is 1 or 2, and will remain unchanged
|
|
when ``min_block_size`` is 3 or larger.
|