Skip to content

Commit

Permalink
Fix calling backend.name() for backendV2 (Qiskit#11065) (Qiskit#11076)
Browse files Browse the repository at this point in the history
* add check for backend version to get backend name

* move backend_interface_version

* check backend is None before get version

* Update qiskit/utils/backend_utils.py

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

* Update releasenotes/notes/fix_backend_name-e84661707058b529.yaml

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

---------

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
(cherry picked from commit d781dcc)

Co-authored-by: Jun Doi <doichan@jp.ibm.com>
  • Loading branch information
mergify[bot] and doichanj authored Oct 21, 2023
1 parent 4b0d30e commit 2f76ef0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
15 changes: 10 additions & 5 deletions qiskit/utils/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,21 @@ def is_statevector_backend(backend):
Returns:
bool: True is statevector
"""
if backend is None:
return False
backend_interface_version = _get_backend_interface_version(backend)
if has_aer():
from qiskit.providers.aer.backends import AerSimulator, StatevectorSimulator

if isinstance(backend, StatevectorSimulator):
return True
if isinstance(backend, AerSimulator) and "aer_simulator_statevector" in backend.name():
return True
if backend is None:
return False
backend_interface_version = _get_backend_interface_version(backend)
if isinstance(backend, AerSimulator):
if backend_interface_version <= 1:
name = backend.name()
else:
name = backend.name
if "aer_simulator_statevector" in name:
return True
if backend_interface_version <= 1:
return backend.name().startswith("statevector")
else:
Expand Down
7 changes: 7 additions & 0 deletions releasenotes/notes/fix_backend_name-e84661707058b529.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
fixes:
- |
Fixed an issue in the :class:`.QuantumInstance` class where it was assuming
all ``AerSimulator`` backends were always :class:`.BackendV1`. This would cause
combatibility issues with the 0.13.0 release of ``qiskit-aer`` which is starting to
use :class:`.BackendV2` for `AerSimulator`` backends.

0 comments on commit 2f76ef0

Please sign in to comment.