Discard cache for standard gates in assign_parameters
(backport #13557)
#13559
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
This is an initial fix to #13504, and should precede #13543.
The following commits discard the cached gate when assigning parameters for a standard gate rather than trying to modify the Python object.
Details and comments
A more in-depth fix is present in #13543, but since it is such a big change, we've decided to include this smaller fix to allow more time to re-evaluate our approach.
When retrieving a
PackedInstruction
from theEquivalenceLibrary
during thecompose_transforms
phase of theBasisTranslator
the parameter modifications done in other places are not reflected on the cached gate, therefore leading to issues when runningQISKIT_PARALLEL=TRUE
due to a modified object reference when callingCircuitData::assign_parameters()
.In the case of a standard gate, we were not removing the old cache but instead modifying it in place (which would not result in the expected outcome), while for other gate instances, we rebuild the non-cached item. Now we instead discard the cache in the
StandardGate
case too, getting rid of the stale shared reference.This is an automatic backport of pull request #13557 done by [Mergify](https://mergify.com).