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 max_block_width to CollectLinearFunctions and CollectClifford passes #13661

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alexanderivrii
Copy link
Contributor

@alexanderivrii alexanderivrii commented Jan 14, 2025

Summary

This PR adds a new argument max_block_width to the class BlockCollector and to the transpiler passes CollectLinearFunctions and CollectCliffords 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 the CollectMultiQBlocks transpiler pass (though naming-wise, I am calling this "width" instead of "size", which is how it should be using the terminology of DAGCircuit and QuantumCircuit).

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 and CollectMultiQBlocks:

  1. BlockCollector allows to only collect nodes that match a given "filter function" and treat other nodes as "should not be collected", while CollectMultiQBlocks collects all nodes (in particular, CollectMultiQBlocks cannot be used to only collect say Clifford gates within in a larger circuit).

  2. BlockCollector can collect nodes exploiting commutativity of nodes within the DAG; CollectMultiQBlocks does not have this functionality. BlockCollector has other options that CollectMultiQBlocks does not have.

  3. 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.

  4. Both BlockCollector and CollectMultiQBlocks are greedy, however CollectMultiQBlocks 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.

@alexanderivrii alexanderivrii requested a review from a team as a code owner January 14, 2025 12:12
@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 14, 2025
@alexanderivrii alexanderivrii added this to the 2.0.0 milestone Jan 14, 2025
@coveralls
Copy link

coveralls commented Jan 14, 2025

Pull Request Test Coverage Report for Build 12784006415

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

  • 19 of 19 (100.0%) changed or added relevant lines in 1 file are covered.
  • 28 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.02%) to 88.911%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/two_qubit_decompose.rs 1 92.13%
crates/qasm2/src/lex.rs 4 92.48%
qiskit/qasm3/exporter.py 5 96.2%
crates/qasm2/src/parse.rs 18 96.69%
Totals Coverage Status
Change from base Build 12765737818: -0.02%
Covered Lines: 79437
Relevant Lines: 89344

💛 - Coveralls

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: To do
Development

Successfully merging this pull request may close these issues.

3 participants