Skip to content
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

Fix QuantumInstance compatibility with BackendV2 (backport #7563) #7605

Merged
merged 2 commits into from
Feb 2, 2022

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Feb 1, 2022

This is an automatic backport of pull request #7563 done by Mergify.


Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com

* 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 <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 6637516)
@jakelishman jakelishman added automerge Changelog: Bugfix Include in the "Fixed" section of the changelog labels Feb 1, 2022
@jakelishman jakelishman added this to the 0.19.2 milestone Feb 1, 2022
@mergify mergify bot merged commit 751f978 into stable/0.19 Feb 2, 2022
@mergify mergify bot deleted the mergify/bp/stable/0.19/pr-7563 branch February 2, 2022 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants