-
Notifications
You must be signed in to change notification settings - Fork 127
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
Improve handling of circuit execution providers #1502
Conversation
da13855
to
0cae5b4
Compare
@@ -69,14 +70,15 @@ | |||
from qiskit_experiments.database_service.utils import objs_to_zip, zip_to_objs | |||
|
|||
from .containers.figure_data import FigureData, FigureType | |||
from .provider_interfaces import Job, Provider |
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.
I wasn't sure if it was convenient to use the Job
and Provider
names here (they basically mean what you expect them to mean) or confusing (they don't quite mean exactly what you might first assume they mean). Maybe JobLike
and ProviderLike
would be better or something like that?
0cae5b4
to
934ea10
Compare
This change improves several aspects about the way `ExperimentData` works with "providers." Here "provider" is generalized beyond `qiskit.providers.Provider` to any object which can provide a `Job`-like object with data about an experiment's circuit execution. This generalization is needed because `qiskit-ibm-runtime`, the main provider that Experiments integrates with, does not use the `Provider` class, so * Replace references to `qiskit.providers.Provider` and `qiskit.providers.Job` with custom interface definitions using `typing.Protocol`. The new interfaces document the API Experiments needs for working with these objects. * Improve type hints and type checking related to providers, jobs, and results, using the new protocol classes. * Infer `IBMExperimentService` authentication parameters from a `qiskit_ibm_runtime.QiskitRuntimeService` instance in the same way that the inference used to work with `qiskit_ibm_provider.IBMProvider`. * Delay inferring an `IBMExperimentService` from a backend or provider until `ExperimentData` tries to communicate with the experiment service. With the fix to infer the authentication parameters from `QiskitRuntimeService`, this delay is needed to avoid breaking existing code that creates an `ExperimentData` instance and then tries to set a custom experiment service for it, relying on the fact that inferrence did not work for `QiskitRuntimeService`, since setting the service on `ExperimentData` after it has already been set once raises an exception. * Remove dead code, both helper functions that are not called anywhere in the repository and code paths only relevant to qiskit-ibm-provider, like references to `time_per_step()`. Since `qiskit-ibm-provider` has long been deprecated and unsupported by IBM Quantum, removing support for it is not treated as a breaking change. * Handle some optional data types better (like result objects that might have a `metadata` attribute).
934ea10
to
37536b1
Compare
Pulled the branch and tested that it doesn't break anything to zero order... I don't use the experiment service extensively so haven't tested that. But otherwise looks fine, will approve. |
This change improves several aspects about the way `ExperimentData` works with "providers." Here "provider" is generalized beyond `qiskit.providers.Provider` to any object which can provide a `Job`-like object with data about an experiment's circuit execution. This generalization is needed because `qiskit-ibm-runtime`, the main provider that Experiments integrates with, does not use the `Provider` class, so * Replace references to `qiskit.providers.Provider` and `qiskit.providers.Job` with custom interface definitions using `typing.Protocol`. The new interfaces document the API Experiments needs for working with these objects. * Improve type hints and type checking related to providers, jobs, and results, using the new protocol classes. * Infer `IBMExperimentService` authentication parameters from a `qiskit_ibm_runtime.QiskitRuntimeService` instance in the same way that the inference used to work with `qiskit_ibm_provider.IBMProvider`. * Delay inferring an `IBMExperimentService` from a backend or provider until `ExperimentData` tries to communicate with the experiment service. With the fix to infer the authentication parameters from `QiskitRuntimeService`, this delay is needed to avoid breaking existing code that creates an `ExperimentData` instance and then tries to set a custom experiment service for it, relying on the fact that inferrence did not work for `QiskitRuntimeService`, since setting the service on `ExperimentData` after it has already been set once raises an exception. * Remove dead code, both helper functions that are not called anywhere in the repository and code paths only relevant to qiskit-ibm-provider, like references to `time_per_step()`. Since `qiskit-ibm-provider` has long been deprecated and unsupported by IBM Quantum, removing support for it is not treated as a breaking change. * Handle some optional data types better (like result objects that might have a `metadata` attribute). (cherry picked from commit 2d48547)
This change improves several aspects about the way `ExperimentData` works with "providers." Here "provider" is generalized beyond `qiskit.providers.Provider` to any object which can provide a `Job`-like object with data about an experiment's circuit execution. This generalization is needed because `qiskit-ibm-runtime`, the main provider that Experiments integrates with, does not use the `Provider` class, so * Replace references to `qiskit.providers.Provider` and `qiskit.providers.Job` with custom interface definitions using `typing.Protocol`. The new interfaces document the API Experiments needs for working with these objects. * Improve type hints and type checking related to providers, jobs, and results, using the new protocol classes. * Infer `IBMExperimentService` authentication parameters from a `qiskit_ibm_runtime.QiskitRuntimeService` instance in the same way that the inference used to work with `qiskit_ibm_provider.IBMProvider`. * Delay inferring an `IBMExperimentService` from a backend or provider until `ExperimentData` tries to communicate with the experiment service. With the fix to infer the authentication parameters from `QiskitRuntimeService`, this delay is needed to avoid breaking existing code that creates an `ExperimentData` instance and then tries to set a custom experiment service for it, relying on the fact that inferrence did not work for `QiskitRuntimeService`, since setting the service on `ExperimentData` after it has already been set once raises an exception. * Remove dead code, both helper functions that are not called anywhere in the repository and code paths only relevant to qiskit-ibm-provider, like references to `time_per_step()`. Since `qiskit-ibm-provider` has long been deprecated and unsupported by IBM Quantum, removing support for it is not treated as a breaking change. * Handle some optional data types better (like result objects that might have a `metadata` attribute).<hr>This is an automatic backport of pull request #1502 done by [Mergify](https://mergify.com). Co-authored-by: Will Shanks <[email protected]>
This change improves several aspects about the way
ExperimentData
works with "providers." Here "provider" is generalized beyondqiskit.providers.Provider
to any object which can provide aJob
-like object with data about an experiment's circuit execution. This generalization is needed becauseqiskit-ibm-runtime
, the main provider that Experiments integrates with, does not use theProvider
class, soqiskit.providers.Provider
andqiskit.providers.Job
with custom interface definitions usingtyping.Protocol
. The new interfaces document the API Experiments needs for working with these objects.IBMExperimentService
authentication parameters from aqiskit_ibm_runtime.QiskitRuntimeService
instance in the same way that the inference used to work withqiskit_ibm_provider.IBMProvider
.IBMExperimentService
from a backend or provider untilExperimentData
tries to communicate with the experiment service. With the fix to infer the authentication parameters fromQiskitRuntimeService
, this delay is needed to avoid breaking existing code that creates anExperimentData
instance and then tries to set a custom experiment service for it, relying on the fact that inferrence did not work forQiskitRuntimeService
, since setting the service onExperimentData
after it has already been set once raises an exception.time_per_step()
. Sinceqiskit-ibm-provider
has long been deprecated and unsupported by IBM Quantum, removing support for it is not treated as a breaking change.metadata
attribute).