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

Fix idle qubit detection to ignore barriers #639

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

Conversation

raunakkumarsingh
Copy link

@raunakkumarsingh raunakkumarsingh commented Jul 16, 2024

Fixes #621
Check for Barriers:
Added if instruction.operation.name == 'barrier': continue to skip over barrier operations during the idle wire detection process.
Iterate Through Instructions:

For each instruction, if it is not a barrier, it iterates through the qubits involved in the instruction and removes those qubit indices from the idle_wires set.
Filter Qubit Subsets:

The qubit_subsets list is filtered to remove any subsets that consist of only one qubit, and that qubit is in the idle_wires set.

@CLAassistant
Copy link

CLAassistant commented Jul 16, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@raunakkumarsingh
Copy link
Author

Added if instruction.operation.name == 'barrier': continue to skip over barrier operations during the idle wire detection process.

@coveralls
Copy link

coveralls commented Jul 16, 2024

Pull Request Test Coverage Report for Build 10002802415

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

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 9983091228: 0.0%
Covered Lines: 2412
Relevant Lines: 2412

💛 - Coveralls

@garrison
Copy link
Member

It'd be nice to have an explicit test for this behavior, too.

@garrison
Copy link
Member

The lint failure can be fixed by merging main into this branch once #640 has been merged to main.

@garrison
Copy link
Member

@raunakkumarsingh, thank you for this contribution. Do you plan to add a test and merge main into this branch, or should I do it?

@raunakkumarsingh
Copy link
Author

I have added tests for the barrier Ignore and rebased my branch.

@garrison
Copy link
Member

garrison commented Jul 18, 2024

Thank you. Please run tox -e style and make sure that tox -e lint passes.

@garrison garrison added bug Something isn't working cutting QPD-based circuit cutting code labels Jul 18, 2024
@raunakkumarsingh
Copy link
Author

corrected lint

circuit.y(2)
circuit.h(2)

separated_circuits = separate_circuit(circuit, partition_labels="ABC")
Copy link
Member

Choose a reason for hiding this comment

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

Actually, I believe this test does not actually check that the relevant bug is fixed.

The idle wire detection code only runs when partition_labels is not provided (or is None). In this case, the partition labels are determined automatically from the connectivity of the circuit. #594 improved on this code so that idle wires are removed from the circuit during separation, but the problem is that any qubit with a barrier (e.g., if a barrier is placed over all qubits, even the idle ones) will be falsely detected as an active qubit. Your change should indeed fix #621 but the test does not ensure that it is fixed. The test is actually almost testing the check desired in #626, but not quite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cutting QPD-based circuit cutting code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An idle qubit should still be considered idle even if it has a barrier
4 participants