Skip to content

Update the deprecation decorator towards SemVer#11296

Closed
1ucian0 wants to merge 21 commits into
Qiskit:mainfrom
1ucian0:docs/deprecation/1
Closed

Update the deprecation decorator towards SemVer#11296
1ucian0 wants to merge 21 commits into
Qiskit:mainfrom
1ucian0:docs/deprecation/1

Conversation

@1ucian0
Copy link
Copy Markdown
Member

@1ucian0 1ucian0 commented Nov 22, 2023

The current deprecate decorators extend the docstring with the following:

current

I suggest the following to be aligned with Qiskit/documentation#366

suggestion

Other consequences:

  • As part of this change, since= parameter should be a string. Sometimes, we accidentally use floats for it which is not correct in the generic case. So, it is good to raise in those cases.

@1ucian0 1ucian0 requested review from a team and woodsp-ibm as code owners November 22, 2023 15:15
@qiskit-bot
Copy link
Copy Markdown
Collaborator

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

  • @Qiskit/terra-core

@1ucian0 1ucian0 added this to the 1.0.0 milestone Nov 22, 2023
@1ucian0 1ucian0 added the type: qa Issues and PRs that relate to testing and code quality label Nov 22, 2023
Comment thread qiskit/utils/deprecation.py Outdated
pending: bool = False,
package_name: str = "qiskit",
removal_timeline: str = "no earlier than 3 months after the release date",
removal_timeline: str = "in the next major release",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This works fine, but we should have sufficient info to compute the next major version from the since field. We could set this to None and then do something like:

if removal_timeline is None:
    removal_major = int(since.split(",")[0]) + 1
    removal_timeline = f"in the next major release {removal_major}"

Or if you're worried about deprecated features passing a major version boundary (e.g. we deprecate something in 1.0 and don't remove it until 3.0) we can replace since with the package's __version__.

Copy link
Copy Markdown
Member Author

@1ucian0 1ucian0 Nov 23, 2023

Choose a reason for hiding this comment

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

good one! Done in cd47576

However, replacing since with __version__ might be tricky. If a features was deprecated in 1.1.0, we want to keep that since after the release of 1.2.0. Or am I missing something?

@coveralls
Copy link
Copy Markdown

coveralls commented Nov 23, 2023

Pull Request Test Coverage Report for Build 13702148612

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • 15 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.007%) to 88.171%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 94.49%
crates/qasm2/src/parse.rs 6 96.68%
crates/qasm2/src/lex.rs 8 91.73%
Totals Coverage Status
Change from base Build 13698067235: -0.007%
Covered Lines: 71838
Relevant Lines: 81476

💛 - Coveralls

@1ucian0 1ucian0 modified the milestones: 1.0.0, 1.0.0pre1, 0.46.0 Nov 27, 2023
@1ucian0 1ucian0 changed the base branch from main to stable/0.46 November 27, 2023 16:08
@1ucian0 1ucian0 changed the base branch from stable/0.46 to main November 27, 2023 16:08
@1ucian0 1ucian0 added the API label Feb 13, 2025
@1ucian0
Copy link
Copy Markdown
Member Author

1ucian0 commented Feb 13, 2025

@Mergifyio dequeue

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Feb 13, 2025

dequeue

☑️ The pull request is not queued

@1ucian0
Copy link
Copy Markdown
Member Author

1ucian0 commented Feb 13, 2025

I think this needs a release note as this is a public documented function and we're [...] changing the default behavior.

Done in 97a2740

Copy link
Copy Markdown
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

This is arguably a violation of our deprecation policy because we didn't warn about the change in behavior in 1.x at all. Ideally we would have had a commit in 1.x that raised a FutureWarning when removal_timeline was None to tell people the default message would change in 2.0 but still return the 3 months message.

That being said we've already made similar mistakes in a couple of far more consequential places in the Qiskit API for 2.0 that I'm inclined to let this slip through with just a release note as a behavior change in 2.0. I left a small comment inline but otherwise I'm fine moving forward here.

Comment thread qiskit/utils/deprecation.py Outdated
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
@1ucian0
Copy link
Copy Markdown
Member Author

1ucian0 commented Feb 25, 2025

Ideally we would have had a commit in 1.x that raised a FutureWarning when removal_timeline was None to tell people the default message would change in 2.0 but still return the 3 months message.

Would it help if I do that in 1.4.1?

@mtreinish
Copy link
Copy Markdown
Member

Given how close we are to the rc1 tag and that this is still failing CI I'm going to defer this (to 3.0 I guess). We can prepare a deprecation in 2.1 though which will be good.

@mtreinish mtreinish removed this from the 2.0.0 milestone Mar 6, 2025
@1ucian0 1ucian0 added this to the 2.0.0 milestone Mar 6, 2025
Copy link
Copy Markdown
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

I know I said that I was ok with this before. But as I was going to hit approve on this I had a crisis of conscience and just can't bring myself to hit approve; I'm really sorry. I'm still just very concerned about this as an api change. This PR is the exact thing the Qiskit deprecation policy says we're not supposed to do. Even though this is would go in a major version release where we're allowed to introducing breaking API changes, we're supposed to document these changes are coming and give a migration path for users so they can prepare. While I feel like this API should not be part of our public API, for better or worse it is and I really think we should follow our own rules here even if it's feels like a super minor part of the API and a very small change.

Why I"m having such a hard time on this PR is because it will silently change the behavior of the decorator to change the message from "no sooner than 6 months" to "in the next major release". While this makes sense given qiskit's stability policy, versioning, and release process we can't make that assumption about our downstream users' packeages. All the usage I could find of it on public github was qiskit-experiments, qiskit-nature, qiskit-qec, etc. and those do not have major versions and afaik don't plan on having them anytime soon/ever. While we can update those individual projects easily we can't know all of the users out there and this behavior change really might not fit with their current usage of the decorator. I'm worried that this change would not get noticed until too late because there is no warning about it coming (which is why we have deprecations)

What I would say we do here is that we should make this a new private function in 2.1 and deprecate all these public decorators for removal in 3.0. This will only delay the usability change you desire by a week or two (since we can migrate internal usage asap on main) and then we've achieved your goals here.

@mtreinish mtreinish modified the milestones: 2.0.0, 2.1.0 Mar 6, 2025
wshanks added a commit to wshanks/qiskit-experiments that referenced this pull request Mar 7, 2025
These functions are planned to be removed from the public Qiskit API in
a future release (see
Qiskit/qiskit#11296 (review)).
github-merge-queue Bot pushed a commit to qiskit-community/qiskit-experiments that referenced this pull request Mar 7, 2025
This change prepares for Qiskit 2.0 by guarding or replacing references
to objects removed in Qiskit 2.0.

## Detailed list of changes:

### Compatibility changes:

* Guard references to `BackendV1`. `BackendV1` was removed in Qiskit
2.0. There were only a few remaining references to `BackendV1` after the
previous removal of pulse support, so it was not hard to keep the
remaining support for now but it should be removed when Qiskit 1 is no
longer supported.
* Update usage of `qiskit.result.Result.header` to expect a dict (Qiskit
2) as well as a class (Qiskit 1). `ExperimentData` gets the circuit
metadata from the header (by convention the metadata is copied into the
result and `ExperimentData` relies on this).
* Add classes `MeasLevel` and `MeasReturnType` to enumerate the expected
measurement level (kerneled or classified) and return type (averaged or
not). Previously, private classes of Qiskit were inadvertently used for
these purposes but they were removed in Qiskit 2.0.
* Remove null default `inst_map` transpile options from experiments.
These should have been removed along with the rest of pulse support.
* Update tests to use `GenericBackendV2` or a custom `BackendV2` in
place of removed `FakeOpenPulse2Q` and `Fake5QV1` backends from Qiskit.
* Remove suppression of Qiskit deprecation warnings from the tests.
* Remove stray references to `ProviderV1` in tests.
* Update the saved `QuantumVolume` results for Qiskit 2.0's change in
the quantum volume algorithm.
* Vendor deprecation decorators to prepare for their removal from
Qiskit's public API (see
[here](Qiskit/qiskit#11296 (review))).
At first it appeared that these methods would be changed late in the
Qiskit 2.0 cycle but the change was pushed back in time. Still the plan
is to make the functions private, so we need to stop using them.

### Other changes

* Provide a more specific warning in `LocalReadouMitigator` if it is
used with a backend without a ``properties()`` method or with a backend
that does not the required readout error properties.
* Fix a performance issue in `QuantumVolume`. When Qiskit Aer is
installed, `QuantumVolume` uses `AerSimulator` to simulate the outcomes
of the quantum volume circuits to determine the heavy output
probabilities. In its default instantiation, `AerSimulator` regenerates
its `Target` every time it is accessed and this generation takes an
appreciable amount of time. Because the target was being accessed
separately for every circuit, this overhead could accumulate to over a
minute in the standard 100 circuit experiment. This overhead was reduced
by processing all the circuits in one pass.
* Switch `FineFrequency` tests to use `T2HahnBackend` in place
`MockIQBackend` since it provides a more realistic backend emulation.
* Fix the `stacklevel` on the deprecation warning for `RestlessNode`.

---------

Co-authored-by: Eli Arbel <arbel@il.ibm.com>
@mtreinish mtreinish modified the milestones: 2.1.0, 2.2.0 May 30, 2025
@raynelfss raynelfss added the Changelog: None Do not include in the GitHub Release changelog. label Aug 13, 2025
@mtreinish mtreinish removed this from the 2.2.0 milestone Aug 21, 2025
@jakelishman
Copy link
Copy Markdown
Member

I'll close based on Matt's comments above.

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jan 15, 2026

backport stable/0.46

🟠 Waiting for conditions to match

Details
  • merged [📌 backport requirement]

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jan 15, 2026

dequeue

☑️ The pull request is not queued

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: None Do not include in the GitHub Release changelog. type: qa Issues and PRs that relate to testing and code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants