Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename BasicAer to BasicProvider and refactor interface to follow BackendV2 #11422

Merged
merged 53 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
23ae8b2
Rename `BasicAer` to `BasicProvider`, rename `QasmSimulatorPy` to `Ba…
ElePT Dec 13, 2023
dd5e5ae
Migrate `BasicSimulator` interface from `BackendV1` to `BackendV2` (w…
ElePT Dec 14, 2023
a1a4045
Update missing references in qiskit/examples and tests
ElePT Dec 15, 2023
6baef9d
Update missing docstrings
ElePT Dec 15, 2023
5049669
Add future import
ElePT Dec 15, 2023
f88df57
Add type
ElePT Dec 15, 2023
aadb549
Fix lint
ElePT Dec 15, 2023
4d72a45
Merge branch 'main' into rename-basic-aer
ElePT Dec 18, 2023
253d844
Avoid rebuilding target/configuration when calling property
ElePT Dec 18, 2023
fc84c87
Merge branch 'rename-basic-aer' of https://github.com/ElePT/qiskit-te…
ElePT Dec 18, 2023
d3d2911
Merge branch 'main' of https://github.com/Qiskit/qiskit into rename-b…
ElePT Dec 18, 2023
04560c1
Update configuration
ElePT Dec 18, 2023
a36a6e6
Fix conflict
ElePT Jan 8, 2024
56ecc8d
Return methods to original order
ElePT Jan 9, 2024
b9f97bf
Merge branch 'main' into rename-basic-aer
ElePT Jan 9, 2024
084a00d
Restore template matching
ElePT Jan 9, 2024
7ae48fa
Merge branch 'rename-basic-aer' of https://github.com/ElePT/qiskit-te…
ElePT Jan 9, 2024
4f8ba72
Add support for target.num_qubits=None in transpiler pipeline. Set nu…
ElePT Jan 11, 2024
6ca23b3
Merge from main and fix conflicts
ElePT Jan 12, 2024
8525ddf
Small refactorings: apply Julien's suggestions, single out unitary ga…
ElePT Jan 15, 2024
9ba3225
Merge from main, fix conflicts
ElePT Jan 15, 2024
5effb80
Fix style
ElePT Jan 15, 2024
aae6003
Add release note
ElePT Jan 15, 2024
6bd130d
Apply inline suggestions from Julien's code review
ElePT Jan 16, 2024
111f101
Add suggestion from Julien's code review
ElePT Jan 16, 2024
dabc3a6
Merge branch 'rename-basic-aer' of https://github.com/ElePT/qiskit-te…
ElePT Jan 16, 2024
17fa381
Fix lint
ElePT Jan 16, 2024
ce67f8f
Fix docs, test
ElePT Jan 16, 2024
4aa2cb2
(Desperate) attempt to fix docs
ElePT Jan 16, 2024
555b1a6
Third attempt to fix docs
ElePT Jan 16, 2024
cdbcd30
Merge branch 'rename-basic-aer' of https://github.com/ElePT/qiskit-te…
ElePT Jan 16, 2024
3af8073
Merge from main, fix conflict
ElePT Jan 22, 2024
7a55777
Remove execute from basic simulator tests
ElePT Jan 22, 2024
bd923b2
Merge from main, fix conflicts
ElePT Jan 24, 2024
a4858eb
Fix conflicts
ElePT Jan 24, 2024
08805a1
Merge remove-execute, fix conflicts
ElePT Jan 24, 2024
e25ca42
Merge remove-execute, fix conflicts
ElePT Jan 24, 2024
64e02f8
Update example docstring
ElePT Jan 24, 2024
8a405eb
Apply suggestions from Matt's code review
ElePT Jan 24, 2024
0c5ea74
Remove BasicProvider global instance
ElePT Jan 25, 2024
2c8a0f2
Apply remaining review comments
ElePT Jan 25, 2024
1e48b13
Merge from main again, fix conflicts
ElePT Jan 25, 2024
4638396
Fix tests
ElePT Jan 25, 2024
580df52
Update reno
ElePT Jan 25, 2024
4efcbc2
Fix examples
ElePT Jan 25, 2024
83b45e3
Update np random generator
ElePT Jan 26, 2024
0c3c55e
Merge branch 'main' of https://github.com/Qiskit/qiskit into rename-b…
ElePT Jan 30, 2024
2bfc582
Use basic simulator instead of basicaer in GenericBackendV2
ElePT Jan 30, 2024
85addc3
Apply code review suggestions
ElePT Jan 30, 2024
7957585
Remove unused import
mtreinish Jan 30, 2024
d50a2f8
Update releasenotes/notes/refactor-basicaer-to-basicprovider-e27aff9c…
ElePT Jan 30, 2024
6f88d27
Update refactor-basicaer-to-basicprovider-e27aff9c8e81d26e.yaml
ElePT Jan 30, 2024
10514c5
Update refactor-basicaer-to-basicprovider-e27aff9c8e81d26e.yaml
ElePT Jan 30, 2024
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
8 changes: 4 additions & 4 deletions examples/python/ghz.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
# (C) Copyright IBM 2017, 2023.
#
# 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
Expand All @@ -15,7 +15,7 @@
"""

from qiskit import QuantumCircuit
from qiskit import BasicAer, execute
from qiskit import BasicProvider, execute


###############################################################
Expand All @@ -34,8 +34,8 @@
for i in range(num_qubits):
qc.measure(i, i)

sim_backend = BasicAer.get_backend("qasm_simulator")
sim_backend = BasicProvider.get_backend("basic_simulator")
job = execute(qc, sim_backend, shots=1024)
result = job.result()
print("Qasm simulator : ")
print("Basic simulator : ")
print(result.get_counts(qc))
6 changes: 3 additions & 3 deletions examples/python/initialize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
# (C) Copyright IBM 2017, 2023.
#
# 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
Expand All @@ -15,7 +15,7 @@
"""

import math
from qiskit import QuantumCircuit, execute, BasicAer
from qiskit import QuantumCircuit, execute, BasicProvider


###############################################################
Expand Down Expand Up @@ -58,7 +58,7 @@
print([format(abs(x * x), ".3f") for x in desired_vector])

# Initialize on local simulator
sim_backend = BasicAer.get_backend("qasm_simulator")
sim_backend = BasicProvider.get_backend("basic_simulator")
job = execute(circuit, sim_backend, shots=shots)
result = job.result()

Expand Down
6 changes: 3 additions & 3 deletions examples/python/load_qasm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
# (C) Copyright IBM 2017, 2023.
#
# 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
Expand All @@ -13,13 +13,13 @@
"""Example on how to load a file into a QuantumCircuit."""

from qiskit import QuantumCircuit
from qiskit import execute, BasicAer
from qiskit import execute, BasicProvider

circ = QuantumCircuit.from_qasm_file("examples/qasm/entangled_registers.qasm")
print(circ)

# See the backend
sim_backend = BasicAer.get_backend("qasm_simulator")
sim_backend = BasicProvider.get_backend("basic_simulator")


# Compile and run the Quantum circuit on a local simulator backend
Expand Down
6 changes: 3 additions & 3 deletions examples/python/qft.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import math
from qiskit import QuantumCircuit
from qiskit import execute, BasicAer
from qiskit import execute, BasicProvider


###############################################################
Expand Down Expand Up @@ -66,8 +66,8 @@ def qft(circ, n):
print(qft4)
print(qft5)

print("Qasm simulator")
sim_backend = BasicAer.get_backend("qasm_simulator")
print("Basic simulator")
sim_backend = BasicProvider.get_backend("basic_simulator")
job = execute([qft3, qft4, qft5], sim_backend, shots=1024)
result = job.result()
print(result.get_counts(qft3))
Expand Down
6 changes: 3 additions & 3 deletions examples/python/rippleadd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
# (C) Copyright IBM 2017, 2023.
#
# 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
Expand All @@ -16,13 +16,13 @@
"""

from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit import BasicAer
from qiskit import BasicProvider
from qiskit import execute

###############################################################
# Set the backend name and coupling map.
###############################################################
backend = BasicAer.get_backend("qasm_simulator")
backend = BasicProvider.get_backend("basic_simulator")
coupling_map = [
[0, 1],
[0, 8],
Expand Down
6 changes: 3 additions & 3 deletions examples/python/teleport.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
# (C) Copyright IBM 2017, 2023.
#
# 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
Expand All @@ -18,14 +18,14 @@
"""

from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit import BasicAer
from qiskit import BasicProvider
from qiskit import execute

###############################################################
# Set the backend name and coupling map.
###############################################################
coupling_map = [[0, 1], [0, 2], [1, 2], [3, 2], [3, 4], [4, 2]]
backend = BasicAer.get_backend("qasm_simulator")
backend = BasicProvider.get_backend("basic_simulator")

###############################################################
# Make a quantum program for quantum teleportation.
Expand Down
12 changes: 6 additions & 6 deletions examples/python/using_qiskit_terra_level_0.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
# (C) Copyright IBM 2017, 2023.
#
# 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
Expand All @@ -14,7 +14,7 @@
Example showing how to use Qiskit-Terra at level 0 (novice).

This example shows the most basic way to user Terra. It builds some circuits
and runs them on both the BasicAer (local Qiskit provider) or IBMQ (remote IBMQ provider).
and runs them on both the BasicProvider(local Qiskit provider).

To control the compile parameters we have provided a transpile function which can be used
as a level 1 user.
Expand All @@ -23,7 +23,7 @@

# Import the Qiskit modules
from qiskit import QuantumCircuit
from qiskit import execute, BasicAer
from qiskit import execute, BasicProvider

# making first circuit: bell state
qc1 = QuantumCircuit(2, 2)
Expand All @@ -37,11 +37,11 @@
qc2.measure([0, 1], [0, 1])

# setting up the backend
print("(BasicAER Backends)")
print(BasicAer.backends())
print("(BasicProvider Backends)")
print(BasicProvider.backends())

# running the job
job_sim = execute([qc1, qc2], BasicAer.get_backend("qasm_simulator"))
job_sim = execute([qc1, qc2], BasicProvider.get_backend("basic_simulator"))
sim_result = job_sim.result()

# Show the results
Expand Down
4 changes: 2 additions & 2 deletions qiskit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
import qiskit.circuit.reset

# Please note these are global instances, not modules.
from qiskit.providers.basicaer import BasicAer
from qiskit.providers.basic_provider import BasicProvider

_config = _user_config.get_config()

Expand Down Expand Up @@ -180,7 +180,7 @@ def __getattr__(self, attr):
__all__ = [
"Aer",
"AncillaRegister",
"BasicAer",
"BasicProvider",
"ClassicalRegister",
"IBMQ",
"MissingOptionalLibraryError",
Expand Down
8 changes: 4 additions & 4 deletions qiskit/circuit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
.. plot::
:include-source:

from qiskit import BasicAer, transpile, QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit import BasicProvider, transpile, QuantumRegister, ClassicalRegister, QuantumCircuit

qr = QuantumRegister(1)
cr = ClassicalRegister(1)
Expand All @@ -82,7 +82,7 @@

.. code-block::

backend = BasicAer.get_backend('qasm_simulator')
backend = BasicProvider.get_backend('basic_simulator')
tqc = transpile(qc, backend)
counts = backend.run(tqc).result().get_counts()

Expand All @@ -100,7 +100,7 @@
.. plot::
:include-source:

from qiskit import BasicAer, transpile, QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit import BasicProvider, transpile, QuantumRegister, ClassicalRegister, QuantumCircuit

qr = QuantumRegister(1)
cr = ClassicalRegister(1)
Expand All @@ -115,7 +115,7 @@

.. code-block::

backend = BasicAer.get_backend('qasm_simulator')
backend = BasicProvider.get_backend('basic_simulator')
tqc = transpile(qc, backend)
counts = backend.run(tqc).result().get_counts()

Expand Down
6 changes: 3 additions & 3 deletions qiskit/execute_function.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
# (C) Copyright IBM 2017, 2023.
#
# 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
Expand Down Expand Up @@ -253,9 +253,9 @@ def execute(

.. code-block::

from qiskit import QuantumCircuit, execute, BasicAer
from qiskit import QuantumCircuit, execute, BasicProvider

backend = BasicAer.get_backend('qasm_simulator')
backend = BasicProvider.get_backend('basic_simulator')

qc = QuantumCircuit(5, 5)
qc.h(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
# (C) Copyright IBM 2017, 2023.
#
# 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
Expand All @@ -12,19 +12,19 @@

"""
====================================================================
BasicAer: Python-based Simulators (:mod:`qiskit.providers.basicaer`)
BasicProvider: Python-based Simulators (:mod:`qiskit.providers.basic_provider`)
====================================================================

.. currentmodule:: qiskit.providers.basicaer
.. currentmodule:: qiskit.providers.basic_provider

A module of Python-based quantum simulators. Simulators are accessed
via the `BasicAer` provider, e.g.:
via the `BasicProvider` provider, e.g.:

.. code-block::

from qiskit import BasicAer
from qiskit import BasicProvider

backend = BasicAer.get_backend('qasm_simulator')
backend = BasicProvider.get_backend('basic_simulator')


Simulators
Expand All @@ -33,41 +33,38 @@
.. autosummary::
:toctree: ../stubs/

QasmSimulatorPy
StatevectorSimulatorPy
UnitarySimulatorPy
BasicSimulator

Provider
========

.. autosummary::
:toctree: ../stubs/

BasicAerProvider
BasicProvider

Job Class
=========

.. autosummary::
:toctree: ../stubs/

BasicAerJob
BasicProviderJob

Exceptions
==========

.. autosummary::
:toctree: ../stubs/

BasicAerError
BasicProviderError
"""

from .basicaerprovider import BasicAerProvider
from .basicaerjob import BasicAerJob
from .qasm_simulator import QasmSimulatorPy
from .statevector_simulator import StatevectorSimulatorPy
from .unitary_simulator import UnitarySimulatorPy
from .exceptions import BasicAerError
from .basic_provider import BasicProvider
from .basic_provider_job import BasicProviderJob
from .basic_simulator import BasicSimulator
from .exceptions import BasicProviderError

# Global instance to be used as the entry point for convenience.
BasicAer = BasicAerProvider()

BasicProvider = BasicProvider()
Loading
Loading