diff --git a/qiskit/algorithms/amplitude_amplifiers/grover.py b/qiskit/algorithms/amplitude_amplifiers/grover.py index 7232fe0e4198..bc9a729a691b 100644 --- a/qiskit/algorithms/amplitude_amplifiers/grover.py +++ b/qiskit/algorithms/amplitude_amplifiers/grover.py @@ -19,7 +19,7 @@ import numpy as np from qiskit import ClassicalRegister, QuantumCircuit -from qiskit.providers import Backend, BaseBackend +from qiskit.providers import Backend from qiskit.quantum_info import partial_trace from qiskit.utils import QuantumInstance from .amplification_problem import AmplificationProblem @@ -112,7 +112,7 @@ def __init__( iterations: Optional[Union[List[int], Iterator[int], int]] = None, growth_rate: Optional[float] = None, sample_from_iterations: bool = False, - quantum_instance: Optional[Union[QuantumInstance, Backend, BaseBackend]] = None, + quantum_instance: Optional[Union[QuantumInstance, Backend]] = None, ) -> None: r""" Args: @@ -172,14 +172,12 @@ def quantum_instance(self) -> Optional[QuantumInstance]: return self._quantum_instance @quantum_instance.setter - def quantum_instance( - self, quantum_instance: Union[QuantumInstance, BaseBackend, Backend] - ) -> None: + def quantum_instance(self, quantum_instance: Union[QuantumInstance, Backend]) -> None: """Set quantum instance. Args: quantum_instance: The quantum instance used to run this algorithm. """ - if isinstance(quantum_instance, (BaseBackend, Backend)): + if isinstance(quantum_instance, Backend): quantum_instance = QuantumInstance(quantum_instance) self._quantum_instance = quantum_instance diff --git a/qiskit/algorithms/amplitude_estimators/ae.py b/qiskit/algorithms/amplitude_estimators/ae.py index 295605a888c5..4d4c89873235 100644 --- a/qiskit/algorithms/amplitude_estimators/ae.py +++ b/qiskit/algorithms/amplitude_estimators/ae.py @@ -19,7 +19,7 @@ from scipy.optimize import bisect from qiskit import QuantumCircuit, ClassicalRegister -from qiskit.providers import BaseBackend, Backend +from qiskit.providers import Backend from qiskit.utils import QuantumInstance from .amplitude_estimator import AmplitudeEstimator, AmplitudeEstimatorResult from .ae_utils import pdf_a, derivative_log_pdf_a, bisect_max @@ -58,7 +58,7 @@ def __init__( num_eval_qubits: int, phase_estimation_circuit: Optional[QuantumCircuit] = None, iqft: Optional[QuantumCircuit] = None, - quantum_instance: Optional[Union[QuantumInstance, BaseBackend, Backend]] = None, + quantum_instance: Optional[Union[QuantumInstance, Backend]] = None, ) -> None: r""" Args: @@ -98,15 +98,13 @@ def quantum_instance(self) -> Optional[QuantumInstance]: return self._quantum_instance @quantum_instance.setter - def quantum_instance( - self, quantum_instance: Union[QuantumInstance, BaseBackend, Backend] - ) -> None: + def quantum_instance(self, quantum_instance: Union[QuantumInstance, Backend]) -> None: """Set quantum instance. Args: quantum_instance: The quantum instance used to run this algorithm. """ - if isinstance(quantum_instance, (BaseBackend, Backend)): + if isinstance(quantum_instance, Backend): quantum_instance = QuantumInstance(quantum_instance) self._quantum_instance = quantum_instance diff --git a/qiskit/algorithms/amplitude_estimators/fae.py b/qiskit/algorithms/amplitude_estimators/fae.py index 7993a4d4fa1c..db8ee9151d50 100644 --- a/qiskit/algorithms/amplitude_estimators/fae.py +++ b/qiskit/algorithms/amplitude_estimators/fae.py @@ -16,7 +16,7 @@ import numpy as np from qiskit.circuit import QuantumCircuit, ClassicalRegister -from qiskit.providers import BaseBackend, Backend +from qiskit.providers import Backend from qiskit.utils import QuantumInstance from qiskit.algorithms.exceptions import AlgorithmError @@ -50,7 +50,7 @@ def __init__( delta: float, maxiter: int, rescale: bool = True, - quantum_instance: Optional[Union[QuantumInstance, BaseBackend, Backend]] = None, + quantum_instance: Optional[Union[QuantumInstance, Backend]] = None, ) -> None: r""" Args: @@ -83,15 +83,13 @@ def quantum_instance(self) -> Optional[QuantumInstance]: return self._quantum_instance @quantum_instance.setter - def quantum_instance( - self, quantum_instance: Union[QuantumInstance, BaseBackend, Backend] - ) -> None: + def quantum_instance(self, quantum_instance: Union[QuantumInstance, Backend]) -> None: """Set quantum instance. Args: quantum_instance: The quantum instance used to run this algorithm. """ - if isinstance(quantum_instance, (BaseBackend, Backend)): + if isinstance(quantum_instance, Backend): quantum_instance = QuantumInstance(quantum_instance) self._quantum_instance = quantum_instance diff --git a/qiskit/algorithms/amplitude_estimators/iae.py b/qiskit/algorithms/amplitude_estimators/iae.py index 38a303731a30..42727cc5aea0 100644 --- a/qiskit/algorithms/amplitude_estimators/iae.py +++ b/qiskit/algorithms/amplitude_estimators/iae.py @@ -17,7 +17,7 @@ from scipy.stats import beta from qiskit import ClassicalRegister, QuantumCircuit -from qiskit.providers import BaseBackend, Backend +from qiskit.providers import Backend from qiskit.utils import QuantumInstance from .amplitude_estimator import AmplitudeEstimator, AmplitudeEstimatorResult @@ -52,7 +52,7 @@ def __init__( alpha: float, confint_method: str = "beta", min_ratio: float = 2, - quantum_instance: Optional[Union[QuantumInstance, BaseBackend, Backend]] = None, + quantum_instance: Optional[Union[QuantumInstance, Backend]] = None, ) -> None: r""" The output of the algorithm is an estimate for the amplitude `a`, that with at least @@ -107,15 +107,13 @@ def quantum_instance(self) -> Optional[QuantumInstance]: return self._quantum_instance @quantum_instance.setter - def quantum_instance( - self, quantum_instance: Union[QuantumInstance, BaseBackend, Backend] - ) -> None: + def quantum_instance(self, quantum_instance: Union[QuantumInstance, Backend]) -> None: """Set quantum instance. Args: quantum_instance: The quantum instance used to run this algorithm. """ - if isinstance(quantum_instance, (BaseBackend, Backend)): + if isinstance(quantum_instance, Backend): quantum_instance = QuantumInstance(quantum_instance) self._quantum_instance = quantum_instance diff --git a/qiskit/algorithms/amplitude_estimators/mlae.py b/qiskit/algorithms/amplitude_estimators/mlae.py index c28ae772dafd..21ca0cb35d1a 100644 --- a/qiskit/algorithms/amplitude_estimators/mlae.py +++ b/qiskit/algorithms/amplitude_estimators/mlae.py @@ -17,7 +17,6 @@ from scipy.optimize import brute from scipy.stats import norm, chi2 -from qiskit.providers import BaseBackend from qiskit.providers import Backend from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit from qiskit.utils import QuantumInstance @@ -52,7 +51,7 @@ def __init__( self, evaluation_schedule: Union[List[int], int], minimizer: Optional[MINIMIZER] = None, - quantum_instance: Optional[Union[QuantumInstance, BaseBackend, Backend]] = None, + quantum_instance: Optional[Union[QuantumInstance, Backend]] = None, ) -> None: r""" Args: @@ -109,15 +108,13 @@ def quantum_instance(self) -> Optional[QuantumInstance]: return self._quantum_instance @quantum_instance.setter - def quantum_instance( - self, quantum_instance: Union[QuantumInstance, BaseBackend, Backend] - ) -> None: + def quantum_instance(self, quantum_instance: Union[QuantumInstance, Backend]) -> None: """Set quantum instance. Args: quantum_instance: The quantum instance used to run this algorithm. """ - if isinstance(quantum_instance, (BaseBackend, Backend)): + if isinstance(quantum_instance, Backend): quantum_instance = QuantumInstance(quantum_instance) self._quantum_instance = quantum_instance diff --git a/qiskit/algorithms/aux_ops_evaluator.py b/qiskit/algorithms/aux_ops_evaluator.py index 9e11604dc10c..dded8f80645b 100644 --- a/qiskit/algorithms/aux_ops_evaluator.py +++ b/qiskit/algorithms/aux_ops_evaluator.py @@ -23,7 +23,7 @@ OperatorBase, ExpectationBase, ) -from qiskit.providers import BaseBackend, Backend +from qiskit.providers import Backend from qiskit.quantum_info import Statevector from qiskit.utils import QuantumInstance @@ -31,7 +31,7 @@ def eval_observables( - quantum_instance: Union[QuantumInstance, BaseBackend, Backend], + quantum_instance: Union[QuantumInstance, Backend], quantum_state: Union[ Statevector, QuantumCircuit, @@ -161,7 +161,7 @@ def _compute_std_devs( observables_expect_sampled: OperatorBase, observables: ListOrDict[OperatorBase], expectation: ExpectationBase, - quantum_instance: Union[QuantumInstance, BaseBackend, Backend], + quantum_instance: Union[QuantumInstance, Backend], ) -> List[complex]: """ Calculates a list of standard deviations from expectation values of observables provided. diff --git a/qiskit/algorithms/factorizers/shor.py b/qiskit/algorithms/factorizers/shor.py index d07d5e172711..1030747ae89f 100644 --- a/qiskit/algorithms/factorizers/shor.py +++ b/qiskit/algorithms/factorizers/shor.py @@ -25,7 +25,6 @@ from qiskit.circuit import Gate, Instruction, ParameterVector from qiskit.circuit.library import QFT from qiskit.providers import Backend -from qiskit.providers import BaseBackend from qiskit.quantum_info import partial_trace from qiskit.utils import summarize_circuits from qiskit.utils.arithmetic import is_power @@ -51,9 +50,7 @@ class Shor: See also https://arxiv.org/abs/quant-ph/0205095 """ - def __init__( - self, quantum_instance: Optional[Union[QuantumInstance, BaseBackend, Backend]] = None - ) -> None: + def __init__(self, quantum_instance: Optional[Union[QuantumInstance, Backend]] = None) -> None: """ Args: quantum_instance: Quantum Instance or Backend @@ -69,11 +66,9 @@ def quantum_instance(self) -> Optional[QuantumInstance]: return self._quantum_instance @quantum_instance.setter - def quantum_instance( - self, quantum_instance: Union[QuantumInstance, BaseBackend, Backend] - ) -> None: + def quantum_instance(self, quantum_instance: Union[QuantumInstance, Backend]) -> None: """Sets quantum instance.""" - if isinstance(quantum_instance, (BaseBackend, Backend)): + if isinstance(quantum_instance, Backend): quantum_instance = QuantumInstance(quantum_instance) self._quantum_instance = quantum_instance diff --git a/qiskit/algorithms/linear_solvers/hhl.py b/qiskit/algorithms/linear_solvers/hhl.py index cf6dbd6e59dc..71b954148de2 100644 --- a/qiskit/algorithms/linear_solvers/hhl.py +++ b/qiskit/algorithms/linear_solvers/hhl.py @@ -29,7 +29,7 @@ ListOp, ExpectationFactory, ) -from qiskit.providers import Backend, BaseBackend +from qiskit.providers import Backend from qiskit.quantum_info.operators.base_operator import BaseOperator from qiskit.utils import QuantumInstance @@ -100,7 +100,7 @@ def __init__( self, epsilon: float = 1e-2, expectation: Optional[ExpectationBase] = None, - quantum_instance: Optional[Union[Backend, BaseBackend, QuantumInstance]] = None, + quantum_instance: Optional[Union[Backend, QuantumInstance]] = None, ) -> None: r""" Args: @@ -142,9 +142,7 @@ def quantum_instance(self) -> Optional[QuantumInstance]: return None if self._sampler is None else self._sampler.quantum_instance @quantum_instance.setter - def quantum_instance( - self, quantum_instance: Optional[Union[QuantumInstance, BaseBackend, Backend]] - ) -> None: + def quantum_instance(self, quantum_instance: Optional[Union[QuantumInstance, Backend]]) -> None: """Set quantum instance. Args: diff --git a/qiskit/algorithms/minimum_eigen_solvers/qaoa.py b/qiskit/algorithms/minimum_eigen_solvers/qaoa.py index f7d3430d7213..da0273e69fb3 100644 --- a/qiskit/algorithms/minimum_eigen_solvers/qaoa.py +++ b/qiskit/algorithms/minimum_eigen_solvers/qaoa.py @@ -20,7 +20,6 @@ from qiskit.opflow import OperatorBase, ExpectationBase from qiskit.opflow.gradients import GradientBase from qiskit.providers import Backend -from qiskit.providers import BaseBackend from qiskit.utils.quantum_instance import QuantumInstance from qiskit.utils.validation import validate_min from qiskit.circuit.library.n_local.qaoa_ansatz import QAOAAnsatz @@ -65,7 +64,7 @@ def __init__( include_custom: bool = False, max_evals_grouped: int = 1, callback: Optional[Callable[[int, np.ndarray, float, float], None]] = None, - quantum_instance: Optional[Union[QuantumInstance, BaseBackend, Backend]] = None, + quantum_instance: Optional[Union[QuantumInstance, Backend]] = None, ) -> None: """ Args: diff --git a/qiskit/algorithms/minimum_eigen_solvers/vqe.py b/qiskit/algorithms/minimum_eigen_solvers/vqe.py index e401a2b007cd..36b1ce4878b4 100755 --- a/qiskit/algorithms/minimum_eigen_solvers/vqe.py +++ b/qiskit/algorithms/minimum_eigen_solvers/vqe.py @@ -24,7 +24,6 @@ from qiskit.circuit import QuantumCircuit, Parameter from qiskit.circuit.library import RealAmplitudes -from qiskit.providers import BaseBackend from qiskit.providers import Backend from qiskit.opflow import ( OperatorBase, @@ -145,7 +144,7 @@ def __init__( include_custom: bool = False, max_evals_grouped: int = 1, callback: Optional[Callable[[int, np.ndarray, float, float], None]] = None, - quantum_instance: Optional[Union[QuantumInstance, BaseBackend, Backend]] = None, + quantum_instance: Optional[Union[QuantumInstance, Backend]] = None, ) -> None: """ @@ -254,9 +253,7 @@ def quantum_instance(self) -> Optional[QuantumInstance]: return self._quantum_instance @quantum_instance.setter - def quantum_instance( - self, quantum_instance: Union[QuantumInstance, BaseBackend, Backend] - ) -> None: + def quantum_instance(self, quantum_instance: Union[QuantumInstance, Backend]) -> None: """Sets quantum_instance""" if not isinstance(quantum_instance, QuantumInstance): quantum_instance = QuantumInstance(quantum_instance) diff --git a/qiskit/algorithms/phase_estimators/hamiltonian_phase_estimation.py b/qiskit/algorithms/phase_estimators/hamiltonian_phase_estimation.py index 820fd76cac85..d84d262249a6 100644 --- a/qiskit/algorithms/phase_estimators/hamiltonian_phase_estimation.py +++ b/qiskit/algorithms/phase_estimators/hamiltonian_phase_estimation.py @@ -25,7 +25,7 @@ PauliSumOp, StateFn, ) -from qiskit.providers import BaseBackend +from qiskit.providers import Backend from .phase_estimation import PhaseEstimation from .hamiltonian_phase_estimation_result import HamiltonianPhaseEstimationResult from .phase_estimation_scale import PhaseEstimationScale @@ -88,7 +88,7 @@ class HamiltonianPhaseEstimation: def __init__( self, num_evaluation_qubits: int, - quantum_instance: Optional[Union[QuantumInstance, BaseBackend]] = None, + quantum_instance: Optional[Union[QuantumInstance, Backend]] = None, ) -> None: """ Args: diff --git a/qiskit/algorithms/phase_estimators/ipe.py b/qiskit/algorithms/phase_estimators/ipe.py index d1af944c705c..67236617a9c3 100644 --- a/qiskit/algorithms/phase_estimators/ipe.py +++ b/qiskit/algorithms/phase_estimators/ipe.py @@ -19,7 +19,7 @@ import qiskit from qiskit.circuit import QuantumCircuit, QuantumRegister from qiskit.circuit.classicalregister import ClassicalRegister -from qiskit.providers import BaseBackend, Backend +from qiskit.providers import Backend from qiskit.utils import QuantumInstance from .phase_estimator import PhaseEstimator from .phase_estimator import PhaseEstimatorResult @@ -38,7 +38,7 @@ class IterativePhaseEstimation(PhaseEstimator): def __init__( self, num_iterations: int, - quantum_instance: Optional[Union[QuantumInstance, BaseBackend, Backend]] = None, + quantum_instance: Optional[Union[QuantumInstance, Backend]] = None, ) -> None: """Args: @@ -48,7 +48,7 @@ def __init__( Raises: ValueError: if num_iterations is not greater than zero. """ - if isinstance(quantum_instance, (Backend, BaseBackend)): + if isinstance(quantum_instance, Backend): quantum_instance = QuantumInstance(quantum_instance) self._quantum_instance = quantum_instance if num_iterations <= 0: diff --git a/qiskit/algorithms/phase_estimators/phase_estimation.py b/qiskit/algorithms/phase_estimators/phase_estimation.py index ab7b4644879f..a833152f6c14 100644 --- a/qiskit/algorithms/phase_estimators/phase_estimation.py +++ b/qiskit/algorithms/phase_estimators/phase_estimation.py @@ -21,7 +21,7 @@ import qiskit from qiskit import circuit from qiskit.circuit.classicalregister import ClassicalRegister -from qiskit.providers import BaseBackend, Backend +from qiskit.providers import Backend from qiskit.utils import QuantumInstance from qiskit.result import Result from .phase_estimation_result import PhaseEstimationResult, _sort_phases @@ -81,7 +81,7 @@ class PhaseEstimation(PhaseEstimator): def __init__( self, num_evaluation_qubits: int, - quantum_instance: Optional[Union[QuantumInstance, BaseBackend, Backend]] = None, + quantum_instance: Optional[Union[QuantumInstance, Backend]] = None, ) -> None: """ Args: @@ -94,7 +94,7 @@ def __init__( if num_evaluation_qubits is not None: self._num_evaluation_qubits = num_evaluation_qubits - if isinstance(quantum_instance, (Backend, BaseBackend)): + if isinstance(quantum_instance, Backend): quantum_instance = QuantumInstance(quantum_instance) self._quantum_instance = quantum_instance diff --git a/qiskit/compiler/assembler.py b/qiskit/compiler/assembler.py index e6d23d314ec1..9dc53b30e21c 100644 --- a/qiskit/compiler/assembler.py +++ b/qiskit/compiler/assembler.py @@ -24,7 +24,6 @@ from qiskit.assembler.run_config import RunConfig from qiskit.circuit import QuantumCircuit, Qubit, Parameter from qiskit.exceptions import QiskitError -from qiskit.providers import BaseBackend from qiskit.providers.backend import Backend from qiskit.pulse import LoConfig, Instruction from qiskit.pulse import Schedule, ScheduleBlock @@ -50,7 +49,7 @@ def assemble( ScheduleBlock, List[ScheduleBlock], ], - backend: Optional[Union[Backend, BaseBackend]] = None, + backend: Optional[Backend] = None, qobj_id: Optional[str] = None, qobj_header: Optional[Union[QobjHeader, Dict]] = None, shots: Optional[int] = None, diff --git a/qiskit/compiler/scheduler.py b/qiskit/compiler/scheduler.py index 715ba8b3e7c2..fea7d0934488 100644 --- a/qiskit/compiler/scheduler.py +++ b/qiskit/compiler/scheduler.py @@ -22,7 +22,6 @@ from qiskit.circuit.quantumcircuit import QuantumCircuit from qiskit.exceptions import QiskitError from qiskit.pulse import InstructionScheduleMap, Schedule -from qiskit.providers import BaseBackend from qiskit.providers.backend import Backend from qiskit.scheduler import ScheduleConfig from qiskit.scheduler.schedule_circuit import schedule_circuit @@ -37,7 +36,7 @@ def _log_schedule_time(start_time, end_time): def schedule( circuits: Union[QuantumCircuit, List[QuantumCircuit]], - backend: Optional[Union[Backend, BaseBackend]] = None, + backend: Optional[Backend] = None, inst_map: Optional[InstructionScheduleMap] = None, meas_map: Optional[List[List[int]]] = None, dt: Optional[float] = None, diff --git a/qiskit/compiler/sequencer.py b/qiskit/compiler/sequencer.py index da502a1eda05..541f78c9f762 100644 --- a/qiskit/compiler/sequencer.py +++ b/qiskit/compiler/sequencer.py @@ -17,7 +17,6 @@ from qiskit.circuit.quantumcircuit import QuantumCircuit from qiskit.exceptions import QiskitError -from qiskit.providers import BaseBackend from qiskit.providers.backend import Backend from qiskit.pulse import InstructionScheduleMap, Schedule from qiskit.scheduler import ScheduleConfig @@ -26,7 +25,7 @@ def sequence( scheduled_circuits: Union[QuantumCircuit, List[QuantumCircuit]], - backend: Optional[Union[Backend, BaseBackend]] = None, + backend: Optional[Backend] = None, inst_map: Optional[InstructionScheduleMap] = None, meas_map: Optional[List[List[int]]] = None, dt: Optional[float] = None, diff --git a/qiskit/compiler/transpiler.py b/qiskit/compiler/transpiler.py index f322935fed7b..4b7b0bbf0869 100644 --- a/qiskit/compiler/transpiler.py +++ b/qiskit/compiler/transpiler.py @@ -22,7 +22,6 @@ from qiskit.circuit.quantumregister import Qubit from qiskit.converters import isinstanceint, isinstancelist, dag_to_circuit, circuit_to_dag from qiskit.dagcircuit import DAGCircuit -from qiskit.providers import BaseBackend from qiskit.providers.backend import Backend from qiskit.providers.models import BackendProperties from qiskit.providers.models.backendproperties import Gate @@ -48,7 +47,7 @@ def transpile( circuits: Union[QuantumCircuit, List[QuantumCircuit]], - backend: Optional[Union[Backend, BaseBackend]] = None, + backend: Optional[Backend] = None, basis_gates: Optional[List[str]] = None, inst_map: Optional[List[InstructionScheduleMap]] = None, coupling_map: Optional[Union[CouplingMap, List[List[int]]]] = None, @@ -327,8 +326,6 @@ def _check_circuits_coupling_map(circuits, transpile_args, backend): # If coupling_map is None, the limit might be in the backend (like in 1Q devices) elif backend is not None: backend_version = getattr(backend, "version", 0) - if not isinstance(backend_version, int): - backend_version = 0 if backend_version <= 1: if not backend.configuration().simulator: max_qubits = backend.configuration().n_qubits @@ -611,8 +608,6 @@ def _create_faulty_qubits_map(backend): faulty_qubits_map = None if backend is not None: backend_version = getattr(backend, "version", 0) - if not isinstance(backend_version, int): - backend_version = 0 if backend_version > 1: return None if backend.properties(): @@ -647,8 +642,6 @@ def _parse_basis_gates(basis_gates, backend, circuits): # try getting basis_gates from user, else backend if basis_gates is None: backend_version = getattr(backend, "version", 0) - if not isinstance(backend_version, int): - backend_version = 0 if backend_version <= 1: if getattr(backend, "configuration", None): basis_gates = getattr(backend.configuration(), "basis_gates", None) @@ -667,8 +660,6 @@ def _parse_inst_map(inst_map, backend, num_circuits): # try getting inst_map from user, else backend if inst_map is None: backend_version = getattr(backend, "version", 0) - if not isinstance(backend_version, int): - backend_version = 0 if backend_version <= 1: if hasattr(backend, "defaults"): inst_map = getattr(backend.defaults(), "instruction_schedule_map", None) @@ -685,8 +676,6 @@ def _parse_coupling_map(coupling_map, backend, num_circuits): # try getting coupling_map from user, else backend if coupling_map is None: backend_version = getattr(backend, "version", 0) - if not isinstance(backend_version, int): - backend_version = 0 if backend_version <= 1: if getattr(backend, "configuration", None): configuration = backend.configuration() @@ -809,9 +798,7 @@ def _target_to_backend_properties(target: Target): def _parse_backend_properties(backend_properties, backend, num_circuits): # try getting backend_properties from user, else backend if backend_properties is None: - backend_version = getattr(backend, "version", None) - if not isinstance(backend_version, int): - backend_version = 0 + backend_version = getattr(backend, "version", 0) if backend_version <= 1: if getattr(backend, "properties", None): backend_properties = backend.properties() @@ -854,8 +841,6 @@ def _parse_backend_num_qubits(backend, num_circuits): return [None] * num_circuits if not isinstance(backend, list): backend_version = getattr(backend, "version", 0) - if not isinstance(backend_version, int): - backend_version = 0 if backend_version <= 1: return [backend.configuration().n_qubits] * num_circuits else: @@ -863,8 +848,6 @@ def _parse_backend_num_qubits(backend, num_circuits): backend_num_qubits = [] for a_backend in backend: backend_version = getattr(backend, "version", 0) - if not isinstance(backend_version, int): - backend_version = 0 if backend_version <= 1: backend_num_qubits.append(a_backend.configuration().n_qubits) else: @@ -1065,8 +1048,6 @@ def _parse_timing_constraints(backend, timing_constraints, num_circuits): timing_constraints = TimingConstraints() else: backend_version = getattr(backend, "version", 0) - if not isinstance(backend_version, int): - backend_version = 0 if backend_version <= 1: if timing_constraints is None: # get constraints from backend diff --git a/qiskit/execute_function.py b/qiskit/execute_function.py index 3b211ff3a444..3968de043059 100644 --- a/qiskit/execute_function.py +++ b/qiskit/execute_function.py @@ -22,10 +22,8 @@ import logging from time import time import warnings -from qiskit.compiler import transpile, assemble, schedule -from qiskit.providers import BaseBackend +from qiskit.compiler import transpile, schedule from qiskit.providers.backend import Backend -from qiskit.qobj.utils import MeasLevel, MeasReturnType from qiskit.pulse import Schedule, ScheduleBlock from qiskit.exceptions import QiskitError @@ -81,7 +79,7 @@ def execute( experiments (QuantumCircuit or list[QuantumCircuit] or Schedule or list[Schedule]): Circuit(s) or pulse schedule(s) to execute - backend (BaseBackend or Backend): + backend (Backend): Backend to execute circuits on. Transpiler options are automatically grabbed from backend.configuration() and backend.properties(). @@ -155,11 +153,15 @@ def execute( arg is present, auto-selection of pass manager based on the transpile options will be turned off and this pass manager will be used directly. - qobj_id (str): String identifier to annotate the Qobj + qobj_id (str): DEPRECATED: String identifier to annotate the Qobj. This has no effect + and the :attr:`~.QuantumCircuit.name` attribute of the input circuit(s) should be used + instead. - qobj_header (QobjHeader or dict): User input that will be inserted in Qobj header, - and will also be copied to the corresponding :class:`qiskit.result.Result` - header. Headers do not affect the run. + qobj_header (QobjHeader or dict): DEPRECATED: User input that will be inserted in Qobj + header, and will also be copied to the corresponding :class:`qiskit.result.Result` + header. Headers do not affect the run. Headers do not affect the run. This kwarg + has no effect anymore and the :attr:`~.QuantumCircuit.metadata` attribute of the + input circuit(s) should be used instead. shots (int): Number of repetitions of each circuit, for sampling. Default: 1024 @@ -254,7 +256,7 @@ def execute( Qobj config, and passed to backend.run() Returns: - BaseJob: returns job instance derived from BaseJob + Job: returns job instance derived from Job Raises: QiskitError: if the execution cannot be interpreted as either circuits or schedules @@ -322,49 +324,21 @@ def execute( stacklevel=2, ) - if isinstance(backend, BaseBackend): - # assembling the circuits into a qobj to be run on the backend - if shots is None: - shots = 1024 - if memory is None: - memory = False - if meas_level is None: - meas_level = MeasLevel.CLASSIFIED - if meas_return is None: - meas_return = MeasReturnType.AVERAGE - if memory_slot_size is None: - memory_slot_size = 100 - - qobj = assemble( - experiments, - qobj_id=qobj_id, - qobj_header=qobj_header, - shots=shots, - memory=memory, - seed_simulator=seed_simulator, - qubit_lo_freq=default_qubit_los, - meas_lo_freq=default_meas_los, - qubit_lo_range=qubit_lo_range, - meas_lo_range=meas_lo_range, - schedule_los=schedule_los, - meas_level=meas_level, - meas_return=meas_return, - memory_slots=memory_slots, - memory_slot_size=memory_slot_size, - rep_time=rep_time, - rep_delay=rep_delay, - parameter_binds=parameter_binds, - backend=backend, - init_qubits=init_qubits, - **run_config, + if qobj_id is not None: + warnings.warn( + "The qobj_id argument is deprecated as of the Qiskit Terra 0.21.0, " + "and will be remvoed in a future release. This argument has no effect and " + "is not used by any backends." ) - # executing the circuits on the backend and returning the job - start_time = time() - job = backend.run(qobj, **run_config) - end_time = time() - _log_submission_time(start_time, end_time) - elif isinstance(backend, Backend): + if qobj_header is not None: + warnings.warn( + "The qobj_header argument is deprecated as of the Qiskit Terra 0.21.0, " + "and will be remvoed in a future release. This argument has no effect and " + "is not used by any backends." + ) + + if isinstance(backend, Backend): start_time = time() run_kwargs = { "shots": shots, diff --git a/qiskit/opflow/converters/circuit_sampler.py b/qiskit/opflow/converters/circuit_sampler.py index 229d7d289168..467ab43029c6 100644 --- a/qiskit/opflow/converters/circuit_sampler.py +++ b/qiskit/opflow/converters/circuit_sampler.py @@ -29,7 +29,7 @@ from qiskit.opflow.state_fns.circuit_state_fn import CircuitStateFn from qiskit.opflow.state_fns.dict_state_fn import DictStateFn from qiskit.opflow.state_fns.state_fn import StateFn -from qiskit.providers import Backend, BaseBackend +from qiskit.providers import Backend from qiskit.utils.backend_utils import is_aer_provider, is_statevector_backend from qiskit.utils.quantum_instance import QuantumInstance @@ -53,7 +53,7 @@ class CircuitSampler(ConverterBase): def __init__( self, - backend: Union[Backend, BaseBackend, QuantumInstance], + backend: Union[Backend, QuantumInstance], statevector: Optional[bool] = None, param_qobj: bool = False, attach_results: bool = False, @@ -129,15 +129,13 @@ def quantum_instance(self) -> QuantumInstance: return self._quantum_instance @quantum_instance.setter - def quantum_instance( - self, quantum_instance: Union[QuantumInstance, Backend, BaseBackend] - ) -> None: + def quantum_instance(self, quantum_instance: Union[QuantumInstance, Backend]) -> None: """Sets the QuantumInstance. Raises: ValueError: statevector or param_qobj are True when not supported by backend. """ - if isinstance(quantum_instance, (Backend, BaseBackend)): + if isinstance(quantum_instance, Backend): quantum_instance = QuantumInstance(quantum_instance) self._quantum_instance = quantum_instance self._check_quantum_instance_and_modes_consistent() diff --git a/qiskit/opflow/expectations/expectation_factory.py b/qiskit/opflow/expectations/expectation_factory.py index 4fcfea5e0ad7..182d7993809a 100644 --- a/qiskit/opflow/expectations/expectation_factory.py +++ b/qiskit/opflow/expectations/expectation_factory.py @@ -21,7 +21,7 @@ from qiskit.opflow.expectations.matrix_expectation import MatrixExpectation from qiskit.opflow.expectations.pauli_expectation import PauliExpectation from qiskit.opflow.operator_base import OperatorBase -from qiskit.providers import Backend, BaseBackend +from qiskit.providers import Backend from qiskit.utils.backend_utils import has_aer, is_aer_qasm, is_statevector_backend from qiskit.utils.quantum_instance import QuantumInstance @@ -36,7 +36,7 @@ class ExpectationFactory: @staticmethod def build( operator: OperatorBase, - backend: Optional[Union[Backend, BaseBackend, QuantumInstance]] = None, + backend: Optional[Union[Backend, QuantumInstance]] = None, include_custom: bool = True, ) -> ExpectationBase: """ diff --git a/qiskit/opflow/gradients/derivative_base.py b/qiskit/opflow/gradients/derivative_base.py index 9979a498c8dc..7eff1e4e57c8 100644 --- a/qiskit/opflow/gradients/derivative_base.py +++ b/qiskit/opflow/gradients/derivative_base.py @@ -19,7 +19,7 @@ import numpy as np from qiskit.utils.quantum_instance import QuantumInstance from qiskit.circuit import ParameterExpression, ParameterVector -from qiskit.providers import BaseBackend, Backend +from qiskit.providers import Backend from ..converters.converter_base import ConverterBase from ..expectations import ExpectationBase, PauliExpectation @@ -83,7 +83,7 @@ def gradient_wrapper( List[Tuple[ParameterExpression, ParameterExpression]], ] ] = None, - backend: Optional[Union[BaseBackend, Backend, QuantumInstance]] = None, + backend: Optional[Union[Backend, QuantumInstance]] = None, expectation: Optional[ExpectationBase] = None, ) -> Callable[[Iterable], np.ndarray]: """Get a callable function which provides the respective gradient, Hessian or QFI for given diff --git a/qiskit/providers/__init__.py b/qiskit/providers/__init__.py index 97f133a72dbe..7cca9ed49e49 100644 --- a/qiskit/providers/__init__.py +++ b/qiskit/providers/__init__.py @@ -112,6 +112,25 @@ Job JobV1 +Job Status +---------- + +.. autosummary:: + :toctree: ../stubs/ + + JobStatus + +Exceptions +---------- + +.. autosummary:: + :toctree: ../stubs/ + + QiskitBackendNotFoundError + BackendPropertyError + JobError + JobTimeoutError + ====================== Writing a New Provider ====================== @@ -647,47 +666,6 @@ def status(self): operation on a given qubit is used to model the readout length. However, a :obj:`~BackendV2` can implement multiple measurement types and list them separately in a :class:`~qiskit.transpiler.Target`. - - -================================================================ -Legacy Provider Interface Base Objects (:mod:`qiskit.providers`) -================================================================ - -These abstract interfaces are deprecated and will be removed in a future -release. The documentation here is left for reference purposes while they're -still supported, but if you're creating or maintaining a provider you should -be using the versioned interface. - -.. currentmodule:: qiskit.providers - -Base Objects -============ - -.. autosummary:: - :toctree: ../stubs/ - - BaseProvider - BaseBackend - BaseJob - -Job Status -========== - -.. autosummary:: - :toctree: ../stubs/ - - JobStatus - -Exceptions -========== - -.. autosummary:: - :toctree: ../stubs/ - - QiskitBackendNotFoundError - BackendPropertyError - JobError - JobTimeoutError """ import pkgutil @@ -703,10 +681,6 @@ def status(self): from qiskit.providers.job import Job from qiskit.providers.job import JobV1 -# Legacy providers interface -from qiskit.providers.basebackend import BaseBackend -from qiskit.providers.baseprovider import BaseProvider -from qiskit.providers.basejob import BaseJob from qiskit.providers.exceptions import ( JobError, JobTimeoutError, diff --git a/qiskit/providers/basebackend.py b/qiskit/providers/basebackend.py deleted file mode 100644 index 09ba54ee45d6..000000000000 --- a/qiskit/providers/basebackend.py +++ /dev/null @@ -1,132 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""This module implements the legacy abstract base class for backend modules. - -To create add-on backend modules subclass the Backend class in this module. -Doing so requires that the required backend interface is implemented. -""" - -from abc import ABC, abstractmethod -import warnings - -from qiskit.version import VERSION as __version__ -from .models import BackendStatus - - -class BaseBackend(ABC): - """Legacy Base class for backends.""" - - @abstractmethod - def __init__(self, configuration, provider=None): - """DEPRECATED Legacy base class for backends. - - This method should initialize the module and its configuration, and - raise an exception if a component of the module is - not available. - - Args: - configuration (BackendConfiguration): backend configuration - provider (BaseProvider): provider responsible for this backend - - Raises: - QiskitError: if an error occurred when instantiating the backend. - """ - warnings.warn( - "The BaseBackend abstract interface is deprecated as of " - "the 0.18.0 release and will be removed in a future " - "release. Instead you should build your backends using " - "the BackendV1 abstract class (which is the current " - "latest version of the backend interface)", - DeprecationWarning, - stacklevel=2, - ) - self._configuration = configuration - self._provider = provider - - @abstractmethod - def run(self, qobj): - """Run a Qobj on the the backend. - - Args: - qobj (Qobj): the Qobj to be executed. - """ - pass - - def configuration(self): - """Return the backend configuration. - - Returns: - BackendConfiguration: the configuration for the backend. - """ - return self._configuration - - def properties(self): - """Return the backend properties. - - Returns: - BackendProperties: the configuration for the backend. If the backend - does not support properties, it returns ``None``. - """ - return None - - def provider(self): - """Return the backend Provider. - - Returns: - BaseProvider: the Provider responsible for the backend. - """ - return self._provider - - def status(self): - """Return the backend status. - - Returns: - BackendStatus: the status of the backend. - """ - return BackendStatus( - backend_name=self.name(), - backend_version=__version__, - operational=True, - pending_jobs=0, - status_msg="", - ) - - def name(self): - """Return the backend name. - - Returns: - str: the name of the backend. - """ - return self._configuration.backend_name - - def version(self): - """Return the backend version. - - Returns: - str: the X.X.X version of the backend. - """ - return self._configuration.backend_version - - def __str__(self): - return self.name() - - def __repr__(self): - """Official string representation of a Backend. - - Note that, by Qiskit convention, it is consciously *not* a fully valid - Python expression. Subclasses should provide 'a string of the form - <...some useful description...>'. [0] - - [0] https://docs.python.org/3/reference/datamodel.html#object.__repr__ - """ - return f"<{self.__class__.__name__}('{self.name()}') from {self._provider}()>" diff --git a/qiskit/providers/basejob.py b/qiskit/providers/basejob.py deleted file mode 100644 index e2fe89e5db66..000000000000 --- a/qiskit/providers/basejob.py +++ /dev/null @@ -1,127 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""This module implements the legacy abstract base class for backend jobs. - -When creating a new backend module it is also necessary to implement this -job interface. -""" - -from abc import ABC, abstractmethod -from typing import Callable, Optional -import time -import warnings - -from .jobstatus import JobStatus, JOB_FINAL_STATES -from .exceptions import JobTimeoutError -from .basebackend import BaseBackend - - -class BaseJob(ABC): - """DEPRECATED Legacy Class to handle asynchronous jobs""" - - def __init__(self, backend: BaseBackend, job_id: str) -> None: - """Initializes the asynchronous job. - - Args: - backend: the backend used to run the job. - job_id: a unique id in the context of the backend used to run - the job. - """ - warnings.warn( - "The BaseJob abstract interface is deprecated as of " - "the 0.18.0 release and will be removed in a future " - "release. Instead you should build your backends using " - "the JobV1 abstract class (which is the current " - "latest version of the backend interface)", - DeprecationWarning, - stacklevel=2, - ) - self._job_id = job_id - self._backend = backend - - def job_id(self) -> str: - """Return a unique id identifying the job.""" - return self._job_id - - def backend(self) -> BaseBackend: - """Return the backend where this job was executed.""" - return self._backend - - def done(self) -> bool: - """Return whether the job has successfully run.""" - return self.status() == JobStatus.DONE - - def running(self) -> bool: - """Return whether the job is actively running.""" - return self.status() == JobStatus.RUNNING - - def cancelled(self) -> bool: - """Return whether the job has been cancelled.""" - return self.status() == JobStatus.CANCELLED - - def in_final_state(self) -> bool: - """Return whether the job is in a final job state.""" - return self.status() in JOB_FINAL_STATES - - def wait_for_final_state( - self, timeout: Optional[float] = None, wait: float = 5, callback: Optional[Callable] = None - ) -> None: - """Poll the job status until it progresses to a final state such as ``DONE`` or ``ERROR``. - - Args: - timeout: Seconds to wait for the job. If ``None``, wait indefinitely. - wait: Seconds between queries. - callback: Callback function invoked after each query. - The following positional arguments are provided to the callback function: - - * job_id: Job ID - * job_status: Status of the job from the last query - * job: This BaseJob instance - - Note: different subclass might provide different arguments to - the callback function. - - Raises: - JobTimeoutError: If the job does not reach a final state before the - specified timeout. - """ - start_time = time.time() - status = self.status() - while status not in JOB_FINAL_STATES: - elapsed_time = time.time() - start_time - if timeout is not None and elapsed_time >= timeout: - raise JobTimeoutError(f"Timeout while waiting for job {self.job_id()}.") - if callback: - callback(self.job_id(), status, self) - time.sleep(wait) - status = self.status() - - @abstractmethod - def submit(self): - """Submit the job to the backend for execution.""" - pass - - @abstractmethod - def result(self): - """Return the results of the job.""" - pass - - @abstractmethod - def cancel(self): - """Attempt to cancel the job.""" - pass - - @abstractmethod - def status(self): - """Return the status of the job, among the values of ``JobStatus``.""" - pass diff --git a/qiskit/providers/baseprovider.py b/qiskit/providers/baseprovider.py deleted file mode 100644 index d4681dd2eec9..000000000000 --- a/qiskit/providers/baseprovider.py +++ /dev/null @@ -1,78 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Base class for a backend provider.""" - -from abc import ABC, abstractmethod -import warnings - -from .exceptions import QiskitBackendNotFoundError - - -class BaseProvider(ABC): - """Base class for a Backend Provider.""" - - def __init__(self, *args, **kwargs): # pylint: disable=unused-argument - warnings.warn( - "The BaseProvider abstract interface is deprecated as of " - "the 0.18.0 release and will be removed in a future " - "release. Instead you should build your backends using " - "the ProviderV1 abstract class (which is the current " - "latest version of the provider interface).", - DeprecationWarning, - stacklevel=2, - ) - pass - - def get_backend(self, name=None, **kwargs): - """Return a single backend matching the specified filtering. - - Args: - name (str): name of the backend. - **kwargs: dict used for filtering. - - Returns: - BaseBackend: a backend matching the filtering. - - Raises: - QiskitBackendNotFoundError: if no backend could be found or - more than one backend matches the filtering criteria. - """ - backends = self.backends(name, **kwargs) - if len(backends) > 1: - raise QiskitBackendNotFoundError("More than one backend matches the criteria") - if not backends: - raise QiskitBackendNotFoundError("No backend matches the criteria") - - return backends[0] - - @abstractmethod - def backends(self, name=None, **kwargs): - """Return a list of backends matching the specified filtering. - - Args: - name (str): name of the backend. - **kwargs: dict used for filtering. - - Returns: - list[BaseBackend]: a list of Backends that match the filtering - criteria. - """ - pass - - def __eq__(self, other): - """Equality comparison. - - By default, it is assumed that two `Providers` from the same class are - equal. Subclassed providers can override this behavior. - """ - return type(self).__name__ == type(other).__name__ diff --git a/qiskit/providers/basicaer/basicaerprovider.py b/qiskit/providers/basicaer/basicaerprovider.py index 604e6cf66174..c8d8b5191322 100644 --- a/qiskit/providers/basicaer/basicaerprovider.py +++ b/qiskit/providers/basicaer/basicaerprovider.py @@ -95,7 +95,7 @@ def _verify_backends(self): of an optional dependency or on the existence of a binary). Returns: - dict[str:BaseBackend]: a dict of Basic Aer backend instances for + dict[str:Backend]: a dict of Basic Aer backend instances for the backends that could be instantiated, keyed by backend name. """ ret = OrderedDict() @@ -112,7 +112,7 @@ def _get_backend_instance(self, backend_cls): Args: backend_cls (class): backend class. Returns: - BaseBackend: a backend instance. + Backend: a backend instance. Raises: QiskitError: if the backend could not be instantiated. """ diff --git a/qiskit/providers/fake_provider/__init__.py b/qiskit/providers/fake_provider/__init__.py index 0d06cfcb161b..c30be21a08fe 100644 --- a/qiskit/providers/fake_provider/__init__.py +++ b/qiskit/providers/fake_provider/__init__.py @@ -23,16 +23,15 @@ from qiskit.test.mock.fake_provider import ( FakeProviderForBackendV2, FakeProvider, - FakeLegacyProvider, ) from qiskit.test.mock.fake_provider import FakeProviderFactory -from qiskit.test.mock.fake_backend import FakeBackend, FakeLegacyBackend -from qiskit.test.mock.fake_pulse_backend import FakePulseBackend, FakePulseLegacyBackend -from qiskit.test.mock.fake_qasm_backend import FakeQasmBackend, FakeQasmLegacyBackend +from qiskit.test.mock.fake_backend import FakeBackend +from qiskit.test.mock.fake_pulse_backend import FakePulseBackend +from qiskit.test.mock.fake_qasm_backend import FakeQasmBackend from qiskit.test.mock.utils.configurable_backend import ConfigurableFakeBackend from qiskit.test.mock.fake_backend_v2 import FakeBackendV2, FakeBackend5QV2 from qiskit.test.mock.fake_mumbai_v2 import FakeMumbaiFractionalCX -from qiskit.test.mock.fake_job import FakeJob, FakeLegacyJob +from qiskit.test.mock.fake_job import FakeJob from qiskit.test.mock.fake_qobj import FakeQobj from qiskit.test.mock.backends import * diff --git a/qiskit/providers/providerutils.py b/qiskit/providers/providerutils.py index e0e3a101ddb3..edd83c6dbe24 100644 --- a/qiskit/providers/providerutils.py +++ b/qiskit/providers/providerutils.py @@ -26,12 +26,12 @@ def filter_backends(backends, filters=None, **kwargs): backends must fulfill all specified conditions. Args: - backends (list[BaseBackend]): list of backends. + backends (list[Backend]): list of backends. filters (callable): filtering conditions as a callable. **kwargs: dict of criteria. Returns: - list[BaseBackend]: a list of backend instances matching the + list[Backend]: a list of backend instances matching the conditions. """ @@ -73,7 +73,7 @@ def resolve_backend_name(name, backends, deprecated, aliased): Args: name (str): name of backend to resolve - backends (list[BaseBackend]): list of available backends. + backends (list[Backend]): list of available backends. deprecated (dict[str: str]): dict of deprecated names. aliased (dict[str: list[str]]): dict of aliased names. diff --git a/qiskit/pulse/builder.py b/qiskit/pulse/builder.py index 56896e92a4ff..85ca476153b0 100644 --- a/qiskit/pulse/builder.py +++ b/qiskit/pulse/builder.py @@ -77,7 +77,7 @@ to worry about the raw experimental physics of pulse programming and not constructing cumbersome data structures. -We can optionally pass a :class:`~qiskit.providers.BaseBackend` to +We can optionally pass a :class:`~qiskit.providers.Backend` to :func:`build` to enable enhanced functionality. Below, we prepare a Bell state by automatically compiling the required pulses from their gate-level representations, while simultaneously applying a long decoupling pulse to a @@ -543,7 +543,7 @@ def __init__( duplication. Args: - backend (Union[Backend, BaseBackend]): Input backend to use in + backend (Backend): Input backend to use in builder. If not set certain functionality will be unavailable. block: Initital ``ScheduleBlock`` to build on. name: Name of pulse program to be built. @@ -557,7 +557,7 @@ def __init__( Raises: PulseError: When invalid ``default_alignment`` or `block` is specified. """ - #: BaseBackend: Backend instance for context builder. + #: Backend: Backend instance for context builder. self._backend = backend #: Union[None, ContextVar]: Token for this ``_PulseBuilder``'s ``ContextVar``. @@ -627,7 +627,7 @@ def backend(self): """Returns the builder backend if set. Returns: - Optional[Union[Backend, BaseBackend]]: The builder's backend. + Optional[Backend]: The builder's backend. """ return self._backend @@ -879,7 +879,7 @@ def build( qiskit.execute(pulse_prog, backend) Args: - backend (Union[Backend, BaseBackend]): A Qiskit backend. If not supplied certain + backend (Backend): A Qiskit backend. If not supplied certain builder functionality will be unavailable. schedule: A pulse ``ScheduleBlock`` in which your pulse program will be built. name: Name of pulse program to be built. @@ -929,7 +929,7 @@ def active_backend(): """Get the backend of the currently active builder context. Returns: - Union[Backend, BaseBackend]: The active backend in the currently active + Backend: The active backend in the currently active builder context. Raises: diff --git a/qiskit/test/mock/__init__.py b/qiskit/test/mock/__init__.py index 621aef085871..4c9ce4a0603d 100644 --- a/qiskit/test/mock/__init__.py +++ b/qiskit/test/mock/__init__.py @@ -20,12 +20,12 @@ The mock devices are mainly for testing the compiler. """ -from .fake_provider import FakeProviderForBackendV2, FakeProvider, FakeLegacyProvider +from .fake_provider import FakeProviderForBackendV2, FakeProvider from .fake_provider import FakeProviderFactory -from .fake_backend import FakeBackend, FakeLegacyBackend +from .fake_backend import FakeBackend from .fake_backend_v2 import FakeBackendV2, FakeBackend5QV2 from .fake_mumbai_v2 import FakeMumbaiFractionalCX -from .fake_job import FakeJob, FakeLegacyJob +from .fake_job import FakeJob from .fake_qobj import FakeQobj from .backends import * diff --git a/qiskit/test/mock/backends/__init__.py b/qiskit/test/mock/backends/__init__.py index 36fc787dd80f..2b85aac04439 100644 --- a/qiskit/test/mock/backends/__init__.py +++ b/qiskit/test/mock/backends/__init__.py @@ -102,39 +102,3 @@ from .vigo import FakeVigo from .washington import FakeWashington from .yorktown import FakeYorktown - -# Legacy Backends -from .almaden import FakeLegacyAlmaden -from .armonk import FakeLegacyArmonk -from .athens import FakeLegacyAthens -from .belem import FakeLegacyBelem -from .boeblingen import FakeLegacyBoeblingen -from .bogota import FakeLegacyBogota -from .burlington import FakeLegacyBurlington -from .cambridge import FakeLegacyCambridge -from .cambridge import FakeLegacyCambridgeAlternativeBasis -from .casablanca import FakeLegacyCasablanca -from .essex import FakeLegacyEssex -from .johannesburg import FakeLegacyJohannesburg -from .lima import FakeLegacyLima -from .london import FakeLegacyLondon -from .manhattan import FakeLegacyManhattan -from .melbourne import FakeLegacyMelbourne -from .montreal import FakeLegacyMontreal -from .mumbai import FakeLegacyMumbai -from .ourense import FakeLegacyOurense -from .paris import FakeLegacyParis -from .poughkeepsie import FakeLegacyPoughkeepsie -from .quito import FakeLegacyQuito -from .rochester import FakeLegacyRochester -from .rome import FakeLegacyRome -from .rueschlikon import FakeLegacyRueschlikon -from .santiago import FakeLegacySantiago -from .singapore import FakeLegacySingapore -from .sydney import FakeLegacySydney -from .tenerife import FakeLegacyTenerife -from .tokyo import FakeLegacyTokyo -from .toronto import FakeLegacyToronto -from .valencia import FakeLegacyValencia -from .vigo import FakeLegacyVigo -from .yorktown import FakeLegacyYorktown diff --git a/qiskit/test/mock/backends/almaden/__init__.py b/qiskit/test/mock/backends/almaden/__init__.py index 2dd9d10bbee4..9f0e03a7b79e 100644 --- a/qiskit/test/mock/backends/almaden/__init__.py +++ b/qiskit/test/mock/backends/almaden/__init__.py @@ -14,4 +14,3 @@ from .fake_almaden import FakeAlmadenV2 from .fake_almaden import FakeAlmaden -from .fake_almaden import FakeLegacyAlmaden diff --git a/qiskit/test/mock/backends/almaden/fake_almaden.py b/qiskit/test/mock/backends/almaden/fake_almaden.py index 5e64fe9dca3d..28d6fafd8934 100644 --- a/qiskit/test/mock/backends/almaden/fake_almaden.py +++ b/qiskit/test/mock/backends/almaden/fake_almaden.py @@ -54,22 +54,3 @@ class FakeAlmaden(fake_pulse_backend.FakePulseBackend): props_filename = "props_almaden.json" defs_filename = "defs_almaden.json" backend_name = "fake_almaden" - - -class FakeLegacyAlmaden(fake_pulse_backend.FakePulseLegacyBackend): - """A fake Almaden backend. - - 00 ↔ 01 ↔ 02 ↔ 03 ↔ 04 - ↕ ↕ - 05 ↔ 06 ↔ 07 ↔ 08 ↔ 09 - ↕ ↕ ↕ - 10 ↔ 11 ↔ 12 ↔ 13 ↔ 14 - ↕ ↕ - 15 ↔ 16 ↔ 17 ↔ 18 ↔ 19 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_almaden.json" - props_filename = "props_almaden.json" - defs_filename = "defs_almaden.json" - backend_name = "fake_almaden" diff --git a/qiskit/test/mock/backends/armonk/__init__.py b/qiskit/test/mock/backends/armonk/__init__.py index 04602d985a25..1a9453bcb450 100644 --- a/qiskit/test/mock/backends/armonk/__init__.py +++ b/qiskit/test/mock/backends/armonk/__init__.py @@ -14,4 +14,3 @@ from .fake_armonk import FakeArmonkV2 from .fake_armonk import FakeArmonk -from .fake_armonk import FakeLegacyArmonk diff --git a/qiskit/test/mock/backends/armonk/fake_armonk.py b/qiskit/test/mock/backends/armonk/fake_armonk.py index 8c9e16b5e17d..43e605cfdf3b 100644 --- a/qiskit/test/mock/backends/armonk/fake_armonk.py +++ b/qiskit/test/mock/backends/armonk/fake_armonk.py @@ -42,16 +42,3 @@ class FakeArmonk(fake_pulse_backend.FakePulseBackend): props_filename = "props_armonk.json" defs_filename = "defs_armonk.json" backend_name = "fake_armonk" - - -class FakeLegacyArmonk(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 1 qubit backend. - - 0 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_armonk.json" - props_filename = "props_armonk.json" - defs_filename = "defs_armonk.json" - backend_name = "fake_armonk" diff --git a/qiskit/test/mock/backends/athens/__init__.py b/qiskit/test/mock/backends/athens/__init__.py index 4f1442274e85..3a7c0c18f718 100644 --- a/qiskit/test/mock/backends/athens/__init__.py +++ b/qiskit/test/mock/backends/athens/__init__.py @@ -14,4 +14,3 @@ from .fake_athens import FakeAthensV2 from .fake_athens import FakeAthens -from .fake_athens import FakeLegacyAthens diff --git a/qiskit/test/mock/backends/athens/fake_athens.py b/qiskit/test/mock/backends/athens/fake_athens.py index b56983a8751d..e10625c460d3 100644 --- a/qiskit/test/mock/backends/athens/fake_athens.py +++ b/qiskit/test/mock/backends/athens/fake_athens.py @@ -36,13 +36,3 @@ class FakeAthens(fake_pulse_backend.FakePulseBackend): props_filename = "props_athens.json" defs_filename = "defs_athens.json" backend_name = "fake_athens" - - -class FakeLegacyAthens(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 5 qubit backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_athens.json" - props_filename = "props_athens.json" - defs_filename = "defs_athens.json" - backend_name = "fake_athens" diff --git a/qiskit/test/mock/backends/belem/__init__.py b/qiskit/test/mock/backends/belem/__init__.py index 842164136550..d60733f78686 100644 --- a/qiskit/test/mock/backends/belem/__init__.py +++ b/qiskit/test/mock/backends/belem/__init__.py @@ -14,4 +14,3 @@ from .fake_belem import FakeBelemV2 from .fake_belem import FakeBelem -from .fake_belem import FakeLegacyBelem diff --git a/qiskit/test/mock/backends/belem/fake_belem.py b/qiskit/test/mock/backends/belem/fake_belem.py index af4db3e4239d..15f0ef878b2c 100644 --- a/qiskit/test/mock/backends/belem/fake_belem.py +++ b/qiskit/test/mock/backends/belem/fake_belem.py @@ -36,13 +36,3 @@ class FakeBelem(fake_pulse_backend.FakePulseBackend): props_filename = "props_belem.json" defs_filename = "defs_belem.json" backend_name = "fake_belem" - - -class FakeLegacyBelem(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 5 qubit backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_belem.json" - props_filename = "props_belem.json" - defs_filename = "defs_belem.json" - backend_name = "fake_belem" diff --git a/qiskit/test/mock/backends/boeblingen/__init__.py b/qiskit/test/mock/backends/boeblingen/__init__.py index f0f9565d1305..79d0e6d1feb7 100644 --- a/qiskit/test/mock/backends/boeblingen/__init__.py +++ b/qiskit/test/mock/backends/boeblingen/__init__.py @@ -14,4 +14,3 @@ from .fake_boeblingen import FakeBoeblingenV2 from .fake_boeblingen import FakeBoeblingen -from .fake_boeblingen import FakeLegacyBoeblingen diff --git a/qiskit/test/mock/backends/boeblingen/fake_boeblingen.py b/qiskit/test/mock/backends/boeblingen/fake_boeblingen.py index 8b44fa38ff22..939b70b626c9 100644 --- a/qiskit/test/mock/backends/boeblingen/fake_boeblingen.py +++ b/qiskit/test/mock/backends/boeblingen/fake_boeblingen.py @@ -54,22 +54,3 @@ class FakeBoeblingen(fake_pulse_backend.FakePulseBackend): props_filename = "props_boeblingen.json" defs_filename = "defs_boeblingen.json" backend_name = "fake_boeblingen" - - -class FakeLegacyBoeblingen(fake_pulse_backend.FakePulseLegacyBackend): - """A fake Boeblingen backend. - - 00 ↔ 01 ↔ 02 ↔ 03 ↔ 04 - ↕ ↕ - 05 ↔ 06 ↔ 07 ↔ 08 ↔ 09 - ↕ ↕ ↕ - 10 ↔ 11 ↔ 12 ↔ 13 ↔ 14 - ↕ ↕ - 15 ↔ 16 ↔ 17 ↔ 18 ↔ 19 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_boeblingen.json" - props_filename = "props_boeblingen.json" - defs_filename = "defs_boeblingen.json" - backend_name = "fake_boeblingen" diff --git a/qiskit/test/mock/backends/bogota/__init__.py b/qiskit/test/mock/backends/bogota/__init__.py index c1cf6ce65022..eff8cf957c39 100644 --- a/qiskit/test/mock/backends/bogota/__init__.py +++ b/qiskit/test/mock/backends/bogota/__init__.py @@ -14,4 +14,3 @@ from .fake_bogota import FakeBogotaV2 from .fake_bogota import FakeBogota -from .fake_bogota import FakeLegacyBogota diff --git a/qiskit/test/mock/backends/bogota/fake_bogota.py b/qiskit/test/mock/backends/bogota/fake_bogota.py index 4c1e4fa6f4b1..c91920b50775 100644 --- a/qiskit/test/mock/backends/bogota/fake_bogota.py +++ b/qiskit/test/mock/backends/bogota/fake_bogota.py @@ -36,13 +36,3 @@ class FakeBogota(fake_pulse_backend.FakePulseBackend): props_filename = "props_bogota.json" defs_filename = "defs_bogota.json" backend_name = "fake_bogota" - - -class FakeLegacyBogota(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 5 qubit backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_bogota.json" - props_filename = "props_bogota.json" - defs_filename = "defs_bogota.json" - backend_name = "fake_bogota" diff --git a/qiskit/test/mock/backends/burlington/__init__.py b/qiskit/test/mock/backends/burlington/__init__.py index 6a1f0b0fb409..b6d11e698499 100644 --- a/qiskit/test/mock/backends/burlington/__init__.py +++ b/qiskit/test/mock/backends/burlington/__init__.py @@ -14,4 +14,3 @@ from .fake_burlington import FakeBurlingtonV2 from .fake_burlington import FakeBurlington -from .fake_burlington import FakeLegacyBurlington diff --git a/qiskit/test/mock/backends/burlington/fake_burlington.py b/qiskit/test/mock/backends/burlington/fake_burlington.py index ece8ce3079f9..b81d360a761d 100644 --- a/qiskit/test/mock/backends/burlington/fake_burlington.py +++ b/qiskit/test/mock/backends/burlington/fake_burlington.py @@ -44,17 +44,3 @@ class FakeBurlington(fake_qasm_backend.FakeQasmBackend): conf_filename = "conf_burlington.json" props_filename = "props_burlington.json" backend_name = "fake_burlington" - - -class FakeLegacyBurlington(fake_qasm_backend.FakeQasmLegacyBackend): - """A fake 5 qubit backend. - - 0 ↔ 1 ↔ 3 ↔ 4 - ↕ - 2 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_burlington.json" - props_filename = "props_burlington.json" - backend_name = "fake_burlington" diff --git a/qiskit/test/mock/backends/cambridge/__init__.py b/qiskit/test/mock/backends/cambridge/__init__.py index 26cab4e61cc3..b65dd250f1c9 100644 --- a/qiskit/test/mock/backends/cambridge/__init__.py +++ b/qiskit/test/mock/backends/cambridge/__init__.py @@ -15,5 +15,3 @@ from .fake_cambridge import FakeCambridgeV2 from .fake_cambridge import FakeCambridge from .fake_cambridge import FakeCambridgeAlternativeBasis -from .fake_cambridge import FakeLegacyCambridge -from .fake_cambridge import FakeLegacyCambridgeAlternativeBasis diff --git a/qiskit/test/mock/backends/cambridge/fake_cambridge.py b/qiskit/test/mock/backends/cambridge/fake_cambridge.py index 2eb89be093f9..01a9cd288f69 100644 --- a/qiskit/test/mock/backends/cambridge/fake_cambridge.py +++ b/qiskit/test/mock/backends/cambridge/fake_cambridge.py @@ -66,33 +66,3 @@ class FakeCambridgeAlternativeBasis(FakeCambridge): def __init__(self): super().__init__() self._configuration.basis_gates = ["u", "sx", "p", "cx", "id"] - - -class FakeLegacyCambridge(fake_qasm_backend.FakeQasmLegacyBackend): - """A fake Cambridge backend. - - 00 ↔ 01 ↔ 02 ↔ 03 ↔ 04 - ↕ ↕ - 05 06 - ↕ ↕ - 07 ↔ 08 ↔ 09 ↔ 10 ↔ 11 ↔ 12 ↔ 13 ↔ 14 ↔ 15 - ↕ ↕ ↕ - 16 17 18 - ↕ ↕ ↕ - 19 ↔ 20 ↔ 21 ↔ 22 ↔ 23 ↔ 24 ↔ 25 ↔ 26 ↔ 27 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_cambridge.json" - props_filename = "props_cambridge.json" - backend_name = "fake_cambridge" - - -class FakeLegacyCambridgeAlternativeBasis(FakeLegacyCambridge): - """A fake Cambridge backend with alternate 1q basis gates.""" - - props_filename = "props_cambridge_alt.json" - - def __init__(self): - super().__init__() - self._configuration.basis_gates = ["u", "sx", "p", "cx", "id"] diff --git a/qiskit/test/mock/backends/casablanca/__init__.py b/qiskit/test/mock/backends/casablanca/__init__.py index 02403355be29..acf7033490f4 100644 --- a/qiskit/test/mock/backends/casablanca/__init__.py +++ b/qiskit/test/mock/backends/casablanca/__init__.py @@ -14,4 +14,3 @@ from .fake_casablanca import FakeCasablancaV2 from .fake_casablanca import FakeCasablanca -from .fake_casablanca import FakeLegacyCasablanca diff --git a/qiskit/test/mock/backends/casablanca/fake_casablanca.py b/qiskit/test/mock/backends/casablanca/fake_casablanca.py index 62f1008ed530..423108f206cc 100644 --- a/qiskit/test/mock/backends/casablanca/fake_casablanca.py +++ b/qiskit/test/mock/backends/casablanca/fake_casablanca.py @@ -36,13 +36,3 @@ class FakeCasablanca(fake_pulse_backend.FakePulseBackend): props_filename = "props_casablanca.json" defs_filename = "defs_casablanca.json" backend_name = "fake_casablanca" - - -class FakeLegacyCasablanca(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 7 qubit backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_casablanca.json" - props_filename = "props_casablanca.json" - defs_filename = "defs_casablanca.json" - backend_name = "fake_casablanca" diff --git a/qiskit/test/mock/backends/essex/__init__.py b/qiskit/test/mock/backends/essex/__init__.py index 57c13692bfb0..ed23aa4b0359 100644 --- a/qiskit/test/mock/backends/essex/__init__.py +++ b/qiskit/test/mock/backends/essex/__init__.py @@ -14,4 +14,3 @@ from .fake_essex import FakeEssexV2 from .fake_essex import FakeEssex -from .fake_essex import FakeLegacyEssex diff --git a/qiskit/test/mock/backends/essex/fake_essex.py b/qiskit/test/mock/backends/essex/fake_essex.py index b075bdf48a29..ca62c1f7d9b7 100644 --- a/qiskit/test/mock/backends/essex/fake_essex.py +++ b/qiskit/test/mock/backends/essex/fake_essex.py @@ -48,19 +48,3 @@ class FakeEssex(fake_qasm_backend.FakeQasmBackend): conf_filename = "conf_essex.json" props_filename = "props_essex.json" backend_name = "fake_essex" - - -class FakeLegacyEssex(fake_qasm_backend.FakeQasmLegacyBackend): - """A fake 5 qubit backend. - - 0 ↔ 1 ↔ 2 - ↕ - 3 - ↕ - 4 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_essex.json" - props_filename = "props_essex.json" - backend_name = "fake_essex" diff --git a/qiskit/test/mock/backends/johannesburg/__init__.py b/qiskit/test/mock/backends/johannesburg/__init__.py index e270f1c4f73d..5a7e95e60bd6 100644 --- a/qiskit/test/mock/backends/johannesburg/__init__.py +++ b/qiskit/test/mock/backends/johannesburg/__init__.py @@ -14,4 +14,3 @@ from .fake_johannesburg import FakeJohannesburgV2 from .fake_johannesburg import FakeJohannesburg -from .fake_johannesburg import FakeLegacyJohannesburg diff --git a/qiskit/test/mock/backends/johannesburg/fake_johannesburg.py b/qiskit/test/mock/backends/johannesburg/fake_johannesburg.py index 713bca2128f4..31e81cd96dfe 100644 --- a/qiskit/test/mock/backends/johannesburg/fake_johannesburg.py +++ b/qiskit/test/mock/backends/johannesburg/fake_johannesburg.py @@ -54,22 +54,3 @@ class FakeJohannesburg(fake_pulse_backend.FakePulseBackend): props_filename = "props_johannesburg.json" defs_filename = "defs_johannesburg.json" backend_name = "fake_johannesburg" - - -class FakeLegacyJohannesburg(fake_pulse_backend.FakePulseLegacyBackend): - """A fake Johannesburg backend. - - 00 ↔ 01 ↔ 02 ↔ 03 ↔ 04 - ↕ ↕ - 05 ↔ 06 ↔ 07 ↔ 08 ↔ 09 - ↕ ↕ ↕ - 10 ↔ 11 ↔ 12 ↔ 13 ↔ 14 - ↕ ↕ - 15 ↔ 16 ↔ 17 ↔ 18 ↔ 19 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_johannesburg.json" - props_filename = "props_johannesburg.json" - defs_filename = "defs_johannesburg.json" - backend_name = "fake_johannesburg" diff --git a/qiskit/test/mock/backends/lima/__init__.py b/qiskit/test/mock/backends/lima/__init__.py index 056166622b92..ce24c99c763a 100644 --- a/qiskit/test/mock/backends/lima/__init__.py +++ b/qiskit/test/mock/backends/lima/__init__.py @@ -14,4 +14,3 @@ from .fake_lima import FakeLimaV2 from .fake_lima import FakeLima -from .fake_lima import FakeLegacyLima diff --git a/qiskit/test/mock/backends/lima/fake_lima.py b/qiskit/test/mock/backends/lima/fake_lima.py index c621aead7c35..8b7022ec97db 100644 --- a/qiskit/test/mock/backends/lima/fake_lima.py +++ b/qiskit/test/mock/backends/lima/fake_lima.py @@ -36,13 +36,3 @@ class FakeLima(fake_pulse_backend.FakePulseBackend): props_filename = "props_lima.json" defs_filename = "defs_lima.json" backend_name = "fake_lima" - - -class FakeLegacyLima(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 5 qubit backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_lima.json" - props_filename = "props_lima.json" - defs_filename = "defs_lima.json" - backend_name = "fake_lima" diff --git a/qiskit/test/mock/backends/london/__init__.py b/qiskit/test/mock/backends/london/__init__.py index 3ffc48c1454b..058905944966 100644 --- a/qiskit/test/mock/backends/london/__init__.py +++ b/qiskit/test/mock/backends/london/__init__.py @@ -14,4 +14,3 @@ from .fake_london import FakeLondonV2 from .fake_london import FakeLondon -from .fake_london import FakeLegacyLondon diff --git a/qiskit/test/mock/backends/london/fake_london.py b/qiskit/test/mock/backends/london/fake_london.py index 76e865277ac7..6eaf1b9b2e48 100644 --- a/qiskit/test/mock/backends/london/fake_london.py +++ b/qiskit/test/mock/backends/london/fake_london.py @@ -48,19 +48,3 @@ class FakeLondon(fake_qasm_backend.FakeQasmBackend): conf_filename = "conf_london.json" props_filename = "props_london.json" backend_name = "fake_london" - - -class FakeLegacyLondon(fake_qasm_backend.FakeQasmLegacyBackend): - """A fake 5 qubit backend. - - 0 ↔ 1 ↔ 2 - ↕ - 3 - ↕ - 4 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_london.json" - props_filename = "props_london.json" - backend_name = "fake_london" diff --git a/qiskit/test/mock/backends/manhattan/__init__.py b/qiskit/test/mock/backends/manhattan/__init__.py index ee35f3809537..3adf4fcbe625 100644 --- a/qiskit/test/mock/backends/manhattan/__init__.py +++ b/qiskit/test/mock/backends/manhattan/__init__.py @@ -14,4 +14,3 @@ from .fake_manhattan import FakeManhattanV2 from .fake_manhattan import FakeManhattan -from .fake_manhattan import FakeLegacyManhattan diff --git a/qiskit/test/mock/backends/manhattan/fake_manhattan.py b/qiskit/test/mock/backends/manhattan/fake_manhattan.py index 5699b5c4f3f3..4fcc4f2a79c7 100644 --- a/qiskit/test/mock/backends/manhattan/fake_manhattan.py +++ b/qiskit/test/mock/backends/manhattan/fake_manhattan.py @@ -36,13 +36,3 @@ class FakeManhattan(fake_pulse_backend.FakePulseBackend): props_filename = "props_manhattan.json" defs_filename = "defs_manhattan.json" backend_name = "fake_manhattan" - - -class FakeLegacyManhattan(fake_pulse_backend.FakePulseLegacyBackend): - """A fake Manhattan backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_manhattan.json" - props_filename = "props_manhattan.json" - defs_filename = "defs_manhattan.json" - backend_name = "fake_manhattan" diff --git a/qiskit/test/mock/backends/melbourne/__init__.py b/qiskit/test/mock/backends/melbourne/__init__.py index d3ce67f3fab8..05ecfdd82166 100644 --- a/qiskit/test/mock/backends/melbourne/__init__.py +++ b/qiskit/test/mock/backends/melbourne/__init__.py @@ -14,4 +14,3 @@ from .fake_melbourne import FakeMelbourneV2 from .fake_melbourne import FakeMelbourne -from .fake_melbourne import FakeLegacyMelbourne diff --git a/qiskit/test/mock/backends/melbourne/fake_melbourne.py b/qiskit/test/mock/backends/melbourne/fake_melbourne.py index 91919bdacd6c..4cd04674d0ec 100644 --- a/qiskit/test/mock/backends/melbourne/fake_melbourne.py +++ b/qiskit/test/mock/backends/melbourne/fake_melbourne.py @@ -18,7 +18,7 @@ import json from qiskit.providers.models import GateConfig, QasmBackendConfiguration, BackendProperties -from qiskit.test.mock.fake_backend import FakeBackend, FakeLegacyBackend +from qiskit.test.mock.fake_backend import FakeBackend from qiskit.test.mock import fake_backend @@ -86,60 +86,3 @@ def properties(self): with open(os.path.join(dirname, filename)) as f_prop: props = json.load(f_prop) return BackendProperties.from_dict(props) - - -class FakeLegacyMelbourne(FakeLegacyBackend): - """A fake 14 qubit backend.""" - - def __init__(self): - """ - 0 ← 1 → 2 → 3 ← 4 ← 5 → 6 - ↑ ↑ ↑ ↓ ↓ ↓ - 13 → 12 ← 11 → 10 ← 9 → 8 ← 7 - """ - cmap = [ - [1, 0], - [1, 2], - [2, 3], - [4, 3], - [4, 10], - [5, 4], - [5, 6], - [5, 9], - [6, 8], - [7, 8], - [9, 8], - [9, 10], - [11, 3], - [11, 10], - [11, 12], - [12, 2], - [13, 1], - [13, 12], - ] - - configuration = QasmBackendConfiguration( - backend_name="fake_melbourne", - backend_version="0.0.0", - n_qubits=14, - basis_gates=["u1", "u2", "u3", "cx", "id"], - simulator=False, - local=True, - conditional=False, - open_pulse=False, - memory=False, - max_shots=65536, - max_experiments=900, - gates=[GateConfig(name="TODO", parameters=[], qasm_def="TODO")], - coupling_map=cmap, - ) - - super().__init__(configuration) - - def properties(self): - """Returns a snapshot of device properties""" - dirname = os.path.dirname(__file__) - filename = "props_melbourne.json" - with open(os.path.join(dirname, filename)) as f_prop: - props = json.load(f_prop) - return BackendProperties.from_dict(props) diff --git a/qiskit/test/mock/backends/montreal/__init__.py b/qiskit/test/mock/backends/montreal/__init__.py index 8390468d928c..e4f42e6d5e00 100644 --- a/qiskit/test/mock/backends/montreal/__init__.py +++ b/qiskit/test/mock/backends/montreal/__init__.py @@ -14,4 +14,3 @@ from .fake_montreal import FakeMontrealV2 from .fake_montreal import FakeMontreal -from .fake_montreal import FakeLegacyMontreal diff --git a/qiskit/test/mock/backends/montreal/fake_montreal.py b/qiskit/test/mock/backends/montreal/fake_montreal.py index 8d24c2262a9a..552d7bc25367 100644 --- a/qiskit/test/mock/backends/montreal/fake_montreal.py +++ b/qiskit/test/mock/backends/montreal/fake_montreal.py @@ -36,13 +36,3 @@ class FakeMontreal(fake_pulse_backend.FakePulseBackend): props_filename = "props_montreal.json" defs_filename = "defs_montreal.json" backend_name = "fake_montreal" - - -class FakeLegacyMontreal(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 27 qubit backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_montreal.json" - props_filename = "props_montreal.json" - defs_filename = "defs_montreal.json" - backend_name = "fake_montreal" diff --git a/qiskit/test/mock/backends/mumbai/__init__.py b/qiskit/test/mock/backends/mumbai/__init__.py index cfa1d860ac5f..e6d7b6a17137 100644 --- a/qiskit/test/mock/backends/mumbai/__init__.py +++ b/qiskit/test/mock/backends/mumbai/__init__.py @@ -14,4 +14,3 @@ from .fake_mumbai import FakeMumbaiV2 from .fake_mumbai import FakeMumbai -from .fake_mumbai import FakeLegacyMumbai diff --git a/qiskit/test/mock/backends/mumbai/fake_mumbai.py b/qiskit/test/mock/backends/mumbai/fake_mumbai.py index 41e6f83db8d1..ee6de9fbc423 100644 --- a/qiskit/test/mock/backends/mumbai/fake_mumbai.py +++ b/qiskit/test/mock/backends/mumbai/fake_mumbai.py @@ -36,13 +36,3 @@ class FakeMumbai(fake_pulse_backend.FakePulseBackend): props_filename = "props_mumbai.json" defs_filename = "defs_mumbai.json" backend_name = "fake_mumbai" - - -class FakeLegacyMumbai(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 27 qubit backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_mumbai.json" - props_filename = "props_mumbai.json" - defs_filename = "defs_mumbai.json" - backend_name = "fake_mumbai" diff --git a/qiskit/test/mock/backends/ourense/__init__.py b/qiskit/test/mock/backends/ourense/__init__.py index 4e73b1bffa47..eb3374d09caa 100644 --- a/qiskit/test/mock/backends/ourense/__init__.py +++ b/qiskit/test/mock/backends/ourense/__init__.py @@ -14,4 +14,3 @@ from .fake_ourense import FakeOurenseV2 from .fake_ourense import FakeOurense -from .fake_ourense import FakeLegacyOurense diff --git a/qiskit/test/mock/backends/ourense/fake_ourense.py b/qiskit/test/mock/backends/ourense/fake_ourense.py index ae889ccb738b..7282d2fcaabe 100644 --- a/qiskit/test/mock/backends/ourense/fake_ourense.py +++ b/qiskit/test/mock/backends/ourense/fake_ourense.py @@ -44,17 +44,3 @@ class FakeOurense(fake_qasm_backend.FakeQasmBackend): conf_filename = "conf_ourense.json" props_filename = "props_ourense.json" backend_name = "fake_ourense" - - -class FakeLegacyOurense(fake_qasm_backend.FakeQasmLegacyBackend): - """A fake 5 qubit backend. - - 0 ↔ 1 ↔ 3 ↔ 4 - ↕ - 2 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_ourense.json" - props_filename = "props_ourense.json" - backend_name = "fake_ourense" diff --git a/qiskit/test/mock/backends/paris/__init__.py b/qiskit/test/mock/backends/paris/__init__.py index ed1354ade823..ec0d15fde1cb 100644 --- a/qiskit/test/mock/backends/paris/__init__.py +++ b/qiskit/test/mock/backends/paris/__init__.py @@ -14,4 +14,3 @@ from .fake_paris import FakeParisV2 from .fake_paris import FakeParis -from .fake_paris import FakeLegacyParis diff --git a/qiskit/test/mock/backends/paris/fake_paris.py b/qiskit/test/mock/backends/paris/fake_paris.py index 452b5ac6a0ba..e54b4442fc20 100644 --- a/qiskit/test/mock/backends/paris/fake_paris.py +++ b/qiskit/test/mock/backends/paris/fake_paris.py @@ -58,24 +58,3 @@ class FakeParis(fake_pulse_backend.FakePulseBackend): props_filename = "props_paris.json" defs_filename = "defs_paris.json" backend_name = "fake_paris" - - -class FakeLegacyParis(fake_pulse_backend.FakePulseLegacyBackend): - """A fake Paris backend. - - 06 17 - ↕ ↕ - 00 ↔ 01 ↔ 04 ↔ 07 ↔ 10 ↔ 12 ↔ 15 ↔ 18 ↔ 20 ↔ 23 - ↕ ↕ ↕ - 02 13 24 - ↕ ↕ ↕ - 03 ↔ 05 ↔ 08 ↔ 11 ↔ 14 ↔ 16 ↔ 19 ↔ 22 ↔ 25 ↔ 26 - ↕ ↕ - 09 20 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_paris.json" - props_filename = "props_paris.json" - defs_filename = "defs_paris.json" - backend_name = "fake_paris" diff --git a/qiskit/test/mock/backends/poughkeepsie/__init__.py b/qiskit/test/mock/backends/poughkeepsie/__init__.py index 2ca2c8bd853f..0bf5af896972 100644 --- a/qiskit/test/mock/backends/poughkeepsie/__init__.py +++ b/qiskit/test/mock/backends/poughkeepsie/__init__.py @@ -14,4 +14,3 @@ from .fake_poughkeepsie import FakePoughkeepsieV2 from .fake_poughkeepsie import FakePoughkeepsie -from .fake_poughkeepsie import FakeLegacyPoughkeepsie diff --git a/qiskit/test/mock/backends/poughkeepsie/fake_poughkeepsie.py b/qiskit/test/mock/backends/poughkeepsie/fake_poughkeepsie.py index 0cb1bf117f92..fa3ac0aae016 100644 --- a/qiskit/test/mock/backends/poughkeepsie/fake_poughkeepsie.py +++ b/qiskit/test/mock/backends/poughkeepsie/fake_poughkeepsie.py @@ -18,7 +18,7 @@ import json from qiskit.providers.models import GateConfig, QasmBackendConfiguration, BackendProperties -from qiskit.test.mock.fake_backend import FakeBackend, FakeLegacyBackend +from qiskit.test.mock.fake_backend import FakeBackend from qiskit.test.mock import fake_backend @@ -119,92 +119,3 @@ def properties(self): with open(os.path.join(dirname, filename)) as f_prop: props = json.load(f_prop) return BackendProperties.from_dict(props) - - -class FakeLegacyPoughkeepsie(FakeLegacyBackend): - """A fake Poughkeepsie backend.""" - - def __init__(self): - """ - 00 ↔ 01 ↔ 02 ↔ 03 ↔ 04 - ↕ ↕ - 05 ↔ 06 ↔ 07 ↔ 08 ↔ 09 - ↕ ↕ ↕ - 10 ↔ 11 ↔ 12 ↔ 13 ↔ 14 - ↕ ↕ - 15 ↔ 16 ↔ 17 ↔ 18 ↔ 19 - """ - cmap = [ - [0, 1], - [0, 5], - [1, 0], - [1, 2], - [2, 1], - [2, 3], - [3, 2], - [3, 4], - [4, 3], - [4, 9], - [5, 0], - [5, 6], - [5, 10], - [6, 5], - [6, 7], - [7, 6], - [7, 8], - [7, 12], - [8, 7], - [8, 9], - [9, 4], - [9, 8], - [9, 14], - [10, 5], - [10, 11], - [10, 15], - [11, 10], - [11, 12], - [12, 7], - [12, 11], - [12, 13], - [13, 12], - [13, 14], - [14, 9], - [14, 13], - [14, 19], - [15, 10], - [15, 16], - [16, 15], - [16, 17], - [17, 16], - [17, 18], - [18, 17], - [18, 19], - [19, 14], - [19, 18], - ] - - configuration = QasmBackendConfiguration( - backend_name="fake_poughkeepsie", - backend_version="0.0.0", - n_qubits=20, - basis_gates=["u1", "u2", "u3", "cx", "id"], - simulator=False, - local=True, - conditional=False, - open_pulse=False, - memory=True, - max_shots=8192, - max_experiments=900, - gates=[GateConfig(name="TODO", parameters=[], qasm_def="TODO")], - coupling_map=cmap, - ) - - super().__init__(configuration) - - def properties(self): - """Returns a snapshot of device properties""" - dirname = os.path.dirname(__file__) - filename = "props_poughkeepsie.json" - with open(os.path.join(dirname, filename)) as f_prop: - props = json.load(f_prop) - return BackendProperties.from_dict(props) diff --git a/qiskit/test/mock/backends/quito/__init__.py b/qiskit/test/mock/backends/quito/__init__.py index 566c991d0900..e6ac098d4213 100644 --- a/qiskit/test/mock/backends/quito/__init__.py +++ b/qiskit/test/mock/backends/quito/__init__.py @@ -14,4 +14,3 @@ from .fake_quito import FakeQuitoV2 from .fake_quito import FakeQuito -from .fake_quito import FakeLegacyQuito diff --git a/qiskit/test/mock/backends/quito/fake_quito.py b/qiskit/test/mock/backends/quito/fake_quito.py index af51260c6c8c..376b824c305b 100644 --- a/qiskit/test/mock/backends/quito/fake_quito.py +++ b/qiskit/test/mock/backends/quito/fake_quito.py @@ -36,13 +36,3 @@ class FakeQuito(fake_pulse_backend.FakePulseBackend): props_filename = "props_quito.json" defs_filename = "defs_quito.json" backend_name = "fake_quito" - - -class FakeLegacyQuito(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 5 qubit backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_quito.json" - props_filename = "props_quito.json" - defs_filename = "defs_quito.json" - backend_name = "fake_quito" diff --git a/qiskit/test/mock/backends/rochester/__init__.py b/qiskit/test/mock/backends/rochester/__init__.py index ad89890bc715..3ccc911f354d 100644 --- a/qiskit/test/mock/backends/rochester/__init__.py +++ b/qiskit/test/mock/backends/rochester/__init__.py @@ -14,4 +14,3 @@ from .fake_rochester import FakeRochesterV2 from .fake_rochester import FakeRochester -from .fake_rochester import FakeLegacyRochester diff --git a/qiskit/test/mock/backends/rochester/fake_rochester.py b/qiskit/test/mock/backends/rochester/fake_rochester.py index 28e4169aeddb..62e177e3c703 100644 --- a/qiskit/test/mock/backends/rochester/fake_rochester.py +++ b/qiskit/test/mock/backends/rochester/fake_rochester.py @@ -34,12 +34,3 @@ class FakeRochester(fake_qasm_backend.FakeQasmBackend): conf_filename = "conf_rochester.json" props_filename = "props_rochester.json" backend_name = "fake_rochester" - - -class FakeLegacyRochester(fake_qasm_backend.FakeQasmLegacyBackend): - """A fake Rochester backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_rochester.json" - props_filename = "props_rochester.json" - backend_name = "fake_rochester" diff --git a/qiskit/test/mock/backends/rome/__init__.py b/qiskit/test/mock/backends/rome/__init__.py index e0f2f3c76488..727b53e9044b 100644 --- a/qiskit/test/mock/backends/rome/__init__.py +++ b/qiskit/test/mock/backends/rome/__init__.py @@ -14,4 +14,3 @@ from .fake_rome import FakeRomeV2 from .fake_rome import FakeRome -from .fake_rome import FakeLegacyRome diff --git a/qiskit/test/mock/backends/rome/fake_rome.py b/qiskit/test/mock/backends/rome/fake_rome.py index b39739333e1c..cccf15190ece 100644 --- a/qiskit/test/mock/backends/rome/fake_rome.py +++ b/qiskit/test/mock/backends/rome/fake_rome.py @@ -36,13 +36,3 @@ class FakeRome(fake_pulse_backend.FakePulseBackend): props_filename = "props_rome.json" defs_filename = "defs_rome.json" backend_name = "fake_rome" - - -class FakeLegacyRome(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 5 qubit backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_rome.json" - props_filename = "props_rome.json" - defs_filename = "defs_rome.json" - backend_name = "fake_rome" diff --git a/qiskit/test/mock/backends/rueschlikon/__init__.py b/qiskit/test/mock/backends/rueschlikon/__init__.py index fd14c89e5aa7..861b5a751101 100644 --- a/qiskit/test/mock/backends/rueschlikon/__init__.py +++ b/qiskit/test/mock/backends/rueschlikon/__init__.py @@ -13,4 +13,3 @@ """Mock rueschlikon backend""" from .fake_rueschlikon import FakeRueschlikon -from .fake_rueschlikon import FakeLegacyRueschlikon diff --git a/qiskit/test/mock/backends/rueschlikon/fake_rueschlikon.py b/qiskit/test/mock/backends/rueschlikon/fake_rueschlikon.py index 306de8311ad9..914850ce710a 100644 --- a/qiskit/test/mock/backends/rueschlikon/fake_rueschlikon.py +++ b/qiskit/test/mock/backends/rueschlikon/fake_rueschlikon.py @@ -15,7 +15,7 @@ """ from qiskit.providers.models import GateConfig, QasmBackendConfiguration -from qiskit.test.mock.fake_backend import FakeBackend, FakeLegacyBackend +from qiskit.test.mock.fake_backend import FakeBackend class FakeRueschlikon(FakeBackend): @@ -69,56 +69,3 @@ def __init__(self): ) super().__init__(configuration) - - -class FakeLegacyRueschlikon(FakeLegacyBackend): - """A fake 16 qubit backend.""" - - def __init__(self): - """ - 1 → 2 → 3 → 4 ← 5 ← 6 → 7 ← 8 - ↓ ↑ ↓ ↓ ↑ ↓ ↓ ↑ - 0 ← 15 → 14 ← 13 ← 12 → 11 → 10 ← 9 - """ - cmap = [ - [1, 0], - [1, 2], - [2, 3], - [3, 4], - [3, 14], - [5, 4], - [6, 5], - [6, 7], - [6, 11], - [7, 10], - [8, 7], - [9, 8], - [9, 10], - [11, 10], - [12, 5], - [12, 11], - [12, 13], - [13, 4], - [13, 14], - [15, 0], - [15, 2], - [15, 14], - ] - - configuration = QasmBackendConfiguration( - backend_name="fake_rueschlikon", - backend_version="0.0.0", - n_qubits=16, - basis_gates=["u1", "u2", "u3", "cx", "id"], - simulator=False, - local=True, - conditional=False, - open_pulse=False, - memory=False, - max_shots=65536, - max_experiments=900, - gates=[GateConfig(name="TODO", parameters=[], qasm_def="TODO")], - coupling_map=cmap, - ) - - super().__init__(configuration) diff --git a/qiskit/test/mock/backends/santiago/__init__.py b/qiskit/test/mock/backends/santiago/__init__.py index f6e73c04b6c8..24af2ecbe902 100644 --- a/qiskit/test/mock/backends/santiago/__init__.py +++ b/qiskit/test/mock/backends/santiago/__init__.py @@ -14,4 +14,3 @@ from .fake_santiago import FakeSantiagoV2 from .fake_santiago import FakeSantiago -from .fake_santiago import FakeLegacySantiago diff --git a/qiskit/test/mock/backends/santiago/fake_santiago.py b/qiskit/test/mock/backends/santiago/fake_santiago.py index 25de8f7ef6db..9a19f1b3134d 100644 --- a/qiskit/test/mock/backends/santiago/fake_santiago.py +++ b/qiskit/test/mock/backends/santiago/fake_santiago.py @@ -36,13 +36,3 @@ class FakeSantiago(fake_pulse_backend.FakePulseBackend): props_filename = "props_santiago.json" defs_filename = "defs_santiago.json" backend_name = "fake_santiago" - - -class FakeLegacySantiago(fake_pulse_backend.FakePulseLegacyBackend): - """A fake Santiago backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_santiago.json" - props_filename = "props_santiago.json" - defs_filename = "defs_santiago.json" - backend_name = "fake_santiago" diff --git a/qiskit/test/mock/backends/singapore/__init__.py b/qiskit/test/mock/backends/singapore/__init__.py index ed72f84e8636..ece759b10992 100644 --- a/qiskit/test/mock/backends/singapore/__init__.py +++ b/qiskit/test/mock/backends/singapore/__init__.py @@ -14,4 +14,3 @@ from .fake_singapore import FakeSingaporeV2 from .fake_singapore import FakeSingapore -from .fake_singapore import FakeLegacySingapore diff --git a/qiskit/test/mock/backends/singapore/fake_singapore.py b/qiskit/test/mock/backends/singapore/fake_singapore.py index afb7b023c7b2..ae6dcb029ba7 100644 --- a/qiskit/test/mock/backends/singapore/fake_singapore.py +++ b/qiskit/test/mock/backends/singapore/fake_singapore.py @@ -54,22 +54,3 @@ class FakeSingapore(fake_pulse_backend.FakePulseBackend): props_filename = "props_singapore.json" defs_filename = "defs_singapore.json" backend_name = "fake_singapore" - - -class FakeLegacySingapore(fake_pulse_backend.FakePulseLegacyBackend): - """A fake Singapore backend. - - 00 ↔ 01 ↔ 02 ↔ 03 ↔ 04 - ↕ ↕ - 05 ↔ 06 ↔ 07 ↔ 08 ↔ 09 - ↕ ↕ ↕ - 10 ↔ 11 ↔ 12 ↔ 13 ↔ 14 - ↕ ↕ - 15 ↔ 16 ↔ 17 ↔ 18 ↔ 19 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_singapore.json" - props_filename = "props_singapore.json" - defs_filename = "defs_singapore.json" - backend_name = "fake_singapore" diff --git a/qiskit/test/mock/backends/sydney/__init__.py b/qiskit/test/mock/backends/sydney/__init__.py index c86b30026f73..c2d55c938369 100644 --- a/qiskit/test/mock/backends/sydney/__init__.py +++ b/qiskit/test/mock/backends/sydney/__init__.py @@ -14,4 +14,3 @@ from .fake_sydney import FakeSydneyV2 from .fake_sydney import FakeSydney -from .fake_sydney import FakeLegacySydney diff --git a/qiskit/test/mock/backends/sydney/fake_sydney.py b/qiskit/test/mock/backends/sydney/fake_sydney.py index ec49344a6f05..06076177de69 100644 --- a/qiskit/test/mock/backends/sydney/fake_sydney.py +++ b/qiskit/test/mock/backends/sydney/fake_sydney.py @@ -36,13 +36,3 @@ class FakeSydney(fake_pulse_backend.FakePulseBackend): props_filename = "props_sydney.json" defs_filename = "defs_sydney.json" backend_name = "fake_sydney" - - -class FakeLegacySydney(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 27 qubit backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_sydney.json" - props_filename = "props_sydney.json" - defs_filename = "defs_sydney.json" - backend_name = "fake_sydney" diff --git a/qiskit/test/mock/backends/tenerife/__init__.py b/qiskit/test/mock/backends/tenerife/__init__.py index 486b9067ba53..00cfe76d9607 100644 --- a/qiskit/test/mock/backends/tenerife/__init__.py +++ b/qiskit/test/mock/backends/tenerife/__init__.py @@ -13,4 +13,3 @@ """Mock tenerife backend""" from .fake_tenerife import FakeTenerife -from .fake_tenerife import FakeLegacyTenerife diff --git a/qiskit/test/mock/backends/tenerife/fake_tenerife.py b/qiskit/test/mock/backends/tenerife/fake_tenerife.py index 7a29a4868a48..653f74a90cba 100644 --- a/qiskit/test/mock/backends/tenerife/fake_tenerife.py +++ b/qiskit/test/mock/backends/tenerife/fake_tenerife.py @@ -18,7 +18,7 @@ import json from qiskit.providers.models import GateConfig, QasmBackendConfiguration, BackendProperties -from qiskit.test.mock.fake_backend import FakeBackend, FakeLegacyBackend +from qiskit.test.mock.fake_backend import FakeBackend class FakeTenerife(FakeBackend): @@ -59,43 +59,3 @@ def properties(self): with open(os.path.join(dirname, filename)) as f_prop: props = json.load(f_prop) return BackendProperties.from_dict(props) - - -class FakeLegacyTenerife(FakeLegacyBackend): - """A fake 5 qubit backend.""" - - def __init__(self): - """ - 1 - ↙ ↑ - 0 ← 2 ← 3 - ↑ ↙ - 4 - """ - cmap = [[1, 0], [2, 0], [2, 1], [3, 2], [3, 4], [4, 2]] - - configuration = QasmBackendConfiguration( - backend_name="fake_tenerife", - backend_version="0.0.0", - n_qubits=5, - basis_gates=["u1", "u2", "u3", "cx", "id"], - simulator=False, - local=True, - conditional=False, - open_pulse=False, - memory=False, - max_shots=65536, - max_experiments=900, - gates=[GateConfig(name="TODO", parameters=[], qasm_def="TODO")], - coupling_map=cmap, - ) - - super().__init__(configuration) - - def properties(self): - """Returns a snapshot of device properties as recorded on 8/30/19.""" - dirname = os.path.dirname(__file__) - filename = "props_tenerife.json" - with open(os.path.join(dirname, filename)) as f_prop: - props = json.load(f_prop) - return BackendProperties.from_dict(props) diff --git a/qiskit/test/mock/backends/tokyo/__init__.py b/qiskit/test/mock/backends/tokyo/__init__.py index a480ad4dfa43..3792fa9557f9 100644 --- a/qiskit/test/mock/backends/tokyo/__init__.py +++ b/qiskit/test/mock/backends/tokyo/__init__.py @@ -13,4 +13,3 @@ """Mock tokyo backend""" from .fake_tokyo import FakeTokyo -from .fake_tokyo import FakeLegacyTokyo diff --git a/qiskit/test/mock/backends/tokyo/fake_tokyo.py b/qiskit/test/mock/backends/tokyo/fake_tokyo.py index e2c3780739f2..8b4d6be6ce5a 100644 --- a/qiskit/test/mock/backends/tokyo/fake_tokyo.py +++ b/qiskit/test/mock/backends/tokyo/fake_tokyo.py @@ -18,7 +18,7 @@ import json from qiskit.providers.models import GateConfig, QasmBackendConfiguration, BackendProperties -from qiskit.test.mock.fake_backend import FakeBackend, FakeLegacyBackend +from qiskit.test.mock.fake_backend import FakeBackend class FakeTokyo(FakeBackend): @@ -132,116 +132,3 @@ def properties(self): with open(os.path.join(dirname, filename)) as f_prop: props = json.load(f_prop) return BackendProperties.from_dict(props) - - -class FakeLegacyTokyo(FakeLegacyBackend): - """A fake 20 qubit backend.""" - - def __init__(self): - """ - 00 ↔ 01 ↔ 02 ↔ 03 ↔ 04 - ↕ ↕ ↕ ↕ ⤫ ↕ - 05 ↔ 06 ↔ 07 ↔ 08 ↔ 09 - ↕ ⤫ ↕ ↕ ⤫ ↕ - 10 ↔ 11 ↔ 12 ↔ 13 ↔ 14 - ↕ ↕ ⤫ ↕ ⤫ ↕ - 15 ↔ 16 ↔ 17 18 19 - """ - cmap = [ - [0, 1], - [0, 5], - [1, 0], - [1, 2], - [1, 6], - [1, 7], - [2, 1], - [2, 6], - [3, 8], - [4, 8], - [4, 9], - [5, 0], - [5, 6], - [5, 10], - [5, 11], - [6, 1], - [6, 2], - [6, 5], - [6, 7], - [6, 10], - [6, 11], - [7, 1], - [7, 6], - [7, 8], - [7, 12], - [8, 3], - [8, 4], - [8, 7], - [8, 9], - [8, 12], - [8, 13], - [9, 4], - [9, 8], - [10, 5], - [10, 6], - [10, 11], - [10, 15], - [11, 5], - [11, 6], - [11, 10], - [11, 12], - [11, 16], - [11, 17], - [12, 7], - [12, 8], - [12, 11], - [12, 13], - [12, 16], - [13, 8], - [13, 12], - [13, 14], - [13, 18], - [13, 19], - [14, 13], - [14, 18], - [14, 19], - [15, 10], - [15, 16], - [16, 11], - [16, 12], - [16, 15], - [16, 17], - [17, 11], - [17, 16], - [17, 18], - [18, 13], - [18, 14], - [18, 17], - [19, 13], - [19, 14], - ] - - configuration = QasmBackendConfiguration( - backend_name="fake_tokyo", - backend_version="0.0.0", - n_qubits=20, - basis_gates=["u1", "u2", "u3", "cx", "id"], - simulator=False, - local=True, - conditional=False, - open_pulse=False, - memory=False, - max_shots=65536, - max_experiments=900, - gates=[GateConfig(name="TODO", parameters=[], qasm_def="TODO")], - coupling_map=cmap, - ) - - super().__init__(configuration) - - def properties(self): - """Returns a snapshot of device properties as recorded on 8/30/19.""" - dirname = os.path.dirname(__file__) - filename = "props_tokyo.json" - with open(os.path.join(dirname, filename)) as f_prop: - props = json.load(f_prop) - return BackendProperties.from_dict(props) diff --git a/qiskit/test/mock/backends/toronto/__init__.py b/qiskit/test/mock/backends/toronto/__init__.py index f8acfc13cdc0..0f0038099d1a 100644 --- a/qiskit/test/mock/backends/toronto/__init__.py +++ b/qiskit/test/mock/backends/toronto/__init__.py @@ -14,4 +14,3 @@ from .fake_toronto import FakeTorontoV2 from .fake_toronto import FakeToronto -from .fake_toronto import FakeLegacyToronto diff --git a/qiskit/test/mock/backends/toronto/fake_toronto.py b/qiskit/test/mock/backends/toronto/fake_toronto.py index cf59b82b8200..039b0705016f 100644 --- a/qiskit/test/mock/backends/toronto/fake_toronto.py +++ b/qiskit/test/mock/backends/toronto/fake_toronto.py @@ -36,13 +36,3 @@ class FakeToronto(fake_pulse_backend.FakePulseBackend): props_filename = "props_toronto.json" defs_filename = "defs_toronto.json" backend_name = "fake_toronto" - - -class FakeLegacyToronto(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 27 qubit backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_toronto.json" - props_filename = "props_toronto.json" - defs_filename = "defs_toronto.json" - backend_name = "fake_toronto" diff --git a/qiskit/test/mock/backends/valencia/__init__.py b/qiskit/test/mock/backends/valencia/__init__.py index b76a400b02a9..a9e6b6d1851c 100644 --- a/qiskit/test/mock/backends/valencia/__init__.py +++ b/qiskit/test/mock/backends/valencia/__init__.py @@ -14,4 +14,3 @@ from .fake_valencia import FakeValenciaV2 from .fake_valencia import FakeValencia -from .fake_valencia import FakeLegacyValencia diff --git a/qiskit/test/mock/backends/valencia/fake_valencia.py b/qiskit/test/mock/backends/valencia/fake_valencia.py index e8a0c1213fff..c21dbfd9ae76 100644 --- a/qiskit/test/mock/backends/valencia/fake_valencia.py +++ b/qiskit/test/mock/backends/valencia/fake_valencia.py @@ -36,13 +36,3 @@ class FakeValencia(fake_pulse_backend.FakePulseBackend): props_filename = "props_valencia.json" defs_filename = "defs_valencia.json" backend_name = "fake_valencia" - - -class FakeLegacyValencia(fake_pulse_backend.FakePulseLegacyBackend): - """A fake 5 qubit backend.""" - - dirname = os.path.dirname(__file__) - conf_filename = "conf_valencia.json" - props_filename = "props_valencia.json" - defs_filename = "defs_valencia.json" - backend_name = "fake_valencia" diff --git a/qiskit/test/mock/backends/vigo/__init__.py b/qiskit/test/mock/backends/vigo/__init__.py index 1efe30e2a2ac..e019afc9e065 100644 --- a/qiskit/test/mock/backends/vigo/__init__.py +++ b/qiskit/test/mock/backends/vigo/__init__.py @@ -14,4 +14,3 @@ from .fake_vigo import FakeVigoV2 from .fake_vigo import FakeVigo -from .fake_vigo import FakeLegacyVigo diff --git a/qiskit/test/mock/backends/vigo/fake_vigo.py b/qiskit/test/mock/backends/vigo/fake_vigo.py index 3b33fc12443f..71d3465329d8 100644 --- a/qiskit/test/mock/backends/vigo/fake_vigo.py +++ b/qiskit/test/mock/backends/vigo/fake_vigo.py @@ -44,17 +44,3 @@ class FakeVigo(fake_qasm_backend.FakeQasmBackend): conf_filename = "conf_vigo.json" props_filename = "props_vigo.json" backend_name = "fake_vigo" - - -class FakeLegacyVigo(fake_qasm_backend.FakeQasmLegacyBackend): - """A fake 5 qubit backend. - - 0 ↔ 1 ↔ 3 ↔ 4 - ↕ - 2 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_vigo.json" - props_filename = "props_vigo.json" - backend_name = "fake_vigo" diff --git a/qiskit/test/mock/backends/yorktown/__init__.py b/qiskit/test/mock/backends/yorktown/__init__.py index e7486f0acd57..43037e7de333 100644 --- a/qiskit/test/mock/backends/yorktown/__init__.py +++ b/qiskit/test/mock/backends/yorktown/__init__.py @@ -14,4 +14,3 @@ from .fake_yorktown import FakeYorktownV2 from .fake_yorktown import FakeYorktown -from .fake_yorktown import FakeLegacyYorktown diff --git a/qiskit/test/mock/backends/yorktown/fake_yorktown.py b/qiskit/test/mock/backends/yorktown/fake_yorktown.py index 777081fcbee1..c4b84383b63a 100644 --- a/qiskit/test/mock/backends/yorktown/fake_yorktown.py +++ b/qiskit/test/mock/backends/yorktown/fake_yorktown.py @@ -48,19 +48,3 @@ class FakeYorktown(fake_qasm_backend.FakeQasmBackend): conf_filename = "conf_yorktown.json" props_filename = "props_yorktown.json" backend_name = "fake_yorktown" - - -class FakeLegacyYorktown(fake_qasm_backend.FakeQasmLegacyBackend): - """A fake 5 qubit backend. - - 1 - / | - 0 - 2 - 3 - | / - 4 - """ - - dirname = os.path.dirname(__file__) - conf_filename = "conf_yorktown.json" - props_filename = "props_yorktown.json" - backend_name = "fake_yorktown" diff --git a/qiskit/test/mock/fake_backend.py b/qiskit/test/mock/fake_backend.py index ad770f2f595b..1be914be0dda 100644 --- a/qiskit/test/mock/fake_backend.py +++ b/qiskit/test/mock/fake_backend.py @@ -16,7 +16,6 @@ Base class for dummy backends. """ -import uuid import warnings import json import os @@ -25,10 +24,9 @@ from qiskit import circuit from qiskit.providers.models import BackendProperties -from qiskit.providers import BackendV2, BackendV1, BaseBackend +from qiskit.providers import BackendV2, BackendV1 from qiskit import pulse from qiskit.exceptions import QiskitError -from qiskit.test.mock import fake_job from qiskit.test.mock.utils.json_decoder import ( decode_backend_configuration, decode_backend_properties, @@ -460,104 +458,3 @@ def run(self, run_input, **kwargs): self.sim._options = self._options job = self.sim.run(circuits, **kwargs) return job - - -class FakeLegacyBackend(BaseBackend): - """This is a dummy backend just for testing purposes of the legacy providers interface.""" - - def __init__(self, configuration, time_alive=10): - """FakeBackend initializer. - Args: - configuration (BackendConfiguration): backend configuration - time_alive (int): time to wait before returning result - """ - super().__init__(configuration) - self.time_alive = time_alive - self._credentials = _Credentials() - - def properties(self): - """Return backend properties""" - coupling_map = self.configuration().coupling_map - unique_qubits = list(set().union(*coupling_map)) - - properties = { - "backend_name": self.name(), - "backend_version": self.configuration().backend_version, - "last_update_date": "2000-01-01 00:00:00Z", - "qubits": [ - [ - {"date": "2000-01-01 00:00:00Z", "name": "T1", "unit": "\u00b5s", "value": 0.0}, - {"date": "2000-01-01 00:00:00Z", "name": "T2", "unit": "\u00b5s", "value": 0.0}, - { - "date": "2000-01-01 00:00:00Z", - "name": "frequency", - "unit": "GHz", - "value": 0.0, - }, - { - "date": "2000-01-01 00:00:00Z", - "name": "readout_error", - "unit": "", - "value": 0.0, - }, - {"date": "2000-01-01 00:00:00Z", "name": "operational", "unit": "", "value": 1}, - ] - for _ in range(len(unique_qubits)) - ], - "gates": [ - { - "gate": "cx", - "name": "CX" + str(pair[0]) + "_" + str(pair[1]), - "parameters": [ - { - "date": "2000-01-01 00:00:00Z", - "name": "gate_error", - "unit": "", - "value": 0.0, - } - ], - "qubits": [pair[0], pair[1]], - } - for pair in coupling_map - ], - "general": [], - } - - return BackendProperties.from_dict(properties) - - def run(self, qobj): - """Main job in simulator""" - if _optionals.HAS_AER: - from qiskit.providers import aer - - if qobj.type == "PULSE": - from qiskit.providers.aer.pulse import PulseSystemModel - - system_model = PulseSystemModel.from_backend(self) - sim = aer.Aer.get_backend("pulse_simulator") - job = sim.run(qobj, system_model) - else: - sim = aer.Aer.get_backend("qasm_simulator") - if self.properties(): - from qiskit.providers.aer.noise import NoiseModel - - noise_model = NoiseModel.from_backend(self, warnings=False) - job = sim.run(qobj, noise_model=noise_model) - else: - job = sim.run(qobj) - - out_job = fake_job.FakeLegacyJob(self, job.job_id, None) - out_job._future = job._future - else: - if qobj.type == "PULSE": - raise QiskitError("Unable to run pulse schedules without qiskit-aer installed") - warnings.warn("Aer not found using BasicAer and no noise", RuntimeWarning) - - def run_job(): - sim = basicaer.BasicAer.get_backend("qasm_simulator") - return sim.run(qobj).result() - - job_id = uuid.uuid4() - out_job = fake_job.FakeLegacyJob(self, job_id, run_job) - out_job.submit() - return out_job diff --git a/qiskit/test/mock/fake_job.py b/qiskit/test/mock/fake_job.py index 876128d810f3..22c4b4312f2e 100644 --- a/qiskit/test/mock/fake_job.py +++ b/qiskit/test/mock/fake_job.py @@ -17,7 +17,7 @@ from concurrent import futures -from qiskit.providers import JobV1, BaseJob +from qiskit.providers import JobV1 from qiskit.providers.jobstatus import JobStatus @@ -80,64 +80,3 @@ def _running(self): @property def _error(self): return self._future.exception(timeout=0) - - -class FakeLegacyJob(BaseJob): - """Fake simulator job""" - - _executor = futures.ThreadPoolExecutor() # pylint: disable=consider-using-with - - def __init__(self, backend, job_id, fn): - super().__init__(backend, job_id) - self._backend = backend - self._job_id = job_id - self._future = None - self._future_callback = fn - - def submit(self): - self._future = self._executor.submit(self._future_callback) - - def result(self, timeout=None): - # pylint: disable=arguments-differ - return self._future.result(timeout=timeout) - - def cancel(self): - return self._future.cancel() - - def status(self): - if self._running: - _status = JobStatus.RUNNING - elif not self._done: - _status = JobStatus.QUEUED - elif self._cancelled: - _status = JobStatus.CANCELLED - elif self._done: - _status = JobStatus.DONE - elif self._error: - _status = JobStatus.ERROR - else: - raise Exception(f"Unexpected state of {self.__class__.__name__}") - _status_msg = None - return {"status": _status, "status_msg": _status_msg} - - def job_id(self): - return self._job_id - - def backend(self): - return self._backend - - @property - def _cancelled(self): - return self._future.cancelled() - - @property - def _done(self): - return self._future.done() - - @property - def _running(self): - return self._future.running() - - @property - def _error(self): - return self._future.exception(timeout=0) diff --git a/qiskit/test/mock/fake_provider.py b/qiskit/test/mock/fake_provider.py index 018425faa6c3..b52a04a3c4ae 100644 --- a/qiskit/test/mock/fake_provider.py +++ b/qiskit/test/mock/fake_provider.py @@ -17,7 +17,6 @@ """ from qiskit.providers.provider import ProviderV1 -from qiskit.providers.baseprovider import BaseProvider from qiskit.providers.exceptions import QiskitBackendNotFoundError from .backends import * @@ -206,64 +205,3 @@ def __init__(self): ] super().__init__() - - -class FakeLegacyProvider(BaseProvider): - """Dummy provider just for testing purposes. - - Only filtering backends by name is implemented. - """ - - def get_backend(self, name=None, **kwargs): - backend = self._backends[0] - if name: - filtered_backends = [backend for backend in self._backends if backend.name() == name] - if not filtered_backends: - raise QiskitBackendNotFoundError() - - backend = filtered_backends[0] - - return backend - - def backends(self, name=None, **kwargs): - return self._backends - - def __init__(self): - self._backends = [ - FakeLegacyAlmaden(), - FakeLegacyArmonk(), - FakeLegacyAthens(), - FakeLegacyBelem(), - FakeLegacyBoeblingen(), - FakeLegacyBogota(), - FakeLegacyBurlington(), - FakeLegacyCambridge(), - FakeLegacyCambridgeAlternativeBasis(), - FakeLegacyCasablanca(), - FakeLegacyEssex(), - FakeLegacyJohannesburg(), - FakeLegacyLima(), - FakeLegacyLondon(), - FakeLegacyManhattan(), - FakeLegacyMelbourne(), - FakeLegacyMontreal(), - FakeLegacyMumbai(), - FakeLegacyOurense(), - FakeLegacyParis(), - FakeLegacyPoughkeepsie(), - FakeLegacyQuito(), - FakeLegacyRochester(), - FakeLegacyRome(), - FakeLegacyRueschlikon(), - FakeLegacySantiago(), - FakeLegacySingapore(), - FakeLegacySydney(), - FakeLegacyTenerife(), - FakeLegacyTokyo(), - FakeLegacyToronto(), - FakeLegacyValencia(), - FakeLegacyVigo(), - FakeLegacyYorktown(), - ] - - super().__init__() diff --git a/qiskit/test/mock/fake_pulse_backend.py b/qiskit/test/mock/fake_pulse_backend.py index 11ff0a5811da..d22a3ba3ea7b 100644 --- a/qiskit/test/mock/fake_pulse_backend.py +++ b/qiskit/test/mock/fake_pulse_backend.py @@ -15,7 +15,7 @@ """ from qiskit.providers.models import PulseBackendConfiguration, PulseDefaults -from qiskit.test.mock.fake_qasm_backend import FakeQasmBackend, FakeQasmLegacyBackend +from qiskit.test.mock.fake_qasm_backend import FakeQasmBackend from qiskit.exceptions import QiskitError from qiskit.test.mock.utils.json_decoder import decode_pulse_defaults @@ -40,25 +40,3 @@ def _set_defaults_from_json(self): def _get_config_from_dict(self, conf): return PulseBackendConfiguration.from_dict(conf) - - -class FakePulseLegacyBackend(FakeQasmLegacyBackend): - """A fake pulse backend.""" - - defs_filename = None - - def defaults(self): - """Returns a snapshot of device defaults""" - if not self._defaults: - self._set_defaults_from_json() - return self._defaults - - def _set_defaults_from_json(self): - if not self.props_filename: - raise QiskitError("No properties file has been defined") - defs = self._load_json(self.defs_filename) - decode_pulse_defaults(defs) - self._defaults = PulseDefaults.from_dict(defs) - - def _get_config_from_dict(self, conf): - return PulseBackendConfiguration.from_dict(conf) diff --git a/qiskit/test/mock/fake_qasm_backend.py b/qiskit/test/mock/fake_qasm_backend.py index fe5dce37df8c..d5e942922a3b 100644 --- a/qiskit/test/mock/fake_qasm_backend.py +++ b/qiskit/test/mock/fake_qasm_backend.py @@ -18,7 +18,7 @@ import os from qiskit.providers.models import BackendProperties, QasmBackendConfiguration -from qiskit.test.mock.fake_backend import FakeBackend, FakeLegacyBackend +from qiskit.test.mock.fake_backend import FakeBackend from qiskit.test.mock.utils.json_decoder import ( decode_backend_configuration, decode_backend_properties, @@ -69,48 +69,3 @@ def _load_json(self, filename): def _get_config_from_dict(self, conf): return QasmBackendConfiguration.from_dict(conf) - - -class FakeQasmLegacyBackend(FakeLegacyBackend): - """A fake qasm backend.""" - - dirname = None - conf_filename = None - props_filename = None - backend_name = None - - def __init__(self): - configuration = self._get_conf_from_json() - self._defaults = None - self._properties = None - super().__init__(configuration) - - def properties(self): - """Returns a snapshot of device properties""" - if not self._properties: - self._set_props_from_json() - return self._properties - - def _get_conf_from_json(self): - if not self.conf_filename: - raise QiskitError("No configuration file has been defined") - conf = self._load_json(self.conf_filename) - decode_backend_configuration(conf) - configuration = self._get_config_from_dict(conf) - configuration.backend_name = self.backend_name - return configuration - - def _set_props_from_json(self): - if not self.props_filename: - raise QiskitError("No properties file has been defined") - props = self._load_json(self.props_filename) - decode_backend_properties(props) - self._properties = BackendProperties.from_dict(props) - - def _load_json(self, filename): - with open(os.path.join(self.dirname, filename)) as f_json: - the_json = json.load(f_json) - return the_json - - def _get_config_from_dict(self, conf): - return QasmBackendConfiguration.from_dict(conf) diff --git a/qiskit/tools/jupyter/jupyter_magics.py b/qiskit/tools/jupyter/jupyter_magics.py index 216e999162e1..6f90a1a76863 100644 --- a/qiskit/tools/jupyter/jupyter_magics.py +++ b/qiskit/tools/jupyter/jupyter_magics.py @@ -112,10 +112,10 @@ def qiskit_job_status(self, line="", cell=None): if iter_var: for item in self.shell.user_ns[var]: - if isinstance(item, qiskit.providers.basejob.BaseJob): + if isinstance(item, qiskit.providers.job.Job): jobs.append(item) else: - if isinstance(self.shell.user_ns[var], qiskit.providers.basejob.BaseJob): + if isinstance(self.shell.user_ns[var], qiskit.providers.job.Job): jobs.append(self.shell.user_ns[var]) # Must have one job class diff --git a/qiskit/transpiler/instruction_durations.py b/qiskit/transpiler/instruction_durations.py index bc43c78b68d9..a13d6e6e5629 100644 --- a/qiskit/transpiler/instruction_durations.py +++ b/qiskit/transpiler/instruction_durations.py @@ -17,7 +17,7 @@ from qiskit.circuit import Barrier, Delay from qiskit.circuit import Instruction, Qubit, ParameterExpression from qiskit.circuit.duration import duration_in_dt -from qiskit.providers import BaseBackend +from qiskit.providers import Backend from qiskit.transpiler.exceptions import TranspilerError from qiskit.utils.units import apply_prefix @@ -60,7 +60,7 @@ def __str__(self): return string @classmethod - def from_backend(cls, backend: BaseBackend): + def from_backend(cls, backend: Backend): """Construct an :class:`InstructionDurations` object from the backend. Args: diff --git a/qiskit/transpiler/passes/calibration/builders.py b/qiskit/transpiler/passes/calibration/builders.py index cdb8be5e1bbe..e1683d477353 100644 --- a/qiskit/transpiler/passes/calibration/builders.py +++ b/qiskit/transpiler/passes/calibration/builders.py @@ -14,13 +14,10 @@ from abc import abstractmethod from typing import List, Union -import warnings import math import numpy as np -from qiskit.providers.basebackend import BaseBackend -from qiskit.providers.backend import BackendV1 from qiskit.circuit import Instruction as CircuitInst from qiskit.circuit.library.standard_gates import RZXGate from qiskit.dagcircuit import DAGCircuit @@ -107,7 +104,6 @@ class RZXCalibrationBuilder(CalibrationBuilder): def __init__( self, - backend: Union[BaseBackend, BackendV1] = None, instruction_schedule_map: InstructionScheduleMap = None, qubit_channel_mapping: List[List[str]] = None, ): @@ -115,10 +111,6 @@ def __init__( Initializes a RZXGate calibration builder. Args: - backend: DEPRECATED a backend object to build the calibrations for. - Use of this argument is deprecated in favor of directly - specifying ``instruction_schedule_map`` and - ``qubit_channel_map``. instruction_schedule_map: The :obj:`InstructionScheduleMap` object representing the default pulse calibrations for the target backend qubit_channel_mapping: The list mapping qubit indices to the list of @@ -128,30 +120,11 @@ def __init__( QiskitError: if open pulse is not supported by the backend. """ super().__init__() - if backend is not None: - warnings.warn( - "Passing a backend object directly to this pass (either as the first positional " - "argument or as the named 'backend' kwarg is deprecated and will no long be " - "supported in a future release. Instead use the instruction_schedule_map and " - "qubit_channel_mapping kwargs.", - DeprecationWarning, - stacklevel=2, - ) - - if not backend.configuration().open_pulse: - raise QiskitError( - "Calibrations can only be added to Pulse-enabled backends, " - "but {} is not enabled with Pulse.".format(backend.name()) - ) - self._inst_map = backend.defaults().instruction_schedule_map - self._channel_map = backend.configuration().qubit_channel_mapping - - else: - if instruction_schedule_map is None or qubit_channel_mapping is None: - raise QiskitError("Calibrations can only be added to Pulse-enabled backends") + if instruction_schedule_map is None or qubit_channel_mapping is None: + raise QiskitError("Calibrations can only be added to Pulse-enabled backends") - self._inst_map = instruction_schedule_map - self._channel_map = qubit_channel_mapping + self._inst_map = instruction_schedule_map + self._channel_map = qubit_channel_mapping def supported(self, node_op: CircuitInst, qubits: List) -> bool: """Determine if a given node supports the calibration. diff --git a/qiskit/utils/backend_utils.py b/qiskit/utils/backend_utils.py index 219e9c9a88fb..bfee6417cce9 100644 --- a/qiskit/utils/backend_utils.py +++ b/qiskit/utils/backend_utils.py @@ -37,10 +37,6 @@ def __init__(self) -> None: def _get_backend_interface_version(backend): """Get the backend version int.""" backend_interface_version = getattr(backend, "version", None) - # Handle deprecated BaseBackend based backends which have a version() - # method - if not isinstance(backend_interface_version, int): - backend_interface_version = 0 return backend_interface_version @@ -90,7 +86,7 @@ def is_aer_provider(backend): """Detect whether or not backend is from Aer provider. Args: - backend (BaseBackend): backend instance + backend (Backend): backend instance Returns: bool: True is AerProvider """ @@ -110,7 +106,7 @@ def is_basicaer_provider(backend): """Detect whether or not backend is from BasicAer provider. Args: - backend (BaseBackend): backend instance + backend (Backend): backend instance Returns: bool: True is BasicAer """ @@ -123,7 +119,7 @@ def is_ibmq_provider(backend): """Detect whether or not backend is from IBMQ provider. Args: - backend (BaseBackend): backend instance + backend (Backend): backend instance Returns: bool: True is IBMQ """ @@ -140,7 +136,7 @@ def is_aer_statevector_backend(backend): Return True if backend object is statevector and from Aer provider. Args: - backend (BaseBackend): backend instance + backend (Backend): backend instance Returns: bool: True is statevector """ @@ -152,7 +148,7 @@ def is_statevector_backend(backend): Return True if backend object is statevector. Args: - backend (BaseBackend): backend instance + backend (Backend): backend instance Returns: bool: True is statevector """ @@ -177,7 +173,7 @@ def is_simulator_backend(backend): Return True if backend is a simulator. Args: - backend (BaseBackend): backend instance + backend (Backend): backend instance Returns: bool: True is a simulator """ @@ -192,7 +188,7 @@ def is_local_backend(backend): Return True if backend is a local backend. Args: - backend (BaseBackend): backend instance + backend (Backend): backend instance Returns: bool: True is a local backend """ @@ -206,7 +202,7 @@ def is_aer_qasm(backend): """ Return True if backend is Aer Qasm simulator Args: - backend (BaseBackend): backend instance + backend (Backend): backend instance Returns: bool: True is Aer Qasm simulator @@ -222,7 +218,7 @@ def support_backend_options(backend): """ Return True if backend supports backend_options Args: - backend (BaseBackend): backend instance + backend (Backend): backend instance Returns: bool: True is support backend_options diff --git a/qiskit/utils/measurement_error_mitigation.py b/qiskit/utils/measurement_error_mitigation.py index 441e27c1ecf0..8d224b21e9f7 100644 --- a/qiskit/utils/measurement_error_mitigation.py +++ b/qiskit/utils/measurement_error_mitigation.py @@ -16,7 +16,7 @@ from typing import List, Optional, Tuple, Dict, Callable from qiskit import compiler -from qiskit.providers import BaseBackend +from qiskit.providers import Backend from qiskit.circuit import QuantumCircuit from qiskit.qobj import QasmQobj from qiskit.assembler.run_config import RunConfig @@ -119,7 +119,7 @@ def get_measured_qubits_from_qobj(qobj: QasmQobj) -> Tuple[List[int], Dict[str, def build_measurement_error_mitigation_circuits( qubit_list: List[int], fitter_cls: Callable, - backend: BaseBackend, + backend: Backend, backend_config: Optional[Dict] = None, compile_config: Optional[Dict] = None, mit_pattern: Optional[List[List[int]]] = None, @@ -194,7 +194,7 @@ def build_measurement_error_mitigation_circuits( def build_measurement_error_mitigation_qobj( qubit_list: List[int], fitter_cls: Callable, - backend: BaseBackend, + backend: Backend, backend_config: Optional[Dict] = None, compile_config: Optional[Dict] = None, run_config: Optional[RunConfig] = None, diff --git a/qiskit/utils/quantum_instance.py b/qiskit/utils/quantum_instance.py index ec7276e9ea83..bd073e5d1d04 100644 --- a/qiskit/utils/quantum_instance.py +++ b/qiskit/utils/quantum_instance.py @@ -29,7 +29,6 @@ is_statevector_backend, is_simulator_backend, is_local_backend, - is_aer_qasm, is_basicaer_provider, support_backend_options, _get_backend_provider, @@ -181,7 +180,7 @@ def __init__( execute the circuits it needs to run using the instance. Args: - backend (Union['Backend', 'BaseBackend']): Instance of selected backend + backend (Backend): Instance of selected backend shots: Number of repetitions of each circuit, for sampling. If None, the shots are extracted from the backend. If the backend has none set, the default is 1024. seed_simulator: Random seed for simulators @@ -247,10 +246,9 @@ def __init__( # if the shots are none, try to get them from the backend if shots is None: - from qiskit.providers.basebackend import BaseBackend # pylint: disable=cyclic-import from qiskit.providers.backend import Backend # pylint: disable=cyclic-import - if isinstance(backend, (BaseBackend, Backend)): + if isinstance(backend, Backend): if hasattr(backend, "options"): # should always be true for V1 backend_shots = backend.options.get("shots", 1024) if shots != backend_shots: @@ -489,12 +487,10 @@ def execute(self, circuits, had_transpiled: bool = False): TODO: Maybe we can combine the circuits for the main ones and calibration circuits before assembling to the qobj. """ - from qiskit.utils.run_circuits import run_qobj, run_circuits + from qiskit.utils.run_circuits import run_circuits from qiskit.utils.measurement_error_mitigation import ( - get_measured_qubits_from_qobj, get_measured_qubits, build_measurement_error_mitigation_circuits, - build_measurement_error_mitigation_qobj, ) if had_transpiled: @@ -511,9 +507,6 @@ def execute(self, circuits, had_transpiled: bool = False): # transpile here, the method always returns a copied list circuits = self.transpile(circuits) - from qiskit.providers import Backend - - circuit_job = isinstance(self._backend, Backend) if self.is_statevector and self.backend_name == "aer_simulator_statevector": try: from qiskit.providers.aer.library import SaveStatevector @@ -534,16 +527,8 @@ def _find_save_state(data): except ImportError: pass - # assemble - if not circuit_job: - qobj = self.assemble(circuits) - if self._meas_error_mitigation_cls is not None: - qubit_index, qubit_mappings = ( - get_measured_qubits(circuits) - if circuit_job - else get_measured_qubits_from_qobj(qobj) - ) + qubit_index, qubit_mappings = get_measured_qubits(circuits) mit_pattern = self._mit_pattern if mit_pattern is None: mit_pattern = [[i] for i in range(len(qubit_index))] @@ -588,128 +573,64 @@ def _find_save_state(data): cal_circuits = None prepended_calibration_circuits: int = 0 if build_cals_matrix: - if circuit_job: - logger.info("Updating to also run measurement error mitigation.") - use_different_shots = not ( - self._meas_error_mitigation_shots is None - or self._meas_error_mitigation_shots == self._run_config.shots - ) - temp_run_config = copy.deepcopy(self._run_config) - if use_different_shots: - temp_run_config.shots = self._meas_error_mitigation_shots - ( + logger.info("Updating to also run measurement error mitigation.") + use_different_shots = not ( + self._meas_error_mitigation_shots is None + or self._meas_error_mitigation_shots == self._run_config.shots + ) + temp_run_config = copy.deepcopy(self._run_config) + if use_different_shots: + temp_run_config.shots = self._meas_error_mitigation_shots + ( + cal_circuits, + state_labels, + circuit_labels, + ) = build_measurement_error_mitigation_circuits( + qubit_index, + self._meas_error_mitigation_cls, + self._backend, + self._backend_config, + self._compile_config, + mit_pattern=mit_pattern, + ) + if use_different_shots: + cals_result = run_circuits( cal_circuits, - state_labels, - circuit_labels, - ) = build_measurement_error_mitigation_circuits( - qubit_index, - self._meas_error_mitigation_cls, self._backend, - self._backend_config, - self._compile_config, - mit_pattern=mit_pattern, + qjob_config=self._qjob_config, + backend_options=self._backend_options, + noise_config=self._noise_config, + run_config=self._run_config.to_dict(), + job_callback=self._job_callback, + max_job_retries=self._max_job_retries, ) - if use_different_shots: - cals_result = run_circuits( - cal_circuits, - self._backend, - qjob_config=self._qjob_config, - backend_options=self._backend_options, - noise_config=self._noise_config, - run_config=self._run_config.to_dict(), - job_callback=self._job_callback, - max_job_retries=self._max_job_retries, - ) - self._time_taken += cals_result.time_taken - result = run_circuits( - circuits, - self._backend, - qjob_config=self.qjob_config, - backend_options=self.backend_options, - noise_config=self._noise_config, - run_config=self.run_config.to_dict(), - job_callback=self._job_callback, - max_job_retries=self._max_job_retries, - ) - self._time_taken += result.time_taken - else: - circuits[0:0] = cal_circuits - prepended_calibration_circuits = len(cal_circuits) - result = run_circuits( - circuits, - self._backend, - qjob_config=self.qjob_config, - backend_options=self.backend_options, - noise_config=self._noise_config, - run_config=self.run_config.to_dict(), - job_callback=self._job_callback, - max_job_retries=self._max_job_retries, - ) - self._time_taken += result.time_taken - cals_result = result - - else: - logger.info("Updating qobj with the circuits for measurement error mitigation.") - use_different_shots = not ( - self._meas_error_mitigation_shots is None - or self._meas_error_mitigation_shots == self._run_config.shots + self._time_taken += cals_result.time_taken + result = run_circuits( + circuits, + self._backend, + qjob_config=self.qjob_config, + backend_options=self.backend_options, + noise_config=self._noise_config, + run_config=self.run_config.to_dict(), + job_callback=self._job_callback, + max_job_retries=self._max_job_retries, ) - temp_run_config = copy.deepcopy(self._run_config) - if use_different_shots: - temp_run_config.shots = self._meas_error_mitigation_shots - - ( - cals_qobj, - state_labels, - circuit_labels, - ) = build_measurement_error_mitigation_qobj( - qubit_index, - self._meas_error_mitigation_cls, + self._time_taken += result.time_taken + else: + circuits[0:0] = cal_circuits + prepended_calibration_circuits = len(cal_circuits) + result = run_circuits( + circuits, self._backend, - self._backend_config, - self._compile_config, - temp_run_config, - mit_pattern=mit_pattern, + qjob_config=self.qjob_config, + backend_options=self.backend_options, + noise_config=self._noise_config, + run_config=self.run_config.to_dict(), + job_callback=self._job_callback, + max_job_retries=self._max_job_retries, ) - if use_different_shots or is_aer_qasm(self._backend): - cals_result = run_qobj( - cals_qobj, - self._backend, - self._qjob_config, - self._backend_options, - self._noise_config, - self._skip_qobj_validation, - self._job_callback, - self._max_job_retries, - ) - self._time_taken += cals_result.time_taken - result = run_qobj( - qobj, - self._backend, - self._qjob_config, - self._backend_options, - self._noise_config, - self._skip_qobj_validation, - self._job_callback, - self._max_job_retries, - ) - self._time_taken += result.time_taken - else: - # insert the calibration circuit into main qobj if the shots are the same - qobj.experiments[0:0] = cals_qobj.experiments - result = run_qobj( - qobj, - self._backend, - self._qjob_config, - self._backend_options, - self._noise_config, - self._skip_qobj_validation, - self._job_callback, - self._max_job_retries, - ) - self._time_taken += result.time_taken - cals_result = result - + self._time_taken += result.time_taken + cals_result = result logger.info("Building calibration matrix for measurement error mitigation.") meas_type = _MeasFitterType.type_from_class(self._meas_error_mitigation_cls) if meas_type == _MeasFitterType.COMPLETE_MEAS_FITTER: @@ -725,28 +646,15 @@ def _find_save_state(data): time.time(), ) else: - result = ( - run_circuits( - circuits, - self._backend, - qjob_config=self.qjob_config, - backend_options=self.backend_options, - noise_config=self._noise_config, - run_config=self._run_config.to_dict(), - job_callback=self._job_callback, - max_job_retries=self._max_job_retries, - ) - if circuit_job - else run_qobj( - qobj, - self._backend, - self._qjob_config, - self._backend_options, - self._noise_config, - self._skip_qobj_validation, - self._job_callback, - self._max_job_retries, - ) + result = run_circuits( + circuits, + self._backend, + qjob_config=self.qjob_config, + backend_options=self.backend_options, + noise_config=self._noise_config, + run_config=self._run_config.to_dict(), + job_callback=self._job_callback, + max_job_retries=self._max_job_retries, ) self._time_taken += result.time_taken @@ -797,28 +705,15 @@ def _find_save_state(data): result.results[n] = tmp_result.results[i] else: - result = ( - run_circuits( - circuits, - self._backend, - qjob_config=self.qjob_config, - backend_options=self.backend_options, - noise_config=self._noise_config, - run_config=self._run_config.to_dict(), - job_callback=self._job_callback, - max_job_retries=self._max_job_retries, - ) - if circuit_job - else run_qobj( - qobj, - self._backend, - self._qjob_config, - self._backend_options, - self._noise_config, - self._skip_qobj_validation, - self._job_callback, - self._max_job_retries, - ) + result = run_circuits( + circuits, + self._backend, + qjob_config=self.qjob_config, + backend_options=self.backend_options, + noise_config=self._noise_config, + run_config=self._run_config.to_dict(), + job_callback=self._job_callback, + max_job_retries=self._max_job_retries, ) self._time_taken += result.time_taken @@ -967,7 +862,7 @@ def measurement_error_mitigation_shots(self, new_value): # pylint: disable=inva @property def backend(self): - """Return BaseBackend backend object.""" + """Return Backend backend object.""" return self._backend @property diff --git a/qiskit/utils/run_circuits.py b/qiskit/utils/run_circuits.py index b037e856f548..27d3e5e3e27c 100644 --- a/qiskit/utils/run_circuits.py +++ b/qiskit/utils/run_circuits.py @@ -18,14 +18,11 @@ import time import copy import os -import uuid -import numpy as np from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister -from qiskit.providers import Backend, BaseBackend, JobStatus, JobError, BaseJob +from qiskit.providers import Backend, JobStatus, JobError, Job from qiskit.providers.jobstatus import JOB_FINAL_STATES from qiskit.result import Result -from qiskit.qobj import QasmQobj from ..exceptions import QiskitError, MissingOptionalLibraryError from .backend_utils import ( is_aer_provider, @@ -82,130 +79,7 @@ def _combine_result_objects(results: List[Result]) -> Result: return new_result -def _split_qobj_to_qobjs(qobj: QasmQobj, chunk_size: int) -> List[QasmQobj]: - qobjs = [] - num_chunks = int(np.ceil(len(qobj.experiments) / chunk_size)) - if num_chunks == 1: - qobjs = [qobj] - else: - if isinstance(qobj, QasmQobj): - qobj_template = QasmQobj( - qobj_id=qobj.qobj_id, config=qobj.config, experiments=[], header=qobj.header - ) - for i in range(num_chunks): - temp_qobj = copy.deepcopy(qobj_template) - temp_qobj.qobj_id = str(uuid.uuid4()) - temp_qobj.experiments = qobj.experiments[i * chunk_size : (i + 1) * chunk_size] - qobjs = _maybe_split_qobj_by_gates(qobjs, temp_qobj) - else: - raise QiskitError("Only support QasmQobj now.") - - return qobjs - - -def _maybe_split_qobj_by_gates(qobjs: List[QasmQobj], qobj: QasmQobj) -> List[QasmQobj]: - if MAX_GATES_PER_JOB is not None: - max_gates_per_job = int(MAX_GATES_PER_JOB) - total_num_gates = 0 - for experiment in qobj.experiments: - total_num_gates += len(experiment.instructions) - # split by gates if total number of gates in a qobj exceed MAX_GATES_PER_JOB - if total_num_gates > max_gates_per_job: - qobj_template = QasmQobj( - qobj_id=qobj.qobj_id, config=qobj.config, experiments=[], header=qobj.header - ) - temp_qobj = copy.deepcopy(qobj_template) - temp_qobj.qobj_id = str(uuid.uuid4()) - temp_qobj.experiments = [] - num_gates = 0 - for experiment in qobj.experiments: - num_gates += len(experiment.instructions) - if num_gates <= max_gates_per_job: - temp_qobj.experiments.append(experiment) - else: - qobjs.append(temp_qobj) - # Initialize for next temp_qobj - temp_qobj = copy.deepcopy(qobj_template) - temp_qobj.qobj_id = str(uuid.uuid4()) - temp_qobj.experiments.append(experiment) - num_gates = len(experiment.instructions) - - qobjs.append(temp_qobj) - else: - qobjs.append(qobj) - else: - qobjs.append(qobj) - - return qobjs - - -def _safe_submit_qobj( - qobj: QasmQobj, - backend: Union[Backend, BaseBackend], - backend_options: Dict, - noise_config: Dict, - skip_qobj_validation: bool, - max_job_retries: int, -) -> Tuple[BaseJob, str]: - # assure get job ids - for _ in range(max_job_retries): - try: - job = run_on_backend( - backend, - qobj, - backend_options=backend_options, - noise_config=noise_config, - skip_qobj_validation=skip_qobj_validation, - ) - job_id = job.job_id() - break - except QiskitError as ex: - failure_warn = True - if is_ibmq_provider(backend): - try: - from qiskit.providers.ibmq import IBMQBackendJobLimitError - except ImportError as ex1: - raise MissingOptionalLibraryError( - libname="qiskit-ibmq-provider", - name="_safe_submit_qobj", - pip_install="pip install qiskit-ibmq-provider", - ) from ex1 - if isinstance(ex, IBMQBackendJobLimitError): - - oldest_running = backend.jobs( - limit=1, descending=False, status=["QUEUED", "VALIDATING", "RUNNING"] - ) - if oldest_running: - oldest_running = oldest_running[0] - logger.warning( - "Job limit reached, waiting for job %s to finish " - "before submitting the next one.", - oldest_running.job_id(), - ) - failure_warn = False # Don't issue a second warning. - try: - oldest_running.wait_for_final_state(timeout=300) - except Exception: # pylint: disable=broad-except - # If the wait somehow fails or times out, we'll just re-try - # the job submit and see if it works now ( but a finite number of times ) - pass - if failure_warn: - logger.warning( - "FAILURE: Can not get job id, Resubmit the qobj to get job id. " - "Terra job error: %s ", - ex, - ) - except Exception as ex: # pylint: disable=broad-except - logger.warning( - "FAILURE: Can not get job id, Resubmit the qobj to get job id. Error: %s ", ex - ) - else: - raise QiskitError("Max retry limit reached. Could not submit the qobj correctly") - - return job, job_id - - -def _safe_get_job_status(job: BaseJob, job_id: str, max_job_retries: int, wait: float) -> JobStatus: +def _safe_get_job_status(job: Job, job_id: str, max_job_retries: int, wait: float) -> JobStatus: for _ in range(max_job_retries): try: job_status = job.status() @@ -227,225 +101,9 @@ def _safe_get_job_status(job: BaseJob, job_id: str, max_job_retries: int, wait: return job_status -def run_qobj( - qobj: QasmQobj, - backend: Union[Backend, BaseBackend], - qjob_config: Optional[Dict] = None, - backend_options: Optional[Dict] = None, - noise_config: Optional[Dict] = None, - skip_qobj_validation: bool = False, - job_callback: Optional[Callable] = None, - max_job_retries: int = 50, -) -> Result: - """ - An execution wrapper with Qiskit-Terra, with job auto recover capability. - - The auto-recovery feature is only applied for non-simulator backend. - This wrapper will try to get the result no matter how long it takes. - - Args: - qobj: qobj to execute - backend: backend instance - qjob_config: configuration for quantum job object - backend_options: configuration for simulator - noise_config: configuration for noise model - skip_qobj_validation: Bypass Qobj validation to decrease submission time, only works for Aer - and BasicAer providers - job_callback: callback used in querying info of the submitted job, and providing the - following arguments: job_id, job_status, queue_position, job - max_job_retries(int): positive non-zero number of trials for the job set (-1 for infinite - trials) (default: 50). - - Returns: - Result object - - Raises: - ValueError: invalid backend - QiskitError: Any error except for JobError raised by Qiskit Terra - """ - qjob_config = qjob_config or {} - backend_options = backend_options or {} - noise_config = noise_config or {} - - if backend is None or not isinstance(backend, (Backend, BaseBackend)): - raise ValueError("Backend is missing or not an instance of BaseBackend") - - with_autorecover = not is_simulator_backend(backend) - - if MAX_CIRCUITS_PER_JOB is not None: - max_circuits_per_job = int(MAX_CIRCUITS_PER_JOB) - else: - if is_local_backend(backend): - max_circuits_per_job = sys.maxsize - else: - backend_interface_version = _get_backend_interface_version(backend) - if backend_interface_version <= 1: - max_circuits_per_job = backend.configuration().max_experiments - else: - max_circuits_per_job = backend.max_circuits - - # split qobj if it exceeds the payload of the backend - - qobjs = _split_qobj_to_qobjs(qobj, max_circuits_per_job) - jobs = [] - job_ids = [] - for qob in qobjs: - job, job_id = _safe_submit_qobj( - qob, backend, backend_options, noise_config, skip_qobj_validation, max_job_retries - ) - job_ids.append(job_id) - jobs.append(job) - - results = [] - if with_autorecover: - logger.info("Backend status: %s", backend.status()) - logger.info("There are %s jobs are submitted.", len(jobs)) - logger.info("All job ids:\n%s", job_ids) - for idx, _ in enumerate(jobs): - job = jobs[idx] - job_id = job_ids[idx] - for _ in range(max_job_retries): - logger.info("Running %s-th qobj, job id: %s", idx, job_id) - # try to get result if possible - while True: - job_status = _safe_get_job_status( - job, job_id, max_job_retries, qjob_config["wait"] - ) - queue_position = 0 - if job_status in JOB_FINAL_STATES: - # do callback again after the job is in the final states - if job_callback is not None: - job_callback(job_id, job_status, queue_position, job) - break - if job_status == JobStatus.QUEUED: - queue_position = job.queue_position() - logger.info("Job id: %s is queued at position %s", job_id, queue_position) - else: - logger.info("Job id: %s, status: %s", job_id, job_status) - if job_callback is not None: - job_callback(job_id, job_status, queue_position, job) - time.sleep(qjob_config["wait"]) - - # get result after the status is DONE - if job_status == JobStatus.DONE: - for _ in range(max_job_retries): - result = job.result(**qjob_config) - if result.success: - results.append(result) - logger.info("COMPLETED the %s-th qobj, job id: %s", idx, job_id) - break - logger.warning("FAILURE: Job id: %s", job_id) - logger.warning( - "Job (%s) is completed anyway, retrieve result from backend again.", - job_id, - ) - job = backend.retrieve_job(job_id) - else: - raise QiskitError( - f"Max retry limit reached. Failed to get result for job id {job_id}" - ) - break - # for other cases, resubmit the qobj until the result is available. - # since if there is no result returned, there is no way algorithm can do any processing - # get back the qobj first to avoid for job is consumed - qobj = job.qobj() - if job_status == JobStatus.CANCELLED: - logger.warning("FAILURE: Job id: %s is cancelled. Re-submit the Qobj.", job_id) - elif job_status == JobStatus.ERROR: - logger.warning( - "FAILURE: Job id: %s encounters the error. " - "Error is : %s. Re-submit the Qobj.", - job_id, - job.error_message(), - ) - else: - logging.warning( - "FAILURE: Job id: %s. Unknown status: %s. Re-submit the Qobj.", - job_id, - job_status, - ) - job, job_id = _safe_submit_qobj( - qobj, - backend, - backend_options, - noise_config, - skip_qobj_validation, - max_job_retries, - ) - jobs[idx] = job - job_ids[idx] = job_id - else: - raise QiskitError( - f"Max retry limit reached. Failed to get result for job with id {job_id}." - ) - else: - results = [] - for job in jobs: - results.append(job.result(**qjob_config)) - - result = _combine_result_objects(results) if results else None - - # If result was not successful then raise an exception with either the status msg or - # extra information if this was an Aer partial result return - if not result.success: - msg = result.status - if result.status == "PARTIAL COMPLETED": - # Aer can return partial results which Aqua algorithms cannot process and signals - # using partial completed status where each returned result has a success and status. - # We use the status from the first result that was not successful - for res in result.results: - if not res.success: - msg += ", " + res.status - break - raise QiskitError(f"Circuit execution failed: {msg}") - - if not hasattr(result, "time_taken"): - setattr(result, "time_taken", 0.0) - - return result - - -# skip_qobj_validation = True does what backend.run -# and aerjob.submit do, but without qobj validation. -def run_on_backend( - backend: Union[Backend, BaseBackend], - qobj: QasmQobj, - backend_options: Optional[Dict] = None, - noise_config: Optional[Dict] = None, - skip_qobj_validation: bool = False, -) -> BaseJob: - """run on backend""" - if skip_qobj_validation: - if is_aer_provider(backend) or is_basicaer_provider(backend): - if backend_options is not None: - for option, value in backend_options.items(): - if option == "backend_options": - for key, val in value.items(): - setattr(qobj.config, key, val) - else: - setattr(qobj.config, option, value) - if ( - is_aer_provider(backend) - and noise_config is not None - and "noise_model" in noise_config - ): - qobj.config.noise_model = noise_config["noise_model"] - job = backend.run(qobj, validate=False) - else: - logger.info( - "Can't skip qobj validation for the %s provider.", - backend.provider().__class__.__name__, - ) - job = backend.run(qobj, **backend_options, **noise_config) - return job - else: - job = backend.run(qobj, **backend_options, **noise_config) - return job - - def run_circuits( circuits: Union[QuantumCircuit, List[QuantumCircuit]], - backend: Union[Backend, BaseBackend], + backend: Backend, qjob_config: Dict, backend_options: Optional[Dict] = None, noise_config: Optional[Dict] = None, @@ -647,13 +305,13 @@ def run_circuits( def _safe_submit_circuits( circuits: Union[QuantumCircuit, List[QuantumCircuit]], - backend: Union[Backend, BaseBackend], + backend: Backend, qjob_config: Dict, backend_options: Dict, noise_config: Dict, run_config: Dict, max_job_retries: int, -) -> Tuple[BaseJob, str]: +) -> Tuple[Job, str]: # assure get job ids for _ in range(max_job_retries): try: @@ -715,12 +373,12 @@ def _safe_submit_circuits( def _run_circuits_on_backend( - backend: Union[Backend, BaseBackend], + backend: Backend, circuits: Union[QuantumCircuit, List[QuantumCircuit]], backend_options: Dict, noise_config: Dict, run_config: Dict, -) -> BaseJob: +) -> Job: """run on backend""" run_kwargs = {} if is_aer_provider(backend) or is_basicaer_provider(backend): diff --git a/qiskit/visualization/gate_map.py b/qiskit/visualization/gate_map.py index e48f7d7df2f2..48044e7a04dd 100644 --- a/qiskit/visualization/gate_map.py +++ b/qiskit/visualization/gate_map.py @@ -27,10 +27,6 @@ def _get_backend_interface_version(backend): backend_interface_version = getattr(backend, "version", None) - # Handle deprecated BaseBackend based backends which have a version() - # method - if not isinstance(backend_interface_version, int): - backend_interface_version = 0 return backend_interface_version @@ -54,7 +50,7 @@ def plot_gate_map( """Plots the gate map of a device. Args: - backend (BaseBackend): The backend instance that will be used to plot the device + backend (Backend): The backend instance that will be used to plot the device gate map. figsize (tuple): Output figure size (wxh) in inches. plot_directed (bool): Plot directed coupling map. @@ -755,7 +751,7 @@ def plot_circuit_layout(circuit, backend, view="virtual", qubit_coordinates=None Args: circuit (QuantumCircuit): Input quantum circuit. - backend (BaseBackend): Target backend. + backend (Backend): Target backend. view (str): Layout view: either 'virtual' or 'physical'. qubit_coordinates (Sequence): An optional sequence input (list or array being the most common) of 2d coordinates for each qubit. The length of the diff --git a/qiskit/visualization/pulse_v2/device_info.py b/qiskit/visualization/pulse_v2/device_info.py index 69c9c24d57c3..1e809c43abd2 100644 --- a/qiskit/visualization/pulse_v2/device_info.py +++ b/qiskit/visualization/pulse_v2/device_info.py @@ -39,7 +39,8 @@ class :py:class:``DrawerBackendInfo`` with necessary methods to generate drawing from typing import Dict, List, Union, Optional from qiskit import pulse -from qiskit.providers import BaseBackend, BackendConfigurationError +from qiskit.providers import BackendConfigurationError +from qiskit.providers.backend import Backend class DrawerBackendInfo(ABC): @@ -67,7 +68,7 @@ def __init__( @classmethod @abstractmethod - def create_from_backend(cls, backend: BaseBackend): + def create_from_backend(cls, backend: Backend): """Initialize a class with backend information provided by provider. Args: @@ -96,7 +97,7 @@ class OpenPulseBackendInfo(DrawerBackendInfo): """Drawing information of backend that conforms to OpenPulse specification.""" @classmethod - def create_from_backend(cls, backend: BaseBackend): + def create_from_backend(cls, backend: Backend): """Initialize a class with backend information provided by provider. Args: diff --git a/qiskit/visualization/pulse_v2/interface.py b/qiskit/visualization/pulse_v2/interface.py index cd9b00478371..4978c404df93 100644 --- a/qiskit/visualization/pulse_v2/interface.py +++ b/qiskit/visualization/pulse_v2/interface.py @@ -23,7 +23,7 @@ from typing import Union, Optional, Dict, Any, Tuple, List -from qiskit.providers import BaseBackend +from qiskit.providers import Backend from qiskit.pulse import Waveform, ParametricPulse, Schedule, ScheduleBlock from qiskit.pulse.channels import Channel from qiskit.visualization.exceptions import VisualizationError @@ -34,7 +34,7 @@ def draw( program: Union[Waveform, ParametricPulse, Schedule, ScheduleBlock], style: Optional[Dict[str, Any]] = None, - backend: Optional[BaseBackend] = None, + backend: Optional[Backend] = None, time_range: Optional[Tuple[int, int]] = None, time_unit: str = types.TimeUnits.CYCLES.value, disable_channels: Optional[List[Channel]] = None, diff --git a/releasenotes/notes/remove-basebackend-7beac0abd17144fe.yaml b/releasenotes/notes/remove-basebackend-7beac0abd17144fe.yaml new file mode 100644 index 000000000000..8683624c4927 --- /dev/null +++ b/releasenotes/notes/remove-basebackend-7beac0abd17144fe.yaml @@ -0,0 +1,48 @@ +--- +upgrade: + - | + The previously deprecated ``BaseBackend``, ``BaseJob``, and ``BaseProvider`` + classes have all been removed. They were originally deprecated in the + 0.18.0 release. Instead of these classes you should be using the versioned + providers interface classes, the latest being :class:`~.BackendV2`, + :class:`~.JobV1`, and :class:`~.ProviderV1`. + - | + The previously deprecated ``backend`` argument for the constructor of the + :class:`~.RZXCalibrationBuilder` transpiler pass has been removed. It was + originally deprecated in the 0.19.0 release. Instead you should query + the :class:`~.Backend` object for the ``instruction_schedule_map`` and + ``qubit_channel_mapping`` and pass that directly to the constructor. For + example, with a :class:`~.BackendV1` backend:: + + from qiskit.transpiler.passes import RZXCalibrationBuilder + from qiskit.test.mock import FakeMumbai + + backend = FakeMumbai() + inst_map = backend.defaults().instruction_schedule_map + channel_map = self.backend.configuration().qubit_channel_mapping + cal_pass = RZXCalibrationBuilder( + instruction_schedule_map=inst_map, + qubit_channel_mapping=channel_map, + ) + + or with a :class:`~.BackendV2` backend:: + + from qiskit.transpiler.passes import RZXCalibrationBuilder + from qiskit.test.mock import FakeMumbaiV2 + + backend = FakeMumbaiV2() + inst_map = backend.instruction_schedule_map + channel_map = {bit: backend.drive_channel(bit) for bit in range(backend.num_qubits)} + cal_pass = RZXCalibrationBuilder( + instruction_schedule_map=inst_map, + qubit_channel_mapping=channel_map, + ) + +deprecations: + - | + The ``qobj_id`` and ``qobj_header`` keyword arguments for the + :func:`~.execute` function have been deprecated and will be removed in a + future release. Since the removal of the ``BaseBackend`` class these + arguments don't have any effect as no backend supports execution with a + :class:`~.Qobj` object directly and instead only work with + :class:`~.QuantumCircuit` objects directly. diff --git a/test/python/algorithms/test_aux_ops_evaluator.py b/test/python/algorithms/test_aux_ops_evaluator.py index 09baf37a44b7..f1727b88b19c 100644 --- a/test/python/algorithms/test_aux_ops_evaluator.py +++ b/test/python/algorithms/test_aux_ops_evaluator.py @@ -19,7 +19,7 @@ from ddt import ddt, data from qiskit.algorithms.list_or_dict import ListOrDict -from qiskit.providers import BaseBackend, Backend +from qiskit.providers import Backend from qiskit.quantum_info import Statevector from qiskit.algorithms import eval_observables from qiskit import BasicAer, QuantumCircuit @@ -83,7 +83,7 @@ def _run_test( decimal: int, expectation: ExpectationBase, observables: ListOrDict[OperatorBase], - quantum_instance: Union[QuantumInstance, BaseBackend, Backend], + quantum_instance: Union[QuantumInstance, Backend], ): result = eval_observables( quantum_instance, quantum_state, observables, expectation, self.threshold diff --git a/test/python/providers/test_base_backend.py b/test/python/providers/test_base_backend.py deleted file mode 100644 index bb41442e1904..000000000000 --- a/test/python/providers/test_base_backend.py +++ /dev/null @@ -1,41 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2019. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Test BaseBackend methods.""" - -from qiskit.test import QiskitTestCase -from qiskit.test.mock import FakeOpenPulse2Q, FakeMelbourne - - -class TestBackendAttrs(QiskitTestCase): - """Test the backend methods.""" - - def setUp(self): - super().setUp() - self.pulse_backend = FakeOpenPulse2Q() - self.backend = FakeMelbourne() - - def test_name(self): - """Test that name can be extracted.""" - self.assertEqual(self.pulse_backend.name(), "fake_openpulse_2q") - self.assertEqual(self.backend.name(), "fake_melbourne") - - def test_version(self): - """Test that name can be extracted.""" - self.assertEqual(self.pulse_backend.version, 1) - self.assertEqual(self.backend.version, 1) - - def test_str_and_repr(self): - """Test the custom __str__ and __repr__ methods.""" - self.assertEqual(str(self.pulse_backend), "fake_openpulse_2q") - self.assertEqual(str(self.backend), "fake_melbourne") - self.assertEqual(repr(self.pulse_backend), "") diff --git a/test/python/providers/test_fake_backends.py b/test/python/providers/test_fake_backends.py index 4e11de426d04..2cca28fc4a1f 100644 --- a/test/python/providers/test_fake_backends.py +++ b/test/python/providers/test_fake_backends.py @@ -24,12 +24,11 @@ from qiskit.exceptions import QiskitError from qiskit.execute_function import execute from qiskit.test.base import QiskitTestCase -from qiskit.test.mock import FakeProviderForBackendV2, FakeProvider, FakeLegacyProvider +from qiskit.test.mock import FakeProviderForBackendV2, FakeProvider from qiskit.utils import optionals FAKE_PROVIDER_FOR_BACKEND_V2 = FakeProviderForBackendV2() FAKE_PROVIDER = FakeProvider() -FAKE_LEGACY_PROVIDER = FakeLegacyProvider() @ddt @@ -89,31 +88,6 @@ def test_circuit_on_fake_backend(self, backend, optimization_level): max_count = max(counts.items(), key=operator.itemgetter(1))[0] self.assertEqual(max_count, "11") - @combine( - backend=[be for be in FAKE_LEGACY_PROVIDER.backends() if be.configuration().num_qubits > 1], - optimization_level=[0, 1, 2, 3], - dsc="Test execution path on {backend} with optimization level {optimization_level}", - name="{backend}_opt_level_{optimization_level}", - ) - def test_circuit_on_fake_legacy_backend(self, backend, optimization_level): - if not optionals.HAS_AER and backend.configuration().num_qubits > 20: - self.skipTest( - "Unable to run fake_backend %s without qiskit-aer" - % backend.configuration().backend_name - ) - with self.assertWarns(DeprecationWarning): - job = execute( - self.circuit, - backend, - optimization_level=optimization_level, - seed_simulator=42, - seed_transpiler=42, - ) - result = job.result() - counts = result.get_counts() - max_count = max(counts.items(), key=operator.itemgetter(1))[0] - self.assertEqual(max_count, "11") - def test_qobj_failure(self): backend = FAKE_PROVIDER.backends()[-1] tqc = transpile(self.circuit, backend)