-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option max_block_width
to CollectLinearFunctions
and CollectClifford
passes
#13661
Conversation
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 12991606884Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I only have some minor comments on the tests.
what happens if you take this circuit:
with |
In general, the problem of "optimally" dividing a circuit into blocks is "hard" (and in fact NP-hard for suitable notions of "optimality"). In practice, which blocks get collected depends on the order in which the nodes are processed and on other options given to I would say we should care about this when we think about resynthesis, as collecting different blocks gives rise to different resynthesis opportunities. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @alexanderivrii
…llectClifford`` passes (Qiskit#13661) * new option max_block_width for CollectCliffords and CollectLinearFunctions passes * release notes * improving release notes * refactoring tests as per review comments * renaming max_width to max_block_width in comment
Summary
This PR adds a new argument
max_block_width
to the classBlockCollector
and to the transpiler passesCollectLinearFunctions
andCollectCliffords
that are based on this class. This argument enforces block collection strategies to restrict the maximum number of qubits over which a block of nodes is defined.This option is similar to the option
max_block_size
in theCollectMultiQBlocks
transpiler pass (though naming-wise, I am calling this "width" instead of "size", which is how it should be using the terminology ofDAGCircuit
andQuantumCircuit
).The implementation is based on the adaptation of
BlockCollector
in AI resynthesis passes (including a small cleanup for updating the frontier nodes).Details and comments
Somewhat related to the PR, here is a more refined difference between
BlockCollector
andCollectMultiQBlocks
:BlockCollector
allows to only collect nodes that match a given "filter function" and treat other nodes as "should not be collected", whileCollectMultiQBlocks
collects all nodes (in particular,CollectMultiQBlocks
cannot be used to only collect say Clifford gates within in a larger circuit).BlockCollector
can collect nodes exploiting commutativity of nodes within the DAG;CollectMultiQBlocks
does not have this functionality.BlockCollector
has other options thatCollectMultiQBlocks
does not have.Both can now collect nodes "forward-wise" from the inputs towards the ouputs of a circuit, and
backward-wise
from the outputs towards the inputs.Both
BlockCollector
andCollectMultiQBlocks
are greedy, howeverCollectMultiQBlocks
is smarter, in the following way.BlockCollector
greedily collects one block at a time, greedily trying to add nodes into the block being collected. In particular it may create "disconnected" blocks . On the other hand,CollectMultiQBlocks
(with the implementation based on the disjoint set union data structure) produces connected blocks by construction.