Skip to content
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

Merged
merged 5 commits into from
Jan 8, 2025

Conversation

alexanderivrii
Copy link
Contributor

Summary

This PR adds a new option collect_from_back to the transpiler pass CollectMultiQBlocks, leading to an increased flexibility of the pass. As an example, on the following circuit

             ┌───┐
        q_0: ┤ H ├──■────■────■───────
             └───┘┌─┴─┐  │    │
        q_1: ─────┤ X ├──┼────┼───────
                  └───┘┌─┴─┐  │
        q_2: ──────────┤ X ├──┼───────
                       └───┘┌─┴─┐┌───┐
        q_3: ───────────────┤ X ├┤ H ├
                            └───┘└───┘

running the pass with max_block_size=3 and collect_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 with max_block_size=3 and collect_from_back=True (new), collects the last three gates into the second block, and the remaining two gates into the first block.

@alexanderivrii alexanderivrii requested a review from a team as a code owner January 6, 2025 09:59
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@alexanderivrii alexanderivrii added the Changelog: New Feature Include in the "Added" section of the changelog label Jan 6, 2025
@alexanderivrii alexanderivrii added this to the 2.0.0 milestone Jan 6, 2025
@coveralls
Copy link

coveralls commented Jan 6, 2025

Pull Request Test Coverage Report for Build 12668777162

Warning: 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

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • 340 unchanged lines in 12 files lost coverage.
  • Overall coverage decreased (-0.02%) to 88.933%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.02%
qiskit/circuit/library/standard_gates/rz.py 3 95.71%
qiskit/circuit/library/standard_gates/rx.py 3 95.95%
qiskit/circuit/library/standard_gates/ry.py 3 95.83%
crates/qasm2/src/lex.rs 5 91.73%
qiskit/primitives/containers/observables_array.py 5 95.0%
crates/qasm2/src/parse.rs 6 97.62%
crates/accelerate/src/commutation_checker.rs 16 97.41%
crates/accelerate/src/unitary_synthesis.rs 23 93.18%
qiskit/transpiler/passes/synthesis/hls_plugins.py 58 83.38%
Totals Coverage Status
Change from base Build 12630226525: -0.02%
Covered Lines: 79436
Relevant Lines: 89321

💛 - Coveralls

Copy link
Member

@jakelishman jakelishman left a 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.

test/python/transpiler/test_collect_multiq_blocks.py Outdated Show resolved Hide resolved
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)
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks!

@jakelishman jakelishman enabled auto-merge January 8, 2025 11:28
@jakelishman jakelishman added this pull request to the merge queue Jan 8, 2025
Merged via the queue into Qiskit:main with commit 55d2da8 Jan 8, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog
Projects
Status: done
Development

Successfully merging this pull request may close these issues.

4 participants