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

Legacy code deprecation in pass manager #11449

Merged

Conversation

nkanazawa1989
Copy link
Contributor

Summary

This PR is deprecation version of #11448 for stable/0.46.

Details and comments

@nkanazawa1989 nkanazawa1989 added Changelog: Deprecation Include in "Deprecated" section of changelog mod: transpiler Issues and PRs related to Transpiler labels Dec 21, 2023
@nkanazawa1989 nkanazawa1989 added this to the 0.46.0 milestone Dec 21, 2023
@nkanazawa1989 nkanazawa1989 requested a review from a team as a code owner December 21, 2023 08:41
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core
  • @nkanazawa1989

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

It looks like the correct things have been deprecated, but I think we need to revisit how it's been done:

  • we should always use the deprecate_func decorator to deprecate classes, so all the warnings are automatically raised correctly, and this also handles putting in .. deprecated:: directives into the class documentation.
  • we oughtn't to be using catch_warnings in library code. It adds extra runtime weight, but also, if the stacklevels are set correctly, it's unnecessary; the warnings will already be filtered out, and manually catching warnings prevents users from being able to control it themselves. We can filter the warnings that are blamed on ourselves in our own test suite, since we've already got the working version in Legacy code removal in pass manager #11448.

qiskit/passmanager/flow_controllers.py Outdated Show resolved Hide resolved
Comment on lines 247 to 250
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
flatten_tasks = list(self._flatten_tasks(self._tasks))
return RunningPassManager(flatten_tasks)
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't filter warnings within the library; it adds cost, but also, it's generally unnecessary - if we ensure that the warnings have their stack level set correctly, they'll blame Qiskit code and so not be shown to users by default.

Copy link
Member

@jakelishman jakelishman Jan 31, 2024

Choose a reason for hiding this comment

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

I removed almost all of these in 35452c5, by effectively pulling in the changes on #11448 into this branch. The particular one highlighted here has a gross hack to make internal library use work, without modifying downstream use at all, but downstream use of to_flow_controller should correctly see the warnings as being blamed on Qiskit code, so they should be fine to suppress those.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Jake. I didn't came up with this solution. I've learned a lot :)

nkanazawa1989 and others added 4 commits January 5, 2024 04:39
The intention here is to avoid overriding warning filters within our
code, and just eagerly migrate to the preferred paths we already know to
be identical.  The `transpiler.PassManager.to_flow_controller` hack is a
bit gross.
jakelishman
jakelishman previously approved these changes Jan 31, 2024
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

I pushed non-trivial changes to this and it wouldn't hurt to have another reviewer, but since everyone's swamped, we're already on top of the 0.46 deadline, and especially since 0.46 still has the old CI workflows, I'm going to move this to merge and we can modify it afterwards if anything needed changing (assuming I didn't bork the tests or lint). Thanks for getting it sorted, Naoki.

@jakelishman jakelishman enabled auto-merge January 31, 2024 00:26
@jakelishman jakelishman added this pull request to the merge queue Jan 31, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 31, 2024
@jakelishman jakelishman added this pull request to the merge queue Jan 31, 2024
Merged via the queue into Qiskit:stable/0.46 with commit d1d1870 Jan 31, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Deprecation Include in "Deprecated" section of changelog mod: transpiler Issues and PRs related to Transpiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants