-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 collect_from_back
to CollectMultiQBlocks
#13612
Conversation
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 12668777162Warning: 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.
This looks like a straightforward new feature and implementation, thanks. One minor testing question only.
pass_ = CollectMultiQBlocks(max_block_size=3, collect_from_back=False) | ||
pass_.run(dag) | ||
expected_blocks = [[topo_ops[0], topo_ops[1], topo_ops[2]], [topo_ops[3], topo_ops[4]]] | ||
self.assertTrue(pass_.property_set["block_list"], expected_blocks) |
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.
Presumably you mean self.assertEqual
(and in the other place)? This is asserting non-emptiness of the pass_.property_set["block_list"]
, with a "message" field of expected_blocks
.
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.
Oops, of course! Fixed in 65a1aba.
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.
Cool, thanks!
Summary
This PR adds a new option
collect_from_back
to the transpiler passCollectMultiQBlocks
, leading to an increased flexibility of the pass. As an example, on the following circuitrunning the pass with
max_block_size=3
andcollect_from_back=False
(default), collects the first three gates (the H-gate and the two following CX-gates) into the first block, and the two remaining gates into the second block, while running the pass withmax_block_size=3
andcollect_from_back=True
(new), collects the last three gates into the second block, and the remaining two gates into the first block.