-
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
Qiskit Services API #4105
Comments
This proposal has a lot of overlap with what we've been working on in Qiskit/RFCs#2 which is the current working proposal (I've been meaning to update it for a couple of weeks now) for reworking the interface between terra and providers. I think we should move the discussion there so we're all on the same page for the new interface. |
I'm ok but can you edit your rfc and then let me know as it does not go far enough yet (as well as name). I want the terra interface to be more like this for the extra services being made. |
There are many proposals here, but I'm going to focus only on two of them: Async / SyncAsync interfaces are becoming an standard in almost every interface design which has By introducing the differentiation between async and sync in the interface, I think the problem you brought to the table, is more related to having the qasm_sim = QasmSimulator()
job = qasm_sim.run(circuit)
result = job.result()
print(f"Counts: {}", result.get_counts()) There are 3 abstractions here (we don't care about the circuit abstraction here):
And we have these 3 abstractions mainly because the cloud computing has been a major In the other hand, we have local simulations where the concept of job may fade away What if we merge the concepts of job and result? qasm_sim = QasmSimulator()
result = qasm_sim.run(circuit)
print(f"Counts: {}", result)
This new About the resultYes, I don't like our current Result class either, and now that I talked about breaking |
Actually, the |
I am ok with the results (or job) but it needs to be a class per service and sub-service (simulator vs real backend) |
A new Terra issue Qiskit/qiskit#4105 was opened that has partial overlap with the work being done here. It had some good ideas that would make the v2 interface a better fit for a world where there are backends that do more than just run circuits (or pulse schedules). This commit starts the process of integrating the ideas from that into the larger refactor pending for the provider interface.
The way I see this, qasm_sim = QasmSimulator()
result = qasm_sim.run(circuit) # result type being: CountsResult
print(f"Counts: {}", result) Otherwise we have the current model: querying |
I prefer results over the job as well. We can have a method result.job_id() or results.job_status to give the feeling that there are jobs running. But I do like that we are all agreeing that there is not the need for two classes. |
@atilag also good if you edit my original with your proposal. |
Will do. |
Again, the job has everything we need already built in. One can supplement the job with things like having the call statement give the results, but moving in the direction that every is a result is not a great idea. Especially given that the cloud usage is the long term direction over local execution. I honest thought this was decided months ago by @jaygambetta @ajavadia and myself. |
I think we are saying the same thing call job or results somehting_cool we want something_cool to come back from service.run() or service.run_async() I don't have strong view on the name but it should not be two objects. From looking at the code I would prefer results but I'm happy with job. |
I started a WIP on this last week: mtreinish@dd25e46. My biggest concerns here are around the backwards compatibility of the user facing api mainly making I think the way to resolve this is to make |
I do not see why we need change anything about a job being returned. We just need to modify a few things about the job. There are use cases where one actually does want to run simulators async (noise modelling on large or many circuits.) We no longer need |
I agree with Paul we should remove BasicAer -- But paul this needs to be its own issue and also implications to show how to switch to quant-info. Lets not mix this with this issue -- happy to start a new one. The run is my big question for me. Talking with @chriseclectic he suggested we could do run defaults to async and introduce for blocked run
The object returned I don't care what it is called but I like this code
if counts is official a job object with a counts.id etc im good. |
This commit adds the initial implementation of the v2 providers interface. The rfc document in Qiskit/RFCs#2 documents the rationale beind the PR. At a high level this introduces a python based API that provides a general interface for writing additional providers to terra that is flexible enough for both additional types of services in the future and also making it less specific to the IBM Quantum API. Moving forward we will encourage existing provider to migrate to this new interface. Included in this commit the Basicaer provider has been converted to a v2 provider. This will provide a good example for providers on how to use the new model. This is still very much in progress, prior to removing the WIP this will be split into 3 PRs. The first will add the Counts class, the second will add the v2 providers interface, and the 3rd will migrate the BasicAer provider to use the v2 interface all 3 are combined for now for ease ease of testing and development (with github's limitations around dependencies between PRs), but each is an independent piece that can stand on it's own (and will make it much easier for final review). Implements Qiskit/RFCs#2 Fixes Qiskit#4105
This has been mostly done now that we've moved to a new versioned providers interface. The |
With the introduction of more IQX services, such as transpiler-as-a-service, we are moving towards a model where there are local and remote executions of the same task (e.g. simulation, transpilation), and additionally remote executions can be low- or high- latency (e.g. simulator vs. device run).
In order to make it easy for users to switch between different types of executions, we would like to create a uniform API between local vs. remote executions, and additionally accomodate both low- and high-latency executions in a natural way.
The proposal is as follows:
Introduce two methods for explicit sync and async runs, and allow the user to choose one that suits their specific run.
run()
waits for results and returns the result.run_async()
returns a job handle that can be later queried for result. One would userun()
for local simulation, small remote simulations, and typical transpilation.run_async()
can be used for device runs or large remote transpilation jobs.Remove
Result
as wrapper of a job result, which has to be queried again for the things you care about. Instead, directly return the thing that the run was intended for, be it counts, memory, unitary, statevector, or a circuit.So a generic service API will look like:
Concrete examples:
Questions:
Backwards compatibility
We need to keep a deprecation period for the old style to still work. This could be like:
execute is edited to default to use
run_async()
so that it works in the same way but add a message that it will be depreicated."Setup"
Can we do the setup in a Pythonic way for remote services as well? i.e. instead of
doing
and have the config persist across multiple remote runs.
This would be be my preference as this allows the user to see what the service provider can set up
Configurations
In the above, the setup is done with a configuration, currently in the form of
PassManagerConfig
orRunConfig
objects. Should we remove these classes and just havepm.setup()
andbackend.setup()
accept these kwargs directly?objects removed:
The text was updated successfully, but these errors were encountered: