forked from qiskit-community/qiskit-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix QuantumInstance compatibility with BackendV2 (Qiskit/qiskit#7563)
* Fix QuantumInstance compatibility with BackendV2 This commit fixes compatibility with the QuantumInstance class when targetting a BackendV2 backend. When BackendV2 was introduced testing with the QuantumInstance (and therefore all of qiskit.algorithms) was neglected and there are several compatibility issues with the class around hard coded assumptions that the backend being wrapped was a BaseBackend or BackendV1 object. * Remove invalid test The tests for the QuantumInstance with BackendV2 were just ported over from the equivalent testing with BackendV1. However, one of those tests was to test error mitigation with a custom noise model which requires qiskit-aer. We can't test this without aer having been migrated to BackendV2. Until qiskit-aer is backendv2 enabled this commit just removes the test. * Remove unused imports * Remove duplicate backend version checks from QuantumInstance The QuantumInstance's is_simulator() and is_local() methods had duplicate checking on the backend version. This was an artifact of testing where in earlier revisions of this PR branch it was done in the QuantumInstance before being moved to the inner helper functions. Since the helper functions are updated to handle the version checking now we no longer need it in the QuantumInstance methods too. This commit removes this and just relies on the helper functions to do the version checking. * Use more descriptive local variable name for backend version This commit attempts to clarify how the version fields are used by naming the local variables backend_interface_version to make it clear what we're checking in that context. * Fix handling of statevector simulator check for BackendV2 This commit fixes the check for whether we're running with a statevector simulator (to determine whether we need to insert save_statevector instructions) to be BackendV2 compatible. This isn't strictly needed yet as qiskit-aer is still based on BackendV1, but this would cause a bug when it does switch to the newer backend version. This commit just gets in front of that potential issue so we don't have a bug in the future. * Use backend_interface_version everywhere There were a few straglers still using backend_version instead of backend_interface_version in the code. This commit updates all these instances so there is consistent naming around this inside the utils subpackage. * Fix handling of statevector simulator detection This commit fixes an oversight from an earlier development version that slipped through later revisions where the statevector simulator backend detection in the QuantumInstance class was hard coded to False for BackendV2. This was just meant as a temporary debugging step while getting the initial commit ready, but was never updated to remove this until now. * Actually commit local variable backend_interface_version renames * Fix typo Co-authored-by: Jake Lishman <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
e0c3254
commit 6d64e59
Showing
3 changed files
with
80 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters