-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Deprecate dense Operator Estimator observables #11056
Conversation
One or more of the the following people are requested to review this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I made a PR to fix unit test errors. A unit test of gradient uses |
This deprecates passing Operator and other dense `BaseOperator` subclasses as observables in `Estimator.run`. These were implicitly converted to SparsePauliOps by the Estimator, so now should be explicitly converted to `SparsePauliOps` by the user instead.
69f024a
to
fd1fafc
Compare
New-deprecation PRs intended for 0.46 want to be targetted directly at |
@jakelishman It looks like there are other primitives deprecation's from previously merged PRs not included in 0.46 ( #11052 #11055). Do we need to merge into main, and then open a separate PR to backport these to stable/0.46 ? |
Luciano noticed #11055 and took / is taking care of it with #11520, but we didn't know about #11052. That needs applying to 0.46 too. We can leave the commits on main for now, provided another PR before 1.0 tidies them up. I can get the bot to prepare a port of #11052 to stable/0.46 (edit: #11532). The difference to normal here is that the current backport branch is |
@@ -59,6 +59,14 @@ def init_observable(observable: BaseOperator | str) -> SparsePauliOp: | |||
if isinstance(observable, SparsePauliOp): | |||
return observable | |||
elif isinstance(observable, BaseOperator) and not isinstance(observable, BasePauli): | |||
warnings.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considere adding a docstring note (similar to https://github.com/Qiskit/qiskit/pull/11520/files#diff-0094a250bbe85d99bff3279e6eaea98adaffcdb59e89773c76cb60be18a19675R157-R161).
" observable arguments is deprecated as of Qiskit 0.46 and will be" | ||
" in Qiskit 1.0. You should explicitly convert to a SparsePauli op using" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
" observable arguments is deprecated as of Qiskit 0.46 and will be" | |
" in Qiskit 1.0. You should explicitly convert to a SparsePauli op using" | |
" observable arguments is deprecated as of Qiskit 0.46 and will be removed" | |
" in Qiskit 1.0. You should explicitly convert to a SparsePauli op using" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Just checking the style, consider adding a docstring note and a release note.
@jakelishman @1ucian0 since it would involve a full rebase to change the target branch I'll open a second PR for adding this to 0.46 |
@Mergifyio backport stable/0.46 |
🟠 Waiting for conditions to match
|
ok, now the bot will just do it for you when this merges |
Replaced by #11535 |
Summary
This deprecates passing Operator and other dense
BaseOperator
subclasses as observables inEstimator.run
. These were implicitly converted to SparsePauliOps by the Estimator, so now should be explicitly converted toSparsePauliOps
by the user instead.Details and comments