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

Allow barriers in overlap circuit inputs #11179

Merged
merged 5 commits into from
Nov 8, 2023

Conversation

caleb-johnson
Copy link
Contributor

Fixes #11177

Summary

This PR allows the inputs to UnitaryOverlap to contain barriers.

Details and comments

When checking the circuit to ensure all instructions are unitary operations, we should ignore barriers.

@caleb-johnson caleb-johnson requested a review from a team as a code owner November 2, 2023 15:22
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Cryoris
  • @Qiskit/terra-core
  • @ajavadia

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 ok to me as a temporary workaround, thanks Caleb. I think a more proper solution will be that we need to unify the "can this operation be used in gates?" logic somewhere, because at the moment the same sort of check is used in various places with quite differing results. For example, circuit_to_gate will reject Barrier as well. We can look at that in a follow-up, though, because it might involve some behavioural changes.

Could you also add a test to prevent regression?

qiskit/circuit/library/overlap.py Outdated Show resolved Hide resolved
qiskit/circuit/library/overlap.py Outdated Show resolved Hide resolved
@caleb-johnson
Copy link
Contributor Author

caleb-johnson commented Nov 2, 2023

Could you also add a test to prevent regression?

yes, will do

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.

My bad, I should have spotted this in the first review: could you add a "bugfix" release note about this? Other than that (and the extra blank line in the test file that I think black will complain about), this looks fine to merge to me as a bugfix, with the proviso I had about that ideally we'll unify this logic somewhere at a larger scale. That wouldn't be suitable for backport, though, so this is good.

@jakelishman jakelishman added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library labels Nov 6, 2023
@jakelishman jakelishman added this to the 0.45.1 milestone Nov 6, 2023
@coveralls
Copy link

coveralls commented Nov 6, 2023

Pull Request Test Coverage Report for Build 6774835580

Warning: This coverage report may be inaccurate.

We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
To ensure accuracy in future PRs, please see these guidelines.
A quick fix for this PR: rebase it; your next report should be accurate.

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 147 unchanged lines in 13 files lost coverage.
  • Overall coverage increased (+0.04%) to 86.921%

Files with Coverage Reduction New Missed Lines %
qiskit/passmanager/passmanager.py 1 91.49%
qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py 1 94.16%
qiskit/extensions/quantum_initializer/squ.py 2 84.15%
qiskit/passmanager/base_tasks.py 2 95.89%
crates/qasm2/src/lex.rs 5 91.16%
qiskit/transpiler/target.py 5 93.78%
qiskit/primitives/backend_estimator.py 6 96.19%
qiskit/transpiler/basepasses.py 8 91.58%
qiskit/transpiler/passes/layout/sabre_layout.py 9 78.03%
qiskit/passmanager/flow_controllers.py 11 66.12%
Totals Coverage Status
Change from base Build 6731270262: 0.04%
Covered Lines: 74329
Relevant Lines: 85513

💛 - Coveralls

@caleb-johnson
Copy link
Contributor Author

caleb-johnson commented Nov 6, 2023

My bad, I should have spotted this in the first review: could you add a "bugfix" release note about this?

Yep, was actually going to ask about this and figured you'd tell me whether this warranted one :)

@caleb-johnson
Copy link
Contributor Author

unify this logic somewhere at a larger scale.

If you have an inclination about where it should live and which modules could use the new function (does this only affect circuit library?), I can start an issue and try to unify it in a separate PR.

@caleb-johnson
Copy link
Contributor Author

unify this logic somewhere at a larger scale.

If you have an inclination about where it should live and which modules could use the new function (does this only affect circuit library?), I can start an issue and try to unify it in a separate PR.

Issue here

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 Caleb!

@jakelishman jakelishman added this pull request to the merge queue Nov 8, 2023
Merged via the queue into Qiskit:main with commit 25c46dc Nov 8, 2023
14 checks passed
mergify bot pushed a commit that referenced this pull request Nov 8, 2023
* Allow barriers in overlap circuit inputs

* Minor fixes plus test with barriers

* Check parameter number on barrier test, similar to other non-failing tests.

* test order

* Add release note

(cherry picked from commit 25c46dc)
github-merge-queue bot pushed a commit that referenced this pull request Nov 8, 2023
* Allow barriers in overlap circuit inputs

* Minor fixes plus test with barriers

* Check parameter number on barrier test, similar to other non-failing tests.

* test order

* Add release note

(cherry picked from commit 25c46dc)

Co-authored-by: Caleb Johnson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UnitaryOverlap cannot handle barriers
4 participants