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

Updated Estimator interface #51

Merged
merged 51 commits into from Oct 27, 2023
Merged

Conversation

ihincks
Copy link
Contributor

@ihincks ihincks commented Oct 4, 2023

No description provided.

@CLAassistant
Copy link

CLAassistant commented Oct 4, 2023

CLA assistant check
All committers have signed the CLA.

0015-estimator-interface.md Show resolved Hide resolved
0015-estimator-interface.md Outdated Show resolved Hide resolved
Copy link
Contributor

@blakejohnson blakejohnson left a comment

Choose a reason for hiding this comment

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

Approving from the lens of the desired interface, including:

  • tasks (we can discuss name of this elsewhere)
  • broadcasted shapes
  • ObservablesArray
  • BindingArray
  • bumping up error bars into the required part of the TaskResult

The issue of migration path is important, but not in scope of my review.

Co-authored-by: Jim Garrison <jim@garrison.cc>
@blakejohnson
Copy link
Contributor

blakejohnson commented Oct 26, 2023

Please, let's close on this in the next 24 hours.

Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com>
Copy link
Contributor

@itoko itoko left a comment

Choose a reason for hiding this comment

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

fix minor typos (ResultTask -> TaskResult)

0015-estimator-interface.md Outdated Show resolved Hide resolved
0015-estimator-interface.md Outdated Show resolved Hide resolved
0015-estimator-interface.md Outdated Show resolved Hide resolved
ihincks and others added 5 commits October 26, 2023 21:35
Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
@ihincks
Copy link
Contributor Author

ihincks commented Oct 27, 2023

Thanks everyone for the thoughtful discussion about whether to version the interfaces, or whether to migrate the current signature. We have, in the end, decided that the pros of versioning the interface win.

Copy link
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.

With a decision being made to use explicit versioning on the public interface as a migration strategy I'm happy with the proposal now. Thanks for all the hard work sorting through everyone's comments to come up with a concrete and workable plan.

I left 2 small comments inline about some of the migration path. Neither are critical for this RFC, the converter class I think is a good idea and some we can add independently after BaseEstimatorV2 has been defined. The other is more of a question for clarification and idle musings on migration strategies for implementers of Estimators (which is largely out of scope for this document, but useful to discuss while formulating this plan).


In summary, we propose the following strategy: explicitly version the `Estimator` interface (i.e. add a `BaseEstimatorV2` as described in this proposal) and document both the differences and the end user migration path for consumers of estimators. The user can determine which version of the estimator to use, and existing implementations can be left intact.

Similar to `Backend`, we will have a `BaseEstimator`, `BaseEstimatorV1` equal to the existing `BaseEstimator`, and `BaseEstimatorV2`, as described in this proposal.
Copy link
Member

@mtreinish mtreinish Oct 27, 2023

Choose a reason for hiding this comment

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

I like this direction, thanks for outlining it clearly. One thing we've found with the Backend interface is that the converter class to wrap the old interface in the new semantics of V2 has proven quite useful for end users writing their own libraries on top of backends: https://qiskit.org/documentation/stubs/qiskit.providers.BackendV2Converter.html accounting for something like that as part of this versioning strategy would be useful. This will enable end users to more quickly standardize on using BaseEstimatorV2 and if a particular estimator implementation is still v1 they can just wrap it in the converter class.

In summary, we propose the following strategy: explicitly version the `Estimator` interface (i.e. add a `BaseEstimatorV2` as described in this proposal) and document both the differences and the end user migration path for consumers of estimators. The user can determine which version of the estimator to use, and existing implementations can be left intact.

Similar to `Backend`, we will have a `BaseEstimator`, `BaseEstimatorV1` equal to the existing `BaseEstimator`, and `BaseEstimatorV2`, as described in this proposal.
We will maintain backward compatibility by defaulting the import of `Estimator` to `EstimatorV1` (i.e. existing) for the duration of the deprecation period.
Copy link
Member

@mtreinish mtreinish Oct 27, 2023

Choose a reason for hiding this comment

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

Which Estimator are you talking about here? I assume qiskit.primitives.Estimator, but I know of at least three classes named Estimator that implement BaseEstimator in different repositories.

Regardless of which one is being referred to, one other option here that might make it easier for users, is basically what qiskit-ibm-provider does for its BackendV2 implementation. The backends from qiskit-ibm-provider implement the BackendV2 interface but also provide a compatible interface with most of BackendV1 (the notable exception being backend.name which is an attribute on V2 and a method on V1). So users have the freedom to use both interfaces for an existing implementation. It also makes future deprecation a little easier because it's easier to warn on legacy access patterns and inputs. But it's also totally manageable with parallel implementations, just using a FutureWarning when Estimator is instantiated and you can use a __future__ import to change Estimator over to EstimatorV2.

@blakejohnson blakejohnson merged commit d8d490a into Qiskit:master Oct 27, 2023
1 check passed
@1ucian0
Copy link
Member

1ucian0 commented Oct 30, 2023

I think the only two open discussion are:

Let’s move those conversation to their issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC proposal New RFC is proposed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet