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

Adding a TreeScan Gate Removal pass to parallelize Scanning Gate #240

Merged
merged 14 commits into from
Aug 5, 2024

Conversation

jkalloor3
Copy link
Contributor

For several circuits of medium width 7-20ish qubits, GPU-enhanced QFactor allows us to run instantiation quickly in order to do a large-block ScanningGate removal. For these workflows, there are very few blocks, which limits our parallelism. In order to fix this, this PR adds a tree structure to ScanningGate removal. The TreeScan works as follows:

  1. Split the circuit operations into chunks of size tree_depth
  2. At every iteration:
    a. Look at the next chunk of operations
    b. Generate 2 ^ tree_depth circuits. Each circuit corresponds to every combination of whether or not to include one of the operations in the chunk.
    c. Instantiate in parallel all 2^tree_depth circuits
    d. Choose the circuit that has the least number of operations and move on to the next chunk of operations.

This optimization is less greedy than the current ScanningGate removal, which we see can offer much better quality circuits than ScanningGate. In very rare occasions, ScanningGate may be able to outperform TreeScan (since it is still greedy), but in general we can expect TreeScan to almost always outperform ScanningGate.

Copy link
Member

@edyounis edyounis left a comment

Choose a reason for hiding this comment

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

Good PR. Minor changes requested

bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/processing/treescan.py Show resolved Hide resolved
bqskit/passes/processing/treescan.py Show resolved Hide resolved
bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/processing/treescan.py Show resolved Hide resolved
bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/__init__.py Show resolved Hide resolved
@jkalloor3 jkalloor3 requested a review from edyounis May 15, 2024 21:35
Copy link
Member

@edyounis edyounis left a comment

Choose a reason for hiding this comment

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

You did not address a few comments from the previous review. I am not a fan of how GitHub collapses the comments, so you probably missed them. You might need to expand the ones in the middle. Let me know if you need help here.

Otherwise, it looks much better. All of my comments this time around were focused on the documentation. We should make sure the code you write is properly documented; it will ensure others can use, maintain, and expand your code. Once you push up a commit, you can check how the documentation looks by clicking on the readthedocs CI check.

bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/processing/treescan.py Show resolved Hide resolved
bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
bqskit/passes/processing/treescan.py Outdated Show resolved Hide resolved
@edyounis edyounis merged commit 4483593 into BQSKit:main Aug 5, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants