Skip to content

Fix ConsolidateBlocks pass for collecting non-CX KAK gate (backport #14417) #14424

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

Merged
merged 1 commit into from
May 21, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented May 21, 2025

Summary

A bug was introduced into the ConsolidateBlocks pass in #13884 around how the KAK gate name was passed to rust from the Python pass. The consolidate blocks internal logic around whether to consolidate a pass or not is based on the estimate from the selected decomposer of whether the estimated number of gates used to synthesis the unitary would exceed the number of basis gates in the block. To do this the pass counts the gate with the synthesis target name in the block. However, in the case of the decomposer being the TwoQubitBasisDecomposer the name being used for this look wasn't the name of the gate, but instead was an internal sentinel value string "USER_GATE" which is used to handle arbitrary user gate definitions in the decomposer. This led to the consolidate blocks pass missing opportunities for consolidation. This commit fixes the oversight so that the name we use for making this determination is the actual basis gate name and the pass functions correctly.

Details and comments

Fixes #14413


This is an automatic backport of pull request #14417 done by Mergify.

A bug was introduced into the ConsolidateBlocks pass in #13884 around
how the KAK gate name was passed to rust from the Python pass. The
consolidate blocks internal logic around whether to consolidate a pass
or not is based on the estimate from the selected decomposer of whether
the estimated number of gates used to synthesis the unitary would exceed
the number of basis gates in the block. To do this the pass counts the
gate with the synthesis target name in the block. However, in the case
of the decomposer being the TwoQubitBasisDecomposer the name being
used for this look wasn't the name of the gate, but instead was an
internal sentinel value string "USER_GATE" which is used to handle
arbitrary user gate definitions in the decomposer. This led to the
consolidate blocks pass missing opportunities for consolidation. This
commit fixes the oversight so that the name we use for making this
determination is the actual basis gate name and the pass functions
correctly.

Fixes #14413

(cherry picked from commit 4e9231d)
@mergify mergify bot requested a review from a team as a code owner May 21, 2025 15:48
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

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

  • @Qiskit/terra-core

@github-actions github-actions bot added priority: high Changelog: Bugfix Include in the "Fixed" section of the changelog mod: transpiler Issues and PRs related to Transpiler labels May 21, 2025
@github-actions github-actions bot added this to the 2.0.2 milestone May 21, 2025
@mtreinish mtreinish enabled auto-merge May 21, 2025 15:57
@coveralls
Copy link

Pull Request Test Coverage Report for Build 15166718418

Details

  • 4 of 5 (80.0%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.01%) to 88.127%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/transpiler/passes/optimization/consolidate_blocks.py 4 5 80.0%
Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 94.81%
crates/qasm2/src/lex.rs 3 92.98%
Totals Coverage Status
Change from base Build 15146030383: 0.01%
Covered Lines: 72935
Relevant Lines: 82761

💛 - Coveralls

@mtreinish mtreinish added this pull request to the merge queue May 21, 2025
Merged via the queue into stable/2.0 with commit d2d3cf7 May 21, 2025
27 checks passed
@jakelishman jakelishman deleted the mergify/bp/stable/2.0/pr-14417 branch June 9, 2025 15:42
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: transpiler Issues and PRs related to Transpiler priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants