Skip to content

Commit

Permalink
Fixes for Qiskit 1.2 (#2201)
Browse files Browse the repository at this point in the history
* remove configuration and properties from AerBackend

* lint

* lint

* lint

* fix qasm_simulator

* fix qasm_simulator

* fix target

* merge code from #2187 partialy to reduce deprecation warnings

* lint

* fix qasm_simulator

* fix test_sampler_v2

* add configuration and properties in Aer

* lint

* lint

* lint

* lint

* fix set_max_qubits

* test unite-test-latest-qiskit

* remove transpile when unitary gates are in circuits

* fix test

* restore unittest for latest qiskit

* add releasenote
  • Loading branch information
doichanj authored Aug 15, 2024
1 parent 2825e1f commit 44bd7eb
Show file tree
Hide file tree
Showing 30 changed files with 1,407 additions and 624 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests-latest-qiskit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
shell: bash
- name: Install dependencies and Aer
run: |
python -m pip install -U setuptools wheel
python -m pip install -U setuptools setuptools-rust wheel
python -m pip install -U \
-c constraints.txt \
-r requirements-dev.txt \
Expand Down
5 changes: 2 additions & 3 deletions qiskit_aer/backends/aer_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from qiskit.transpiler.passes import Decompose


from qiskit.qobj import QobjExperimentHeader
from qiskit_aer.aererror import AerError
from qiskit_aer.noise import NoiseModel

Expand All @@ -62,7 +61,7 @@
AerConfig,
)

from .backend_utils import circuit_optypes
from .backend_utils import circuit_optypes, CircuitHeader
from ..library.control_flow_instructions import AerMark, AerJump, AerStore


Expand Down Expand Up @@ -682,7 +681,7 @@ def assemble_circuit(circuit: QuantumCircuit, basis_gates=None):
for inst in circuit.data
)

header = QobjExperimentHeader(
header = CircuitHeader(
n_qubits=num_qubits,
qreg_sizes=qreg_sizes,
memory_slots=num_memory,
Expand Down
29 changes: 15 additions & 14 deletions qiskit_aer/backends/aer_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

import copy
import logging
from warnings import warn
from qiskit.providers import convert_to_target
from qiskit.providers.options import Options
from qiskit.providers.models import QasmBackendConfiguration
from qiskit.providers.backend import BackendV2, BackendV1
from qiskit.transpiler.target import target_to_backend_properties

from ..version import __version__
from .aerbackend import AerBackend, AerError
from .backendconfiguration import AerBackendConfiguration
from .backendproperties import target_to_backend_properties
from .backend_utils import (
cpp_execute_circuits,
cpp_execute_qobj,
Expand Down Expand Up @@ -685,7 +686,6 @@ class AerSimulator(AerBackend):
"simulator": True,
"local": True,
"conditional": True,
"open_pulse": False,
"memory": True,
"max_shots": int(1e6),
"description": "A C++ QasmQobj simulator with noise",
Expand Down Expand Up @@ -728,7 +728,7 @@ def __init__(

# Default configuration
if configuration is None:
configuration = QasmBackendConfiguration.from_dict(AerSimulator._DEFAULT_CONFIGURATION)
configuration = AerBackendConfiguration.from_dict(AerSimulator._DEFAULT_CONFIGURATION)

# set backend name from method and device in option
if "from" not in configuration.backend_name:
Expand Down Expand Up @@ -846,29 +846,30 @@ def from_backend(cls, backend, **options):
else:
description = backend.description

configuration = QasmBackendConfiguration(
configuration = AerBackendConfiguration(
backend_name=f"aer_simulator_from({backend.name})",
backend_version=backend.backend_version,
n_qubits=backend.num_qubits,
basis_gates=backend.operation_names,
gates=[],
local=True,
simulator=True,
conditional=True,
open_pulse=False,
memory=False,
max_shots=int(1e6),
coupling_map=(
None if backend.coupling_map is None else list(backend.coupling_map.get_edges())
),
coupling_map=list(backend.coupling_map.get_edges()),
max_experiments=backend.max_circuits,
description=description,
)
properties = target_to_backend_properties(backend.target)
target = backend.target
elif isinstance(backend, BackendV1):
# BackendV1 will be removed in Qiskit 2.0, so we will remove this soon
warn(
" from_backend using V1 based backend is deprecated as of Aer 0.15"
" and will be removed no sooner than 3 months from that release"
" date. Please use backends based on V2.",
DeprecationWarning,
stacklevel=2,
)
# Get configuration and properties from backend
configuration = copy.copy(backend.configuration())
configuration = backend.configuration()
properties = copy.copy(backend.properties())

# Customize configuration name
Expand Down
Loading

0 comments on commit 44bd7eb

Please sign in to comment.