Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/apidoc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Primitives and providers:
providers
providers_basic_provider
providers_fake_provider
providers_models

Results and visualizations:

Expand Down Expand Up @@ -83,5 +82,4 @@ Other:

compiler
exceptions
qobj
utils
6 changes: 0 additions & 6 deletions docs/apidoc/providers_models.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/apidoc/qobj.rst

This file was deleted.

50 changes: 12 additions & 38 deletions qiskit/compiler/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from qiskit.circuit.quantumcircuit import QuantumCircuit
from qiskit.dagcircuit import DAGCircuit
from qiskit.providers.backend import Backend
from qiskit.providers.backend_compat import BackendV2Converter
from qiskit.pulse import Schedule
from qiskit.transpiler import Layout, CouplingMap, PropertySet
from qiskit.transpiler.basepasses import BasePass
Expand Down Expand Up @@ -95,21 +94,20 @@ def transpile( # pylint: disable=too-many-return-statements
(``basis_gates``, ``coupling_map``, ``instruction_durations``,
``dt`` or ``timing_constraints``). If a ``backend`` is provided together with any loose constraint
from the list above, the loose constraint will take priority over the corresponding backend
constraint. This behavior is independent of whether the ``backend`` instance is of type
:class:`.BackendV1` or :class:`.BackendV2`, as summarized in the table below. The first column
constraint. This behavior is summarized in the table below. The first column
in the table summarizes the potential user-provided constraints, and each cell shows whether
the priority is assigned to that specific constraint input or another input
(`target`/`backend(V1)`/`backend(V2)`).

============================ ========= ======================== =======================
User Provided target backend(V1) backend(V2)
============================ ========= ======================== =======================
**basis_gates** target basis_gates basis_gates
**coupling_map** target coupling_map coupling_map
**instruction_durations** target instruction_durations instruction_durations
**dt** target dt dt
**timing_constraints** target timing_constraints timing_constraints
============================ ========= ======================== =======================
(`target`/`backend(V2)`).

============================ ========= ========================
User Provided target backend(V2)
============================ ========= ========================
**basis_gates** target basis_gates
**coupling_map** target coupling_map
**instruction_durations** target instruction_durations
**dt** target dt
**timing_constraints** target timing_constraints
============================ ========= ========================

Args:
circuits: Circuit(s) to transpile
Expand Down Expand Up @@ -320,30 +318,6 @@ def callback_func(**kwargs):
config = user_config.get_config()
optimization_level = config.get("transpile_optimization_level", 2)

if backend is not None and getattr(backend, "version", 0) <= 1:
warnings.warn(
"The `transpile` function will stop supporting inputs of "
f"type `BackendV1` ( {backend} ) in the `backend` parameter in a future "
"release no earlier than 2.0. `BackendV1` is deprecated and implementations "
"should move to `BackendV2`.",
category=DeprecationWarning,
stacklevel=2,
)
with warnings.catch_warnings():
# This is a temporary conversion step to allow for a smoother transition
# to a fully target-based transpiler pipeline while maintaining the behavior
# of `transpile` with BackendV1 inputs.
# TODO BackendV1 is deprecated and this path can be
# removed once it gets removed:
# https://github.com/Qiskit/qiskit/pull/12850
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
message=r".+qiskit\.providers\.backend_compat\.BackendV2Converter.+",
module="qiskit",
)
backend = BackendV2Converter(backend)

if (
scheduling_method is not None
and backend is None
Expand Down
18 changes: 6 additions & 12 deletions qiskit/primitives/backend_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from qiskit.circuit import ClassicalRegister, QuantumCircuit, QuantumRegister
from qiskit.compiler import transpile
from qiskit.exceptions import QiskitError
from qiskit.providers import BackendV1, BackendV2, Options
from qiskit.providers import BackendV2, Options
from qiskit.quantum_info import Pauli, PauliList
from qiskit.quantum_info.operators.base_operator import BaseOperator
from qiskit.result import Counts, Result
Expand All @@ -43,7 +43,7 @@

def _run_circuits(
circuits: QuantumCircuit | list[QuantumCircuit],
backend: BackendV1 | BackendV2,
backend: BackendV2,
clear_metadata: bool = True,
**run_options,
) -> tuple[list[Result], list[dict]]:
Expand All @@ -64,9 +64,7 @@ def _run_circuits(
metadata.append(circ.metadata)
if clear_metadata:
circ.metadata = {}
if isinstance(backend, BackendV1):
max_circuits = getattr(backend.configuration(), "max_experiments", None)
elif isinstance(backend, BackendV2):
if isinstance(backend, BackendV2):
max_circuits = backend.max_circuits
else:
raise RuntimeError("Backend version not supported")
Expand Down Expand Up @@ -96,7 +94,7 @@ class BackendEstimator(BaseEstimator[PrimitiveJob[EstimatorResult]]):

The :class:`~.BackendEstimator` class is a generic implementation of the
:class:`~.BaseEstimator` (V1) interface that is used to wrap a :class:`~.BackendV2`
(or :class:`~.BackendV1`) object in the :class:`~.BaseEstimator` V1 API. It
object in the :class:`~.BaseEstimator` V1 API. It
facilitates using backends that do not provide a native
:class:`~.BaseEstimator` V1 implementation in places that work with
:class:`~.BaseEstimator` V1.
Expand All @@ -117,7 +115,7 @@ class BackendEstimator(BaseEstimator[PrimitiveJob[EstimatorResult]]):
)
def __init__(
self,
backend: BackendV1 | BackendV2,
backend: BackendV2,
options: dict | None = None,
abelian_grouping: bool = True,
bound_pass_manager: PassManager | None = None,
Expand Down Expand Up @@ -195,7 +193,7 @@ def transpiled_circuits(self) -> list[QuantumCircuit]:
return self._transpiled_circuits

@property
def backend(self) -> BackendV1 | BackendV2:
def backend(self) -> BackendV2:
"""
Returns:
The backend which this estimator object based on
Expand Down Expand Up @@ -478,9 +476,5 @@ def _passmanager_for_measurement_circuits(layout, backend) -> PassManager:
coupling_map = backend.coupling_map
passmanager.append(FullAncillaAllocation(coupling_map))
passmanager.append(EnlargeWithAncilla())
elif isinstance(backend, BackendV1) and backend.configuration().coupling_map is not None:
coupling_map = CouplingMap(backend.configuration().coupling_map)
passmanager.append(FullAncillaAllocation(coupling_map))
passmanager.append(EnlargeWithAncilla())
passmanager.append(ApplyLayout())
return passmanager
8 changes: 4 additions & 4 deletions qiskit/primitives/backend_estimator_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from qiskit.circuit import ClassicalRegister, QuantumCircuit, QuantumRegister
from qiskit.exceptions import QiskitError
from qiskit.providers import BackendV1, BackendV2
from qiskit.providers import BackendV2
from qiskit.quantum_info import Pauli, PauliList
from qiskit.result import Counts
from qiskit.transpiler import PassManager, PassManagerConfig
Expand Down Expand Up @@ -76,7 +76,7 @@ class BackendEstimatorV2(BaseEstimatorV2):

The :class:`~.BackendEstimatorV2` class is a generic implementation of the
:class:`~.BaseEstimatorV2` interface that is used to wrap a :class:`~.BackendV2`
(or :class:`~.BackendV1`) object in the :class:`~.BaseEstimatorV2` API. It
object in the :class:`~.BaseEstimatorV2` API. It
facilitates using backends that do not provide a native
:class:`~.BaseEstimatorV2` implementation in places that work with
:class:`~.BaseEstimatorV2`. However,
Expand Down Expand Up @@ -127,7 +127,7 @@ class BackendEstimatorV2(BaseEstimatorV2):
def __init__(
self,
*,
backend: BackendV1 | BackendV2,
backend: BackendV2,
options: dict | None = None,
):
"""
Expand All @@ -153,7 +153,7 @@ def options(self) -> Options:
return self._options

@property
def backend(self) -> BackendV1 | BackendV2:
def backend(self) -> BackendV2:
"""Returns the backend which this sampler object based on."""
return self._backend

Expand Down
6 changes: 3 additions & 3 deletions qiskit/primitives/backend_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from typing import Any

from qiskit.circuit.quantumcircuit import QuantumCircuit
from qiskit.providers.backend import BackendV1, BackendV2
from qiskit.providers.backend import BackendV2
from qiskit.providers.options import Options
from qiskit.result import QuasiDistribution, Result
from qiskit.transpiler.passmanager import PassManager
Expand Down Expand Up @@ -57,7 +57,7 @@ class BackendSampler(BaseSampler[PrimitiveJob[SamplerResult]]):
)
def __init__(
self,
backend: BackendV1 | BackendV2,
backend: BackendV2,
options: dict | None = None,
bound_pass_manager: PassManager | None = None,
skip_transpilation: bool = False,
Expand Down Expand Up @@ -115,7 +115,7 @@ def transpiled_circuits(self) -> list[QuantumCircuit]:
return self._transpiled_circuits

@property
def backend(self) -> BackendV1 | BackendV2:
def backend(self) -> BackendV2:
"""
Returns:
The backend which this sampler object based on
Expand Down
8 changes: 4 additions & 4 deletions qiskit/primitives/backend_sampler_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from qiskit.primitives.containers.bit_array import _min_num_bytes
from qiskit.primitives.containers.sampler_pub import SamplerPub
from qiskit.primitives.primitive_job import PrimitiveJob
from qiskit.providers.backend import BackendV1, BackendV2
from qiskit.providers.backend import BackendV2
from qiskit.result import Result


Expand Down Expand Up @@ -83,7 +83,7 @@ class BackendSamplerV2(BaseSamplerV2):

The :class:`~.BackendSamplerV2` class is a generic implementation of the
:class:`~.BaseSamplerV2` interface that is used to wrap a :class:`~.BackendV2`
(or :class:`~.BackendV1`) object in the class :class:`~.BaseSamplerV2` API. It
object in the class :class:`~.BaseSamplerV2` API. It
facilitates using backends that do not provide a native
:class:`~.BaseSamplerV2` implementation in places that work with
:class:`~.BaseSamplerV2`. However,
Expand Down Expand Up @@ -119,7 +119,7 @@ class BackendSamplerV2(BaseSamplerV2):
def __init__(
self,
*,
backend: BackendV1 | BackendV2,
backend: BackendV2,
options: dict | None = None,
):
"""
Expand All @@ -132,7 +132,7 @@ def __init__(
self._options = Options(**options) if options else Options()

@property
def backend(self) -> BackendV1 | BackendV2:
def backend(self) -> BackendV2:
"""Returns the backend which this sampler object based on."""
return self._backend

Expand Down
Loading