Implement DynamicsBackend.from_backend#157
Conversation
chriseclectic
left a comment
There was a problem hiding this comment.
This looks like it only works with legacy V1 backends from IBMQ Provider since it uses configuration and defaults rather than the new target for V2 backends from the IBM provider. It might be worth discussing with @mtreinish the best way to support both V1 and V2, with focus on V2 going forwards.
We can go through the specific fields on a case by case basis, but @mtreinish and I discussed this, and the gist of it is that we are essentially stuck with only supporting V1 in this method for now (and whatever V2 backends have configuration/defaults for backwards compatibility). The main issue is that the Hamiltonian specification currently has no place in V2 backends, it can only be found in I added the |
|
Right, BackendV2 makes a hard separation between the required fields, the optional fields, and the custom fields for a backend's properties. We started a bit more conservatively with what was required and optional as those basically had dependency inside qiskit-terra and were parts of what we considered the standard interface at the time. Anything outside of that was considered custom and particular implementations of a backend are encouraged to add any extra details they provide and if there is a need for a common interface we can evolve the backend/target to include extra data as it becomes widely used/needed. This was a key part of the design because the ibm payload formats contain a lot of superfluous (especially when coming from a more common circuit only usage patter) and duplicated information and other providers don't give nearly the same level of detail so we wanted the new version to be very clear about the intent behind each field a backend provides. On the IBM provider's backends the As for the gaps in BackendV2, for the case of dynamics I think the big thing as @DanPuzzuoli said is that we're missing hamiltonian definition. The intent at the time of Qiskit/qiskit#5885 was to follow-up after the PR with an object model representation of the hamiltonian and add that as an optional field on the backend (see @nkanazawa1989's comments here: Qiskit/qiskit#5885 (review) ). We have yet to actually start working on that if you had any input on this or an idea of how we should model this object in terra I'd be very keen to try and get this into 0.24.0. Thinking forward though it might be better to try and access the v2 attributes directly if there is equivalent information available outside of |
…n as possible from the target, and updating the documentation to show where everything comes from
|
Thanks for the explanation @mtreinish . Based on these comments I've modified the following:
|
Summary
Closes #53.
This PR is a resubmission of the out-of-date #71 . Its scope is also slightly being expanded to implement the
DynamicsBackend.from_backendmethod, for constructing aDynamicsBackendinstance from an existing backend.Note: this is a duplication of #154 - I seem to have messed up my branches badly and had to restart it.
Details and comments
This PR is composed of:
from_backendmethod, though it won't be heavily advertised or developed beyond its existing form.DynamicsBackend.from_backendmethod, which parses the hamiltonian string of an existing backend, and also imports other backend properties into aDynamicsBackendinstance.configurationanddefaultsmethods have been added for backwards compatibility. A user can set whatever these methods are supposed to return through the options setting infrastructure.Note the explicit choice in this PR to only extract minimal required information from the
backend, and to set up as little as possible in the constructedDynamicsBackend. I.e. noconfigurationordefaultsare constructed, and a minimaltarget(only containing thedtvalue) is constructed. This is for two reasons:configuration/defaultshave a lot of information in them, some of which are duplicated from thetarget. Rather than try to copy the relevant information and make it all consistent, since they are not required elements of theBackendV2interface, we leave it up to the user to set them up and add them if necessary for their use case.