-
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
Compatibility classes for converting BackendV1 to BackendV2 to facilitate migration #8611
Comments
From a typing perspective I don't like your proposed interfaces haha ( Since I complained about your proposed interface, my suggestion would be to add a single class method |
As for the specific details of building this most of the code already exists in the fake providers already. The majority of such a compatibility interface would be converting |
This commit adds a new class BackendV2Converter which is a BackendV2 implementation that converts an input BackendV1 object into a BackendV2 implementation. This is useful for users that are supporting working with arbitrary providers so that they can standardize on using the newest access patterns even if a provider is still using BackendV1. Similarly, for qiskit's internal usage, this gives us a path to move all of the transpiler internals to use Target and avoid carrying around duplicate information in the PassManagerConfig for passes that haven't been updated. This will enable us to convert input BackendV1 instances to a target once on initial calling and have the transpiler only ever see a target. Fixes Qiskit#8611
* Add BackendV2Convert class for treating BackendV1 as BackendV2 This commit adds a new class BackendV2Converter which is a BackendV2 implementation that converts an input BackendV1 object into a BackendV2 implementation. This is useful for users that are supporting working with arbitrary providers so that they can standardize on using the newest access patterns even if a provider is still using BackendV1. Similarly, for qiskit's internal usage, this gives us a path to move all of the transpiler internals to use Target and avoid carrying around duplicate information in the PassManagerConfig for passes that haven't been updated. This will enable us to convert input BackendV1 instances to a target once on initial calling and have the transpiler only ever see a target. Fixes #8611 * Update docstring * Return empty options for _default_options * Remove leftover pylint disable * Expand standard gate conversions and handle missing basis_gates * Fix copy paste error qubit_props_list_from_props() docstring * Add name mapping argument to allow setting custom name-> gate mappings for conversion * Add missing gamma parameter * Fix handling of global ops in configuration * Raise exception on custom gates without mapping * Move name mapping to standard gates module * Fix lint and docs * Use gate object name attribute to build name mapping Co-authored-by: Jake Lishman <[email protected]> * Fix lint * Fix pylint cyclic-import error * Update qiskit/providers/backend_compat.py Co-authored-by: Naoki Kanazawa <[email protected]> * Remove supported_instructions and add option for adding delay The supported instructions field is underdocumented and it's not clear that the instructions it contains are something that we want to support directly. Since the only reason we added support for it in the target generation was to handle the delay for ibm backends (mostly in tests as the IBM provider will be using BackendV2 natively soon) this commit removes its usage and adds a new flag for explicitly adding delay to the backend's target. * Add mention of converter class to API changes section * Add missing flag usage to delay test * Run black Co-authored-by: Jake Lishman <[email protected]> Co-authored-by: Naoki Kanazawa <[email protected]>
…kit/qiskit#8759) * Add BackendV2Convert class for treating BackendV1 as BackendV2 This commit adds a new class BackendV2Converter which is a BackendV2 implementation that converts an input BackendV1 object into a BackendV2 implementation. This is useful for users that are supporting working with arbitrary providers so that they can standardize on using the newest access patterns even if a provider is still using BackendV1. Similarly, for qiskit's internal usage, this gives us a path to move all of the transpiler internals to use Target and avoid carrying around duplicate information in the PassManagerConfig for passes that haven't been updated. This will enable us to convert input BackendV1 instances to a target once on initial calling and have the transpiler only ever see a target. Fixes Qiskit/qiskit#8611 * Update docstring * Return empty options for _default_options * Remove leftover pylint disable * Expand standard gate conversions and handle missing basis_gates * Fix copy paste error qubit_props_list_from_props() docstring * Add name mapping argument to allow setting custom name-> gate mappings for conversion * Add missing gamma parameter * Fix handling of global ops in configuration * Raise exception on custom gates without mapping * Move name mapping to standard gates module * Fix lint and docs * Use gate object name attribute to build name mapping Co-authored-by: Jake Lishman <[email protected]> * Fix lint * Fix pylint cyclic-import error * Update qiskit/providers/backend_compat.py Co-authored-by: Naoki Kanazawa <[email protected]> * Remove supported_instructions and add option for adding delay The supported instructions field is underdocumented and it's not clear that the instructions it contains are something that we want to support directly. Since the only reason we added support for it in the target generation was to handle the delay for ibm backends (mostly in tests as the IBM provider will be using BackendV2 natively soon) this commit removes its usage and adds a new flag for explicitly adding delay to the backend's target. * Add mention of converter class to API changes section * Add missing flag usage to delay test * Run black Co-authored-by: Jake Lishman <[email protected]> Co-authored-by: Naoki Kanazawa <[email protected]>
What should we add?
For package developers trying to transition to new backends it would be very convenient if terra had wrapper backend classes/functions that can make a backend V1 into a backend V2 and vice versa.
Something to this effect was recently added to qiskit-experiments to help facilitate handling both types of backends in tests, however it falls a bit short of general use because it uses duck-typing of methods for both backends but wont actually be an instance of a backend so can't be used as a drop-in replacement.
It would be convenient having either a backend class or generator function that can take one backend and return an equivalent instance of the other.
Eg we could have classes that can be initialized with another backend like:
An alternative would be a function to generate a backend either V1->V2 or V2->V1 (or trivially V1->V1, V2->V2)
The text was updated successfully, but these errors were encountered: