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 PropertySet re-use in BasePassManager.run #11787

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

jakelishman
Copy link
Member

Summary

Since the genericised PassManager, the PropertySet used in the WorkflowState of a pass-manager pipeline was taken directly from the internal state of the BasePassManager. This is set to a clean PropertySet during the pass-manager initialisation (similar to how it was in the previous version), but is not reset on subsequent runs. This didn't cause problems in the old form because the "iterator" over tasks in the old form was a new RunningPassManager instance.

Failing to generate a clean property set could lead to passes getting fed old analysis data when the pass manager was used more than once, leading to miscompilations.

Details and comments

Fix #11784. This was a bug introduced in Qiskit 0.45.0, so I don't think it's critical to merge ahead of 1.0.0final, but can go into 1.0.1 and is suitable for backport to 0.46.1 as well.

Since the genericised `PassManager`, the `PropertySet` used in the
`WorkflowState` of a pass-manager pipeline was taken directly from the
internal state of the `BasePassManager`.  This is set to a clean
`PropertySet` during the pass-manager initialisation (similar to how it
was in the previous version), but is not reset on subsequent runs.  This
didn't cause problems in the old form because the "iterator" over tasks
in the old form was a new `RunningPassManager` instance.

Failing to generate a clean property set could lead to passes getting
fed old analysis data when the pass manager was used more than once,
leading to miscompilations.
@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: transpiler Issues and PRs related to Transpiler labels Feb 13, 2024
@jakelishman jakelishman added this to the 1.0.1 milestone Feb 13, 2024
@jakelishman jakelishman requested a review from a team as a code owner February 13, 2024 15:21
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core

@coveralls
Copy link

Pull Request Test Coverage Report for Build 7888745483

Details

  • 0 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.05%) to 89.226%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 4 91.69%
Totals Coverage Status
Change from base Build 7886503866: 0.05%
Covered Lines: 58840
Relevant Lines: 65945

💛 - Coveralls

Copy link
Contributor

@nkanazawa1989 nkanazawa1989 left a comment

Choose a reason for hiding this comment

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

Thanks @jakelishman this PR looks good to me. The comment below is not a blocker.

@@ -47,6 +47,8 @@ def __init__(
"""
self._tasks = []
self.max_iteration = max_iteration
# This empty property set never gets used; it gets overridden at the completion of a
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to nullify this attribute? This used to be None in < 0.45. This update disallows users to manually update property_set (e.g. warm-start), but I think this is reasonable. This constructor may mislead the users if they don't read the comment.

Copy link
Member Author

@jakelishman jakelishman Feb 20, 2024

Choose a reason for hiding this comment

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

That's an interesting question. I think allowing a warm state might be better to enable by making it an explicit argument to PassManager.run, if we were going to go that route, though I'm not clear there's a real use-case for that - did you have one in mind?

For None vs the empty property set: I'm loosely in favour of having PropertySet() as the default value, because it means that strictly typed code doesn't need to worry about PassManager.property_set possibly being None on every single access, when it can be known that a well behaved runtime should never see that behaviour. PropertySet() is what you'd get if you ran an empty pass manager, and I don't think PassManager needs to use the typing to distinguish the cases of "has never been run" vs "ran and did nothing"; that's a program-ordering concern that the user can always easily resolve themselves.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh also, given that it was PropertySet in 1.0.0, we can't backport the PR if we change the dummy property set to None. That actually means we wouldn't be able to accept that change to this PR, so maybe if you want to talk about it more, we should make a new issue for Qiskit 1.1.

@jakelishman jakelishman added this pull request to the merge queue Feb 22, 2024
@jakelishman
Copy link
Member Author

@Mergifyio backport stable/0.46

Copy link
Contributor

mergify bot commented Feb 22, 2024

backport stable/0.46

✅ Backports have been created

Merged via the queue into Qiskit:main with commit 9c1accb Feb 22, 2024
12 checks passed
mergify bot pushed a commit that referenced this pull request Feb 22, 2024
Since the genericised `PassManager`, the `PropertySet` used in the
`WorkflowState` of a pass-manager pipeline was taken directly from the
internal state of the `BasePassManager`.  This is set to a clean
`PropertySet` during the pass-manager initialisation (similar to how it
was in the previous version), but is not reset on subsequent runs.  This
didn't cause problems in the old form because the "iterator" over tasks
in the old form was a new `RunningPassManager` instance.

Failing to generate a clean property set could lead to passes getting
fed old analysis data when the pass manager was used more than once,
leading to miscompilations.

(cherry picked from commit 9c1accb)
mergify bot pushed a commit that referenced this pull request Feb 22, 2024
Since the genericised `PassManager`, the `PropertySet` used in the
`WorkflowState` of a pass-manager pipeline was taken directly from the
internal state of the `BasePassManager`.  This is set to a clean
`PropertySet` during the pass-manager initialisation (similar to how it
was in the previous version), but is not reset on subsequent runs.  This
didn't cause problems in the old form because the "iterator" over tasks
in the old form was a new `RunningPassManager` instance.

Failing to generate a clean property set could lead to passes getting
fed old analysis data when the pass manager was used more than once,
leading to miscompilations.

(cherry picked from commit 9c1accb)
github-merge-queue bot pushed a commit that referenced this pull request Feb 22, 2024
Since the genericised `PassManager`, the `PropertySet` used in the
`WorkflowState` of a pass-manager pipeline was taken directly from the
internal state of the `BasePassManager`.  This is set to a clean
`PropertySet` during the pass-manager initialisation (similar to how it
was in the previous version), but is not reset on subsequent runs.  This
didn't cause problems in the old form because the "iterator" over tasks
in the old form was a new `RunningPassManager` instance.

Failing to generate a clean property set could lead to passes getting
fed old analysis data when the pass manager was used more than once,
leading to miscompilations.

(cherry picked from commit 9c1accb)

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
github-merge-queue bot pushed a commit that referenced this pull request Feb 22, 2024
Since the genericised `PassManager`, the `PropertySet` used in the
`WorkflowState` of a pass-manager pipeline was taken directly from the
internal state of the `BasePassManager`.  This is set to a clean
`PropertySet` during the pass-manager initialisation (similar to how it
was in the previous version), but is not reset on subsequent runs.  This
didn't cause problems in the old form because the "iterator" over tasks
in the old form was a new `RunningPassManager` instance.

Failing to generate a clean property set could lead to passes getting
fed old analysis data when the pass manager was used more than once,
leading to miscompilations.

(cherry picked from commit 9c1accb)

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
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 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.

generate_preset_pass_manager generates transpiler error on efficientSU2 at 12 qubits
4 participants