Closed nkanazawa1989 closed 3 months ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
qiskit_ibm_runtime/qiskit_runtime_service.py | 40 | 47 | 85.11% | ||
<!-- | Total: | 40 | 47 | 85.11% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
qiskit_ibm_runtime/qiskit_runtime_service.py | 2 | 77.07% | ||
<!-- | Total: | 2 | --> |
Totals | |
---|---|
Change from base Build 9402463581: | -0.07% |
Covered Lines: | 6017 |
Relevant Lines: | 7312 |
I think there is value in caching the backend data, so we don't need to call the server again to retrieve the same exactly data just to build a target that with different basis gates.
Having said that, the existing caching code is just too complicated, and this PR is a good opportunity to clean it up. A follow up improvement can be a "backend cache" that only stores server data (backend config etc), andBackend
objects are dynamically created with different target, instance, etc but use the same server data.
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
qiskit_ibm_runtime/qiskit_runtime_service.py | 41 | 42 | 97.62% | ||
<!-- | Total: | 41 | 42 | 97.62% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
qiskit_ibm_runtime/qiskit_runtime_service.py | 2 | 78.2% | ||
<!-- | Total: | 2 | --> |
Totals | |
---|---|
Change from base Build 9402463581: | -0.002% |
Covered Lines: | 6015 |
Relevant Lines: | 7304 |
follow up improvement can be a "backend cache" that only stores server data (backend config etc), andBackend objects are dynamically created with different target, instance, etc but use the same server data.
Done in deb6cb6. Cache code is now very simple.
Edit:
Some numbers from benchmark. On my laptop
Of course it depends on internet bandwidth, but seems like this simple cache is sufficient.
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
qiskit_ibm_runtime/qiskit_runtime_service.py | 41 | 42 | 97.62% | ||
qiskit_ibm_runtime/api/clients/runtime.py | 1 | 4 | 25.0% | ||
<!-- | Total: | 42 | 46 | 91.3% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
qiskit_ibm_runtime/qiskit_runtime_service.py | 2 | 78.2% | ||
<!-- | Total: | 2 | --> |
Totals | |
---|---|
Change from base Build 9402463581: | -0.02% |
Covered Lines: | 6016 |
Relevant Lines: | 7307 |
Actually, one more comment - Both backend.properties()
and backend.defaults()
currently have a refresh
keyword that says "If True
, re-query the server for the backend properties/defaults. Otherwise, return a cached version.". Since we only cache configuration now, those need to be deprecated and later removed, unless you want to also add caching for properties/defaults.
Since we only cache configuration now, those need to be deprecated and later removed, unless you want to also add caching for properties/defaults.
I think this behavior should be okey because instance-wise these information are cached. Maybe I should write upgrade note.
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
qiskit_ibm_runtime/qiskit_runtime_service.py | 41 | 42 | 97.62% | ||
qiskit_ibm_runtime/api/clients/runtime.py | 1 | 4 | 25.0% | ||
<!-- | Total: | 42 | 46 | 91.3% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
qiskit_ibm_runtime/qiskit_runtime_service.py | 2 | 78.2% | ||
<!-- | Total: | 2 | --> |
Totals | |
---|---|
Change from base Build 9452478202: | -0.02% |
Covered Lines: | 6048 |
Relevant Lines: | 7341 |
This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
qiskit_ibm_runtime/qiskit_runtime_service.py | 41 | 42 | 97.62% | ||
qiskit_ibm_runtime/api/clients/runtime.py | 1 | 4 | 25.0% | ||
<!-- | Total: | 42 | 46 | 91.3% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
qiskit_ibm_runtime/qiskit_runtime_service.py | 2 | 78.2% | ||
<!-- | Total: | 2 | --> |
Totals | |
---|---|
Change from base Build 9452478202: | -0.02% |
Covered Lines: | 6048 |
Relevant Lines: | 7341 |
Summary
In #1715 we implemented new pattern to retrieve backend from the service, namely, opt-int. With opt-in, the same backend can have different Target, and thus they must be different Python objects.
This PR removes backend instance cache mechanism from
QiskitRuntimeService
. Instead, cache for the configuration data is implemented in theRuntimeClient
.IBMBackend
object is created every time it is requested, but the source data is cached and the communication with the server occurs only once.Details and comments
Once after we announce the fractional gate opt-in (not limited to fractional, some future opt-ins), user may try to compare the performance of our system with and without opt-in. One may write
Note that this does NOT work as expected BUT doesn't raise any warning or error. Note that
backend_with_fg
is silently mutated at the second retrieval via the cache, and both sampler jobs run without fractional gates. One may wonder why two results look comparable.This PR will remove this complication and make internal code much simpler.