Fix ConsolidateBlocks pass for collecting non-CX KAK gate (backport #14417) #14424
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.