Skip to content

Commit

Permalink
Move Aer to it's own package version 2
Browse files Browse the repository at this point in the history
Namespace packages are constant source of problems for users. The python
packaging ecosystem around splitting packages across namespaces is
fragile at the best of times and can often leave a you with an
environment that isn't recoverable (especially when mixing install
methods). There is also a performance hit whenever there is a piece of
the namespace we allow external packages to extend since it requires
doing a full python path search which can be slow depending on the
backing I/O and the number of paths in sys.path for an environment. This
commit addresses the piece from the aer perspective by moving
qiskit.providers.aer to it's own package and namespace 'qiskit_aer'.

This is coupled with a custom namespace module that implements a
custom import loader at the root of the namespace. This has 2 advantages
it removes the use of namespace packages so the fragility and
performance impact are fixed since every element will be renamed to use
'qiskit_' instead of 'qiskit.' (aer being the only one remaining).

This is the second attempt at doing this namespace rename, the first
failed attempt in Qiskit#840 was trying to migrate all the former qiskit
elements at the same time and was too difficult to migrate everything at
once without causing breaking api changes. This commit is mechanically
the same (renaming qiskit.providers.aer -> qiskit_aer), but how it
integrates with qiskit-terra is changed. With Qiskit/qiskit#5089
qiskit-terra, the
package which owns the 'qiskit.*' namespace, adds a metaimporter that
will redirect imports from qiskit.providers.aer to qiskit_aer. This
means before we can merge this commit Qiskit/qiskit#5089 will need
to be released first to ensure that for backwards compatibility existing
users will be able to access aer from the old namespace.

Fixes Qiskit/qiskit#559
  • Loading branch information
mtreinish committed Jun 14, 2022
1 parent 1d87bcc commit 5eeb0c7
Show file tree
Hide file tree
Showing 164 changed files with 231 additions and 239 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ jobs:
- name: Run Lint
run: |
set -e
pycodestyle --ignore=E402,W504 --max-line-length=100 qiskit/providers/aer
pylint -j 2 -rn qiskit/providers/aer
pycodestyle --ignore=E402,W504 --max-line-length=100 qiskit_aer
pylint -j 2 -rn qiskit_aer
sdist:
runs-on: ${{ matrix.platform.os }}
needs: ["lint"]
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rhs*_op.pyx
*.whl
*.egg*
build/*
qiskit/providers/aer/backends/libomp.dylib
*libomp.dylib

# Ignore macOS DS_Store
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ ignore-mixin-members=yes
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=matplotlib.cm,numpy.random
ignored-modules=matplotlib.cm,numpy.random,qiskit.providers

# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# be linked statically per Apple's indications.

cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
file(STRINGS "qiskit/providers/aer/VERSION.txt" VERSION_NUM)
file(STRINGS "qiskit_aer/VERSION.txt" VERSION_NUM)

include(CheckLanguage)
project(qasm_simulator VERSION ${VERSION_NUM} LANGUAGES CXX C)
Expand Down Expand Up @@ -327,7 +327,7 @@ set(AER_LIBRARIES
set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} ${CONAN_DEFINES})
if(SKBUILD) # Terra Addon build
set(AER_LIBRARIES ${AER_LIBRARIES} AER_DEPENDENCY_PKG::muparserx)
add_subdirectory(qiskit/providers/aer/backends/wrappers)
add_subdirectory(qiskit_aer/backends/wrappers)
add_subdirectory(src/open_pulse)
else() # Standalone build

Expand Down
20 changes: 10 additions & 10 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
include MANIFEST.in
include README.md
include pyproject.toml
recursive-include qiskit *pyx
recursive-include qiskit *pxd
recursive-include qiskit *.pxi
recursive-include qiskit *cpp
recursive-include qiskit *hpp
recursive-include qiskit_aer *pyx
recursive-include qiskit_aer *pxd
recursive-include qiskit_aer *.pxi
recursive-include qiskit_aer *cpp
recursive-include qiskit_aer *hpp
graft src
graft contrib
include qiskit/providers/aer/backends/wrappers/CMakeLists.txt
include qiskit/providers/aer/backends/wrappers/bindings.cc
include qiskit/providers/aer/pulse/qutip_extra_lite/cy/CMakeLists.txt
include qiskit/providers/aer/VERSION.txt
include qiskit/providers/aer/library/instructions_table.csv
include qiskit_aer/backends/wrappers/CMakeLists.txt
include qiskit_aer/backends/wrappers/bindings.cc
include qiskit_aer/pulse/qutip_extra_lite/cy/CMakeLists.txt
include qiskit_aer/VERSION.txt
include qiskit_aer/library/instructions_table.csv
include CMakeLists.txt
include cmake/*.cmake
# Exclude static libraries (they are all compressed with 7z)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $ python
```python
import qiskit
from qiskit import IBMQ
from qiskit.providers.aer import AerSimulator
from qiskit_aer import AerSimulator

# Generate 3-qubit GHZ state
circ = qiskit.QuantumCircuit(3)
Expand Down
4 changes: 2 additions & 2 deletions docs/apidocs/aer_extensions.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _aer-circuit-extensions:

.. automodule:: qiskit.providers.aer.extensions
.. automodule:: qiskit_aer.extensions
:no-members:
:no-inherited-members:
:no-special-members:
:no-special-members:
2 changes: 1 addition & 1 deletion docs/apidocs/aer_jobs.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _aer-jobs:

.. automodule:: qiskit.providers.aer.jobs
.. automodule:: qiskit_aer.jobs
:no-members:
:no-inherited-members:
:no-special-members:
4 changes: 2 additions & 2 deletions docs/apidocs/aer_library.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _aer-library:

.. automodule:: qiskit.providers.aer.library
.. automodule:: qiskit_aer.library
:no-members:
:no-inherited-members:
:no-special-members:
:no-special-members:
4 changes: 2 additions & 2 deletions docs/apidocs/aer_noise.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _aer-noise:

.. automodule:: qiskit.providers.aer.noise
.. automodule:: qiskit_aer.noise
:no-members:
:no-inherited-members:
:no-special-members:
:no-special-members:
4 changes: 2 additions & 2 deletions docs/apidocs/aer_provider.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _aer-provider:

.. automodule:: qiskit.providers.aer
.. automodule:: qiskit_aer
:no-members:
:no-inherited-members:
:no-special-members:
:no-special-members:
4 changes: 2 additions & 2 deletions docs/apidocs/aer_pulse.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _aer-pulse:

.. automodule:: qiskit.providers.aer.pulse
.. automodule:: qiskit_aer.pulse
:no-members:
:no-inherited-members:
:no-special-members:
:no-special-members:
4 changes: 2 additions & 2 deletions docs/apidocs/aer_utils.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _aer-utils:

.. automodule:: qiskit.providers.aer.utils
.. automodule:: qiskit_aer.utils
:no-members:
:no-inherited-members:
:no-special-members:
:no-special-members:
4 changes: 2 additions & 2 deletions docs/apidocs/parallel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Example: Threadpool execution
import qiskit
from concurrent.futures import ThreadPoolExecutor
from qiskit.providers.aer import AerSimulator
from qiskit_aer import AerSimulator
from math import pi
# Generate circuit
Expand Down Expand Up @@ -78,7 +78,7 @@ guard it by an ``if __name__ == "__main__":`` block.
.. code-block:: python
import qiskit
from qiskit.providers.aer import AerSimulator
from qiskit_aer import AerSimulator
from dask.distributed import LocalCluster, Client
from math import pi
def q_exec():
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
# (e.g., if this is set to ['foo.'], then foo.bar is shown under B, not F).
# This can be handy if you document a project that consists of a single
# package. Works only for the HTML builder currently.
modindex_common_prefix = ['qiskit.providers']
modindex_common_prefix = ['qiskit_aer']

# -- Configuration for extlinks extension ------------------------------------
# Refer to https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions qiskit/providers/aer/__init__.py → qiskit_aer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

"""
==========================================
Aer Provider (:mod:`qiskit.providers.aer`)
Aer Provider (:mod:`qiskit_aer`)
==========================================
.. currentmodule:: qiskit.providers.aer
.. currentmodule:: qiskit_aer
Simulator Provider
==================
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class AerSimulator(AerBackend):
The final state of the simulator can be saved to the returned
``Result`` object by appending the
:func:`~qiskit.providers.aer.library.save_state` instruction to a
:func:`~qiskit_aer.library.save_state` instruction to a
quantum circuit. The format of the final state will depend on the
simulation method used. Additional simulation data may also be saved
using the other save instructions in :mod:`qiskit.provider.aer.library`.
Expand Down Expand Up @@ -296,7 +296,7 @@ class AerSimulator(AerBackend):
* ``stabilizer_max_snapshot_probabilities`` (int): set the maximum
qubit number for the
`~qiskit.providers.aer.extensions.SnapshotProbabilities`
`~qiskit_aer.extensions.SnapshotProbabilities`
instruction (Default: 32).
These backend options only apply when using the ``"extended_stabilizer"``
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ class PulseSimulator(AerBackend):
The ``PulseSimulator`` simulates continuous time Hamiltonian dynamics of a quantum system,
with controls specified by pulse :class:`~qiskit.Schedule` objects, and the model of the
physical system specified by :class:`~qiskit.providers.aer.pulse.PulseSystemModel` objects.
physical system specified by :class:`~qiskit_aer.pulse.PulseSystemModel` objects.
Results are returned in the same format as when jobs are submitted to actual devices.
**Examples**
The minimal information a ``PulseSimulator`` needs to simulate is a
:class:`~qiskit.providers.aer.pulse.PulseSystemModel`, which can be supplied either by
:class:`~qiskit_aer.pulse.PulseSystemModel`, which can be supplied either by
setting the backend option before calling ``run``, e.g.:
.. code-block:: python
backend_sim = qiskit.providers.aer.PulseSimulator()
backend_sim = qiskit_aer.PulseSimulator()
# Set the pulse system model for the simulator
backend_sim.set_options(system_model=system_model)
Expand All @@ -85,7 +85,7 @@ class PulseSimulator(AerBackend):
.. code-block:: python
backend_sim = qiskit.providers.aer.PulseSimulator()
backend_sim = qiskit_aer.PulseSimulator()
# Assemble schedules using PulseSimulator as the backend
pulse_qobj = assemble(schedules, backend=backend_sim)
Expand All @@ -99,21 +99,21 @@ class PulseSimulator(AerBackend):
.. code-block:: python
armonk_sim = qiskit.providers.aer.PulseSimulator.from_backend(FakeArmonk())
armonk_sim = qiskit_aer.PulseSimulator.from_backend(FakeArmonk())
pulse_qobj = assemble(schedules, backend=armonk_sim)
armonk_sim.run(pulse_qobj)
In the above example, the ``PulseSimulator`` copies all configuration and default data from
``FakeArmonk()``, and as such has the same affect as ``FakeArmonk()`` when passed as an
argument to ``assemble``. Furthermore it constructs a
:class:`~qiskit.providers.aer.pulse.PulseSystemModel` from the model details in the supplied
:class:`~qiskit_aer.pulse.PulseSystemModel` from the model details in the supplied
backend, which is then used in simulation.
**Supported PulseQobj parameters**
* ``qubit_lo_freq``: Local oscillator frequencies for each :class:`DriveChannel`.
Defaults to either the value given in the
:class:`~qiskit.providers.aer.pulse.PulseSystemModel`, or is calculated directly
:class:`~qiskit_aer.pulse.PulseSystemModel`, or is calculated directly
from the Hamiltonian.
* ``meas_level``: Type of desired measurement output, in ``[1, 2]``.
``1`` gives complex numbers (IQ values), and ``2`` gives discriminated states ``|0>`` and
Expand All @@ -138,7 +138,7 @@ class PulseSimulator(AerBackend):
The simulator uses the ``zvode`` differential equation solver method through ``scipy``.
Simulation is performed in the rotating frame of the diagonal of the drift Hamiltonian
contained in the :class:`~qiskit.providers.aer.pulse.PulseSystemModel`. Measurements
contained in the :class:`~qiskit_aer.pulse.PulseSystemModel`. Measurements
are performed in the `dressed basis` of the drift Hamiltonian.
**Other options**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class QasmSimulator(AerBackend):
* ``stabilizer_max_snapshot_probabilities`` (int): set the maximum
qubit number for the
`~qiskit.providers.aer.extensions.SnapshotProbabilities`
`~qiskit_aer.extensions.SnapshotProbabilities`
instruction (Default: 32).
These backend options only apply when using the ``"extended_stabilizer"``
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ target_include_directories(controller_wrappers PRIVATE ${AER_SIMULATOR_CPP_SRC_D
PRIVATE ${AER_SIMULATOR_CPP_EXTERNAL_LIBS})
target_link_libraries(controller_wrappers ${AER_LIBRARIES})
target_compile_definitions(controller_wrappers PRIVATE ${AER_COMPILER_DEFINITIONS})
install(TARGETS controller_wrappers LIBRARY DESTINATION qiskit/providers/aer/backends)
install(TARGETS controller_wrappers LIBRARY DESTINATION qiskit_aer/backends)

# Install redistributable dependencies
install(FILES ${BACKEND_REDIST_DEPS} DESTINATION qiskit/providers/aer/backends)
install(FILES ${BACKEND_REDIST_DEPS} DESTINATION qiskit_aer/backends)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

"""
===========================================================
Circuit Extensions (:mod:`qiskit.providers.aer.extensions`)
Circuit Extensions (:mod:`qiskit_aer.extensions`)
===========================================================
.. currentmodule:: qiskit.providers.aer.extensions
.. currentmodule:: qiskit_aer.extensions
Snapshots
=========
Expand All @@ -25,7 +25,7 @@
Adding nonlocal noise to a noise model is deprecated as of qiskit-aer
0.9.0 and will be removed no earlier than 3 months from that release date.
They have been superceded by the save instructions in the
:mod:`qiskit.providers.aer.library` module.
:mod:`qiskit_aer.library` module.
Snapshot instructions allow taking a snapshot of the current state of the
simulator without effecting the outcome of the simulation. These can be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self,
This instruction has been deprecated and will be removed no earlier
than 3 months from the 0.9.0 release date. It has been superseded by
the save instructions in
:mod:`qiskit.providers.aer.library` module.
:mod:`qiskit_aer.library` module.
"""
warn('The `Snapshot` instruction will be deprecated in the'
' future. It has been superseded by the `SaveStatevector`'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, label, num_qubits):
This instruction has been deprecated and will be removed no earlier
than 3 months from the 0.9.0 release date. It has been superseded by the
:class:`qiskit.providers.aer.library.SaveDensityMatrix` instruction.
:class:`qiskit_aer.library.SaveDensityMatrix` instruction.
"""
warn('The `SnapshotDensityMatrix` instruction has been deprecated as of'
' qiskit-aer 0.9. It has been superseded by the `SaveDensityMatrix`'
Expand Down Expand Up @@ -64,7 +64,7 @@ def snapshot_density_matrix(self, label, qubits=None):
This instruction has been deprecated and will be removed no earlier
than 3 months from the 0.9.0 release date. It has been superseded by the
:class:`qiskit.providers.aer.library.save_density_matrix`
:class:`qiskit_aer.library.save_density_matrix`
circuit method.
"""
warn('The `snapshot_density_matrix` circuit method has been deprecated as of'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def __init__(self, label, op, single_shot=False, variance=False):
This instruction has been deprecated and will be removed no earlier
than 3 months from the 0.9.0 release date. It has been superseded by the
:class:`qiskit.providers.aer.library.SaveExpectationValue` and
:class:`qiskit.providers.aer.library.SaveExpectationValueVariance`
:class:`qiskit_aer.library.SaveExpectationValue` and
:class:`qiskit_aer.library.SaveExpectationValueVariance`
instructions.
"""
warn('The `SnapshotExpectationValue` instruction has been deprecated as of'
Expand Down Expand Up @@ -152,8 +152,8 @@ def snapshot_expectation_value(self, label, op, qubits,
This instruction has been deprecated and will be removed no earlier
than 3 months from the 0.9.0 release date. It has been superseded by the
:func:`qiskit.providers.aer.library.save_expectation_value` and
:func:`qiskit.providers.aer.library.save_expectation_value_variance`
:func:`qiskit_aer.library.save_expectation_value` and
:func:`qiskit_aer.library.save_expectation_value_variance`
circuit methods.
"""
warn('The `snapshot_expectation_value` circuit method has been deprecated as of'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def __init__(self, label, num_qubits, variance=False):
This instruction has been deprecated and will be removed no earlier
than 3 months from the 0.9.0 release date. It has been superseded by the
:class:`qiskit.providers.aer.library.SaveProbabilities` and
:class:`qiskit.providers.aer.library.SaveProbabilitiesDict`
:class:`qiskit_aer.library.SaveProbabilities` and
:class:`qiskit_aer.library.SaveProbabilitiesDict`
instructions.
"""
warn('The `SnapshotProbabilities` instruction has been deprecated as of'
Expand Down Expand Up @@ -69,8 +69,8 @@ def snapshot_probabilities(self, label, qubits, variance=False):
This instruction has been deprecated and will be removed no earlier
than 3 months from the 0.9.0 release date. It has been superseded by the
:func:`qiskit.providers.aer.library.save_probabilities` and
:func:`qiskit.providers.aer.library.save_probabilities_dict`
:func:`qiskit_aer.library.save_probabilities` and
:func:`qiskit_aer.library.save_probabilities_dict`
circuit methods.
"""
warn('The `snapshot_probabilities` circuit method has been deprecated as of'
Expand Down
Loading

0 comments on commit 5eeb0c7

Please sign in to comment.