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 basis_count checking in ConsolidateBlocks #13463

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

mtreinish
Copy link
Member

Summary

The ConsolidateBlocks pass was ported to rust in #13368 and as part of that implementation a small behavior difference between the rust and python interfaces was causing the pass to not work correctly with non-CX gates. The internal 2q decomposer interface stores a sentinel string for the kak gate which is used to tell the python space constructor use the python defined gate object. However in the pass code we weren't factoring this difference in, and for non-CX gates we were evaluating the basis count as the number of gates with that sentinel value name (which is almost always zero) and this was preventing the pass from consolidating many blocks that should have been. This commit fixes this issue by taking the name from python space and passing it through to the rust portion of the code and using that for the comparison.

Details and comments

Fixes #13459

The ConsolidateBlocks pass was ported to rust in Qiskit#13368 and as part of
that implementation a small behavior difference between the rust and
python interfaces was causing the pass to not work correctly with non-CX
gates. The internal 2q decomposer interface stores a sentinel string for
the kak gate which is used to tell the python space constructor use the
python defined gate object. However in the pass code we weren't
factoring this difference in, and for non-CX gates we were evaluating
the basis count as the number of gates with that sentinel value name
(which is almost always zero) and this was preventing the pass from
consolidating many blocks that should have been. This commit fixes this
issue by taking the name from python space and passing it through to the
rust portion of the code and using that for the comparison.

Fixes Qiskit#13459
@mtreinish mtreinish added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Nov 20, 2024
@mtreinish mtreinish added this to the 1.3.0 milestone Nov 20, 2024
@mtreinish mtreinish requested a review from a team as a code owner November 20, 2024 14:20
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core

Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

LGTM. Good catch. Probably not a bugfix in terms of changelog because we didn't release the original code yet.

@ElePT ElePT added stable backport potential The bug might be minimal and/or import enough to be port to stable and removed Changelog: Bugfix Include in the "Fixed" section of the changelog labels Nov 20, 2024
@ElePT ElePT enabled auto-merge November 20, 2024 14:34
@coveralls
Copy link

Pull Request Test Coverage Report for Build 11935273085

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 13 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.008%) to 88.927%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/two_qubit_decompose.rs 3 92.13%
crates/qasm2/src/lex.rs 4 91.73%
crates/qasm2/src/parse.rs 6 96.69%
Totals Coverage Status
Change from base Build 11934143697: -0.008%
Covered Lines: 79397
Relevant Lines: 89283

💛 - Coveralls

@ElePT ElePT added this pull request to the merge queue Nov 20, 2024
Merged via the queue into Qiskit:main with commit c792426 Nov 20, 2024
18 checks passed
mergify bot pushed a commit that referenced this pull request Nov 20, 2024
The ConsolidateBlocks pass was ported to rust in #13368 and as part of
that implementation a small behavior difference between the rust and
python interfaces was causing the pass to not work correctly with non-CX
gates. The internal 2q decomposer interface stores a sentinel string for
the kak gate which is used to tell the python space constructor use the
python defined gate object. However in the pass code we weren't
factoring this difference in, and for non-CX gates we were evaluating
the basis count as the number of gates with that sentinel value name
(which is almost always zero) and this was preventing the pass from
consolidating many blocks that should have been. This commit fixes this
issue by taking the name from python space and passing it through to the
rust portion of the code and using that for the comparison.

Fixes #13459

(cherry picked from commit c792426)
github-merge-queue bot pushed a commit that referenced this pull request Nov 20, 2024
The ConsolidateBlocks pass was ported to rust in #13368 and as part of
that implementation a small behavior difference between the rust and
python interfaces was causing the pass to not work correctly with non-CX
gates. The internal 2q decomposer interface stores a sentinel string for
the kak gate which is used to tell the python space constructor use the
python defined gate object. However in the pass code we weren't
factoring this difference in, and for non-CX gates we were evaluating
the basis count as the number of gates with that sentinel value name
(which is almost always zero) and this was preventing the pass from
consolidating many blocks that should have been. This commit fixes this
issue by taking the name from python space and passing it through to the
rust portion of the code and using that for the comparison.

Fixes #13459

(cherry picked from commit c792426)

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
@raynelfss raynelfss added Changelog: Bugfix Include in the "Fixed" section of the changelog Changelog: None Do not include in changelog and removed Changelog: Bugfix Include in the "Fixed" section of the changelog labels Nov 20, 2024
@mtreinish mtreinish deleted the fix-consolidate-basis_gates branch November 22, 2024 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
5 participants