Skip to content

Commit

Permalink
Remove deprecated IBMQ dependent functionality (Qiskit#11513)
Browse files Browse the repository at this point in the history
* Remove deprecate IBMQ dependent functionality

This commit removes all the functionality in Qiskit that depended on the
legacy qiskit-ibmq-provider package. This process was started in Qiskit#10525
which removed the qiskit.IBMQ alias object but as was discovered in that
PR there were many other places in qiskit that were relying on the
qiskit-ibmq-provider package. This commit removes all of these places,
which primarily include qiskit.test.decorators's online_test decorator,
qiskit.tools.jupyter, qiskit.tools.monitor, qiskit.test.ibmq_mock, and
qiskit.test.mock (which just referenced IBMQ and didn't actually use
it). With these removals we're also no longer optionally dependent on
ipywidgets, jupyter, or ipython and those are removed from the optional
and development requirements lists.

* Remove stale api docs

* Remove ibmq usage in fake backend update script

* Preserve circuit library visualizations

* Remove apidocs from index

* Remove unused import

* Update docs
  • Loading branch information
mtreinish authored Jan 11, 2024
1 parent 4ce0049 commit 6bcb17b
Show file tree
Hide file tree
Showing 99 changed files with 105 additions and 4,917 deletions.
1 change: 0 additions & 1 deletion docs/apidoc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ API Reference
quantum_info
result
tools
tools_jupyter
transpiler
transpiler_passes
transpiler_preset
Expand Down
6 changes: 0 additions & 6 deletions docs/apidoc/tools_jupyter.rst

This file was deleted.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ qasm3-import = [
]
visualization = [
"matplotlib >= 3.3",
"ipywidgets >= 7.3.0",
"pydot",
"Pillow >= 4.2.1",
"pylatexenc >= 1.4",
Expand Down
53 changes: 0 additions & 53 deletions qiskit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@

_config = _user_config.get_config()

# Moved to after IBMQ and Aer imports due to import issues
# with other modules that check for IBMQ (tools)
from qiskit.execute_function import execute
from qiskit.compiler import transpile, assemble, schedule, sequence

Expand Down Expand Up @@ -125,64 +123,13 @@ def __getattr__(self, attr):
return getattr(self.aer, attr)


class IBMQWrapper:
"""Lazy loading wrapper for IBMQ provider."""

def __init__(self):
self.ibmq = None

def __bool__(self):
if self.ibmq is None:
try:
from qiskit.providers import ibmq

self.ibmq = ibmq.IBMQ
warnings.warn(
"The qiskit.IBMQ entrypoint and the qiskit-ibmq-provider package ("
"accessible from 'qiskit.providers.ibmq`) are deprecated and will be removed "
"in a future release. Instead you should use the qiskit-ibm-provider package "
"which is accessible from 'qiskit_ibm_provider'. You can install it with "
"'pip install qiskit_ibm_provider'",
DeprecationWarning,
stacklevel=2,
)

except ImportError:
return False
return True

def __getattr__(self, attr):
if not self.ibmq:
try:
from qiskit.providers import ibmq

self.ibmq = ibmq.IBMQ
warnings.warn(
"The qiskit.IBMQ entrypoint and the qiskit-ibmq-provider package ("
"accessible from 'qiskit.providers.ibmq`) are deprecated and will be removed "
"in a future release. Instead you should use the qiskit-ibm-provider package "
"which is accessible from 'qiskit_ibm_provider'. You can install it with "
"'pip install qiskit_ibm_provider'. Just replace 'qiskit.IBMQ' with "
"'qiskit_ibm_provider.IBMProvider'",
DeprecationWarning,
stacklevel=2,
)
except ImportError as ex:
raise MissingOptionalLibraryError(
"qiskit-ibmq-provider", "IBMQ provider", "pip install qiskit-ibmq-provider"
) from ex
return getattr(self.ibmq, attr)


Aer = AerWrapper()
IBMQ = IBMQWrapper()

__all__ = [
"Aer",
"AncillaRegister",
"BasicAer",
"ClassicalRegister",
"IBMQ",
"MissingOptionalLibraryError",
"QiskitError",
"QuantumCircuit",
Expand Down
6 changes: 3 additions & 3 deletions qiskit/circuit/library/basis_change/qft.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class QFT(BlueprintCircuit):
.. plot::
from qiskit.circuit.library import QFT
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
circuit = QFT(4)
_generate_circuit_library_visualization(circuit)
Expand All @@ -51,7 +51,7 @@ class QFT(BlueprintCircuit):
.. plot::
from qiskit.circuit.library import QFT
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
circuit = QFT(4).inverse()
_generate_circuit_library_visualization(circuit)
Expand All @@ -67,7 +67,7 @@ class QFT(BlueprintCircuit):
.. plot::
from qiskit.circuit.library import QFT
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
circuit = QFT(5, approximation_degree=2)
_generate_circuit_library_visualization(circuit)
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/boolean_logic/inner_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class InnerProduct(QuantumCircuit):
.. plot::
from qiskit.circuit.library import InnerProduct
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
circuit = InnerProduct(4)
_generate_circuit_library_visualization(circuit)
"""
Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/library/boolean_logic/quantum_and.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AND(QuantumCircuit):
.. plot::
from qiskit.circuit.library import AND
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
circuit = AND(5)
_generate_circuit_library_visualization(circuit)
Expand All @@ -43,7 +43,7 @@ class AND(QuantumCircuit):
.. plot::
from qiskit.circuit.library import AND
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
circuit = AND(5, flags=[-1, 0, 0, 1, 1])
_generate_circuit_library_visualization(circuit)
Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/library/boolean_logic/quantum_or.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class OR(QuantumCircuit):
.. plot::
from qiskit.circuit.library import OR
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
circuit = OR(5)
_generate_circuit_library_visualization(circuit)
Expand All @@ -44,7 +44,7 @@ class OR(QuantumCircuit):
.. plot::
from qiskit.circuit.library import OR
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
circuit = OR(5, flags=[-1, 0, 0, 1, 1])
_generate_circuit_library_visualization(circuit)
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/boolean_logic/quantum_xor.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(
.. plot::
from qiskit.circuit.library import XOR
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
circuit = XOR(5, seed=42)
_generate_circuit_library_visualization(circuit)
"""
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/fourier_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, f: List[int], g: List[int]) -> None:
.. plot::
from qiskit.circuit.library import FourierChecking
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
f = [1, -1, -1, -1]
g = [1, 1, -1, -1]
circuit = FourierChecking(f, g)
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/generalized_gates/gms.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class GMS(QuantumCircuit):
.. plot::
from qiskit.circuit.library import GMS
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
import numpy as np
circuit = GMS(num_qubits=3, theta=[[0, np.pi/4, np.pi/8],
[0, 0, np.pi/2],
Expand Down
8 changes: 4 additions & 4 deletions qiskit/circuit/library/generalized_gates/gr.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GR(QuantumCircuit):
.. plot::
from qiskit.circuit.library import GR
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
import numpy as np
circuit = GR(num_qubits=3, theta=np.pi/4, phi=np.pi/2)
_generate_circuit_library_visualization(circuit)
Expand Down Expand Up @@ -101,7 +101,7 @@ class GRX(GR):
.. plot::
from qiskit.circuit.library import GRX
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
import numpy as np
circuit = GRX(num_qubits=3, theta=np.pi/4)
_generate_circuit_library_visualization(circuit)
Expand Down Expand Up @@ -149,7 +149,7 @@ class GRY(GR):
.. plot::
from qiskit.circuit.library import GRY
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
import numpy as np
circuit = GRY(num_qubits=3, theta=np.pi/4)
_generate_circuit_library_visualization(circuit)
Expand Down Expand Up @@ -197,7 +197,7 @@ class GRZ(QuantumCircuit):
.. plot::
from qiskit.circuit.library import GRZ
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
import numpy as np
circuit = GRZ(num_qubits=3, phi=np.pi/2)
_generate_circuit_library_visualization(circuit)
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/generalized_gates/mcmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class MCMTVChain(MCMT):
.. plot::
from qiskit.circuit.library import MCMTVChain, ZGate
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
circuit = MCMTVChain(ZGate(), 2, 2)
_generate_circuit_library_visualization(circuit.decompose())
Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/library/generalized_gates/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(
.. plot::
from qiskit.circuit.library import Permutation
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
A = [2,4,3,0,1]
circuit = Permutation(5, A)
_generate_circuit_library_visualization(circuit.decompose())
Expand Down Expand Up @@ -130,7 +130,7 @@ def __init__(
from qiskit.circuit.quantumcircuit import QuantumCircuit
from qiskit.circuit.library import PermutationGate
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
A = [2,4,3,0,1]
permutation = PermutationGate(A)
circuit = QuantumCircuit(5)
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/graph_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class GraphState(QuantumCircuit):
.. plot::
from qiskit.circuit.library import GraphState
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
import rustworkx as rx
G = rx.generators.cycle_graph(5)
circuit = GraphState(rx.adjacency_matrix(G))
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/hidden_linear_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class HiddenLinearFunction(QuantumCircuit):
.. plot::
from qiskit.circuit.library import HiddenLinearFunction
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
A = [[1, 1, 0], [1, 0, 1], [0, 1, 1]]
circuit = HiddenLinearFunction(A)
_generate_circuit_library_visualization(circuit)
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/iqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class IQP(QuantumCircuit):
.. plot::
from qiskit.circuit.library import IQP
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
A = [[6, 5, 3], [5, 4, 5], [3, 5, 1]]
circuit = IQP(A)
_generate_circuit_library_visualization(circuit.decompose())
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/phase_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
from qiskit.circuit import QuantumCircuit
from qiskit.circuit.library import PhaseEstimation
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
unitary = QuantumCircuit(2)
unitary.x(0)
unitary.y(1)
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/quantum_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class QuantumVolume(QuantumCircuit):
.. plot::
from qiskit.circuit.library import QuantumVolume
from qiskit.tools.jupyter.library import _generate_circuit_library_visualization
from qiskit.visualization.library import _generate_circuit_library_visualization
circuit = QuantumVolume(5, 6, seed=10, classical_permutation=False)
_generate_circuit_library_visualization(circuit.decompose())
Expand Down
11 changes: 5 additions & 6 deletions qiskit/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,12 @@ def get_translation_stage_plugin(self):
handles submitting the circuits to the backend to be executed and returning a
:class:`~qiskit.providers.Job` object. Depending on the type of backend this
typically involves serializing the circuit object into the API format used by a
backend. For example, on IBMQ backends from the ``qiskit-ibmq-provider``
backend. For example, on IBM backends from the ``qiskit-ibm-provider``
package this involves converting from a quantum circuit and options into a
`qobj <https://arxiv.org/abs/1809.03452>`__ JSON payload and submitting
that to the IBM Quantum API. Since every backend interface is different (and
in the case of the local simulators serialization may not be needed) it is
expected that the backend's :obj:`~qiskit.providers.BackendV2.run` method will
handle this conversion.
:mod:`.qpy` payload embedded in JSON and submitting that to the IBM Quantum
API. Since every backend interface is different (and in the case of the local
simulators serialization may not be needed) it is expected that the backend's
:obj:`~qiskit.providers.BackendV2.run` method will handle this conversion.
An example run method would be something like::
Expand Down
17 changes: 2 additions & 15 deletions qiskit/providers/fake_provider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,8 @@
Please note that the simulation is done using a noise model generated from system snapshots
obtained in the past (sometimes a few years ago) and the results are not representative of the
latest behaviours of the real quantum system which the fake backend is mimicking. If you want to
run noisy simulations to compare with the real quantum system, please follow steps below to
generate a simulator mimics a real quantum system with the latest calibration results.
.. code-block:: python
from qiskit.providers.ibmq import IBMQ
from qiskit.providers.aer import AerSimulator
# get a real backend from a real provider
provider = IBMQ.load_account()
backend = provider.get_backend('ibmq_manila')
# generate a simulator that mimics the real quantum system with the latest calibration results
backend_sim = AerSimulator.from_backend(backend)
run noisy simulations to compare with the real quantum system you will need to create a noise
model from the current properties of the backend manually.
Fake Providers
==============
Expand Down
2 changes: 1 addition & 1 deletion qiskit/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"""Functionality and helpers for testing Qiskit."""

from .base import QiskitTestCase
from .decorators import requires_aer_provider, online_test, slow_test
from .decorators import requires_aer_provider, slow_test
from .reference_circuits import ReferenceCircuits
from .utils import Path
2 changes: 0 additions & 2 deletions qiskit/test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ def tearDown(self):
@classmethod
def setUpClass(cls):
super().setUpClass()
# Determines if the TestCase is using IBMQ credentials.
cls.using_ibmq_credentials = False
# Set logging to file and stdout if the LOG_LEVEL envar is set.
cls.log = logging.getLogger(cls.__name__)
if os.getenv("LOG_LEVEL"):
Expand Down
Loading

0 comments on commit 6bcb17b

Please sign in to comment.