Rename `aer.openpulse` module to `aer.pulse` and cleanup imports (#567)

This commit is contained in:
Christopher J. Wood 2020-01-31 13:47:10 -05:00 committed by GitHub
parent 8d374e32f8
commit 7fee89e9ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 90 additions and 61 deletions

View File

@ -232,8 +232,8 @@ set(AER_LIBRARIES
# Cython build is only enabled if building through scikit-build.
if(SKBUILD) # Terra Addon build
add_subdirectory(qiskit/providers/aer/openpulse/cy)
add_subdirectory(qiskit/providers/aer/openpulse/qutip_lite/cy)
add_subdirectory(qiskit/providers/aer/pulse/cy)
add_subdirectory(qiskit/providers/aer/pulse/qutip_lite/cy)
add_subdirectory(qiskit/providers/aer/backends/wrappers)
add_subdirectory(src/simulators/open_pulse)
else() # Standalone build

View File

@ -0,0 +1,6 @@
.. _aer-pulse:
.. automodule:: qiskit.providers.aer.pulse
:no-members:
:no-inherited-members:
:no-special-members:

View File

@ -9,6 +9,7 @@ API Documentation
aer_provider
aer_extensions
aer_pulse
aer_noise
aer_noise_errors
aer_noise_device

View File

@ -43,15 +43,6 @@ Job Class
AerJob
OpenPulse
=========
.. autosummary::
:toctree: ../stubs/
PulseSystemModel
duffing_system_model
Exceptions
==========
.. autosummary::
@ -74,7 +65,7 @@ from .aerprovider import AerProvider
from .aerjob import AerJob
from .aererror import AerError
from .backends import *
from .openpulse import *
from . import pulse
from . import noise
from . import utils
from .version import __version__

View File

@ -12,7 +12,7 @@
# pylint: disable=arguments-differ, missing-return-type-doc
"""
Qiskit Aer OpenPulse simulator backend.
Qiskit Aer pulse simulator backend.
"""
import uuid
@ -25,26 +25,26 @@ from qiskit.providers.models import BackendConfiguration, PulseDefaults
from .aerbackend import AerBackend
from ..aerjob import AerJob
from ..version import __version__
from ..openpulse.qobj.digest import digest_pulse_obj
from ..openpulse.solver.opsolve import opsolve
from ..pulse.qobj.digest import digest_pulse_obj
from ..pulse.solver.opsolve import opsolve
logger = logging.getLogger(__name__)
class PulseSimulator(AerBackend):
r"""Aer OpenPulse simulator.
r"""Pulse schedule simulator backend.
The ``PulseSimulator`` simulates continuous time Hamiltonian dynamics of a quantum system,
with controls specified by pulse :class:`Schedule` objects, and the model of the physical
system specified by :class:`PulseSystemModel` objects. Results are returned in the same format
as when jobs are submitted to actual devices.
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.
Results are returned in the same format as when jobs are submitted to actual devices.
**Example**
To use the simulator, first :meth:`assemble` a :class:`PulseQobj` object
from a list of pulse :class:`Schedule` objects, using ``backend=PulseSimulator()``.
Call the simulator with the :class:`PulseQobj` and a :class:`PulseSystemModel`
object representing the physical system.
To use the simulator, first :func:`~qiskit.assemble` a :class:`PulseQobj` object
from a list of pulse :class:`~qiskit.Schedule` objects, using ``backend=PulseSimulator()``.
Call the simulator with the :class:`PulseQobj` and a
:class:`~qiskit.providers.aer.pulse.PulseSystemModel` object representing the physical system.
.. code-block:: python
@ -59,8 +59,9 @@ class PulseSimulator(AerBackend):
**Supported PulseQobj parameters**
* ``qubit_lo_freq``: Local oscillator frequencies for each :class:`DriveChannel`.
Defaults to either the value given in the :class:`PulseSystemModel`, or
is calculated directly from the Hamiltonian.
Defaults to either the value given in the
:class:`~qiskit.providers.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
``|1>``. Defaults to ``2``.
@ -72,8 +73,8 @@ 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:`PulseSystemModel`. Measurements are performed in the `dressed basis`
of the drift Hamiltonian.
contained in the :class:`~qiskit.providers.aer.pulse.PulseSystemModel`. Measurements
are performed in the `dressed basis` of the drift Hamiltonian.
**Other options**

View File

@ -11,7 +11,38 @@
# 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.
"""Init for openpulse"""
"""
=======================================================
Pulse System Models (:mod:`qiskit.providers.aer.pulse`)
=======================================================
.. currentmodule:: qiskit.providers.aer.pulse
This module contains classes and functions to build a pulse system model
for simulating a Qiskit pulse schedule.
Classes
=======
.. autosummary::
:toctree: ../stubs/
PulseSystemModel
Functions
=========
These functions can be used to generate a pulse system model for certain types
of systems.
.. autosummary::
:toctree: ../stubs/
duffing_system_model
"""
# pylint: disable=import-error
import distutils.sysconfig # noqa

View File

@ -9,7 +9,7 @@ include(cython_utils)
# shared library.
string(REPLACE " -static " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CYTHON_INSTALL_DIR "qiskit/providers/aer/openpulse/cy/")
set(CYTHON_INSTALL_DIR "qiskit/providers/aer/pulse/cy/")
add_cython_module(channel_value)
add_cython_module(measure)
add_cython_module(memory)

View File

@ -20,7 +20,7 @@
cimport cython
import numpy as np
cimport numpy as np
from qiskit.providers.aer.openpulse.qutip_lite.cy.spmatfuncs import cy_expect_psi_csr
from qiskit.providers.aer.pulse.qutip_lite.cy.spmatfuncs import cy_expect_psi_csr
@cython.boundscheck(False)
def occ_probabilities(unsigned int[::1] qubits, complex[::1] state, list meas_ops):

View File

@ -23,9 +23,10 @@ from ..aererror import AerError
class PulseSystemModel():
r"""Physical model object for use in :class:`PulseSimulator`.
r"""Physical model object for pulse simulator.
This class contains model information required by :class:`PulseSimulator`. It contains:
This class contains model information required by the
:class:`~qiskit.providers.aer.PulseSimulator`. It contains:
* ``"hamiltonian"``: a :class:`HamiltonianModel` object representing the
Hamiltonian of the system.
@ -38,9 +39,8 @@ class PulseSystemModel():
* ``"subsystem_list"``: List of subsystems in the model.
* ``"dt"``: Sample width size for OpenPulse instructions.
A :class:`PulseSystemModel` object can be instantiated from the
helper function :meth:`duffing_system_model`, or using the
:meth:`PulseSystemModel.from_backend` constructor.
A model can be instantiated from the helper function :func:`duffing_system_model`,
or using the :meth:`PulseSystemModel.from_backend` constructor.
**Example**

View File

@ -6,7 +6,7 @@ include(cython_utils)
# shared library.
string(REPLACE " -static " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CYTHON_INSTALL_DIR "qiskit/providers/aer/openpulse/qutip_lite/cy")
set(CYTHON_INSTALL_DIR "qiskit/providers/aer/pulse/qutip_lite/cy")
add_cython_module(spconvert src/zspmv.cpp)
add_cython_module(spmath src/zspmv.cpp)
add_cython_module(sparse_utils src/zspmv.cpp)

View File

@ -34,7 +34,7 @@
###############################################################################
import numpy as np
from scipy.sparse import coo_matrix
from qiskit.providers.aer.openpulse.qutip_lite.fastsparse import fast_csr_matrix
from qiskit.providers.aer.pulse.qutip_lite.fastsparse import fast_csr_matrix
cimport numpy as np
cimport cython
from libcpp.algorithm cimport sort

View File

@ -33,7 +33,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
import numpy as np
from qiskit.providers.aer.openpulse.qutip_lite.fastsparse import fast_csr_matrix
from qiskit.providers.aer.pulse.qutip_lite.fastsparse import fast_csr_matrix
cimport numpy as cnp
from libc.math cimport abs, fabs, sqrt
from libcpp cimport bool

View File

@ -33,7 +33,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
from qiskit.providers.aer.openpulse.qutip_lite.cy.sparse_structs cimport CSR_Matrix
from qiskit.providers.aer.pulse.qutip_lite.cy.sparse_structs cimport CSR_Matrix
cdef void fdense2D_to_CSR(complex[::1, :] mat, CSR_Matrix * out,
unsigned int nrows, unsigned int ncols)

View File

@ -33,7 +33,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
import numpy as np
from qiskit.providers.aer.openpulse.qutip_lite.fastsparse import fast_csr_matrix
from qiskit.providers.aer.pulse.qutip_lite.fastsparse import fast_csr_matrix
cimport numpy as cnp
cimport cython
from libc.stdlib cimport div, malloc, free

View File

@ -33,7 +33,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
from qiskit.providers.aer.openpulse.qutip_lite.cy.sparse_structs cimport CSR_Matrix
from qiskit.providers.aer.pulse.qutip_lite.cy.sparse_structs cimport CSR_Matrix
cdef void _zcsr_add(CSR_Matrix * A, CSR_Matrix * B,
CSR_Matrix * C, double complex alpha)

View File

@ -262,10 +262,10 @@ cdef extern from "<complex>" namespace "std" nogil:
cdef extern from "<complex>" namespace "std" nogil:
double complex conj(double complex x)
from qiskit.providers.aer.openpulse.qutip_lite.cy.spmatfuncs cimport spmvpy
from qiskit.providers.aer.pulse.qutip_lite.cy.spmatfuncs cimport spmvpy
from libc.math cimport pi
from qiskit.providers.aer.openpulse.cy.channel_value cimport chan_value
from qiskit.providers.aer.pulse.cy.channel_value cimport chan_value
include """ + _include_string + """
"""]

View File

@ -26,9 +26,8 @@ import numpy as np
from scipy.integrate import ode
from scipy.linalg.blas import get_blas_funcs
from qiskit.providers.aer.openpulse.solver.zvode import qiskit_zvode
from qiskit.providers.aer.openpulse.cy.measure import (occ_probabilities,
write_shots_memory)
from qiskit.providers.aer.pulse.solver.zvode import qiskit_zvode
from qiskit.providers.aer.pulse.cy.measure import occ_probabilities, write_shots_memory
from ..qutip_lite.cy.spmatfuncs import cy_expect_psi_csr, spmv_csr
dznrm2 = get_blas_funcs("znrm2", dtype=np.float64)

View File

@ -9,6 +9,6 @@ include(cython_utils)
# shared library.
string(REPLACE " -static " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CYTHON_INSTALL_DIR "qiskit/providers/aer/openpulse/cy/")
set(CYTHON_INSTALL_DIR "qiskit/providers/aer/pulse/cy/")
add_cython_module(numeric_integrator_wrapper numeric_integrator.cpp)
add_cython_module(test_python_to_cpp)

BIN
src/third-party/macos/lib/libmuparserx.a vendored Normal file

Binary file not shown.

View File

@ -29,8 +29,8 @@ from qiskit.compiler import assemble
from qiskit.quantum_info import state_fidelity
from qiskit.pulse.channels import (DriveChannel, ControlChannel, AcquireChannel, MemorySlot)
from qiskit.pulse.commands import SamplePulse, FrameChange
from qiskit.providers.aer.openpulse.pulse_system_model import PulseSystemModel
from qiskit.providers.aer.openpulse.hamiltonian_model import HamiltonianModel
from qiskit.providers.aer.pulse.pulse_system_model import PulseSystemModel
from qiskit.providers.aer.pulse.hamiltonian_model import HamiltonianModel
USE_CPP_ODE_FUNC = True
def run_cython_and_cpp_solvers(func):

View File

@ -16,10 +16,10 @@ Tests for pulse system generator functions
import unittest
from numpy import array, array_equal, kron
from test.terra.common import QiskitAerTestCase
from qiskit.providers.aer.openpulse.pulse_system_model import PulseSystemModel
from qiskit.providers.aer.openpulse.hamiltonian_model import HamiltonianModel
from qiskit.providers.aer.openpulse import duffing_model_generators as model_gen
from qiskit.providers.aer.openpulse.qobj.op_qobj import get_oper
from qiskit.providers.aer.pulse.pulse_system_model import PulseSystemModel
from qiskit.providers.aer.pulse.hamiltonian_model import HamiltonianModel
from qiskit.providers.aer.pulse import duffing_model_generators as model_gen
from qiskit.providers.aer.pulse.qobj.op_qobj import get_oper
class TestDuffingModelGenerators(QiskitAerTestCase):
"""Tests for functions in duffing_model_generators.py"""

View File

@ -19,13 +19,13 @@ import qiskit
import qiskit.pulse as pulse
from qiskit.pulse import pulse_lib
from qiskit.compiler import assemble
from qiskit.providers.aer.openpulse.pulse_system_model import PulseSystemModel
from qiskit.providers.aer.openpulse.hamiltonian_model import HamiltonianModel
from qiskit.providers.aer.openpulse.qobj.digest import digest_pulse_obj
from qiskit.providers.aer.pulse.pulse_system_model import PulseSystemModel
from qiskit.providers.aer.pulse.hamiltonian_model import HamiltonianModel
from qiskit.providers.aer.pulse.qobj.digest import digest_pulse_obj
class TestDigest(QiskitAerTestCase):
"""Testing of functions in providers.aer.openpulse.qobj.digest."""
"""Testing of functions in providers.aer.pulse.qobj.digest."""
def setUp(self):
self.backend_sim = backend_sim = qiskit.Aer.get_backend('pulse_simulator')

View File

@ -23,8 +23,8 @@ from qiskit.test.mock import FakeOpenPulse2Q
import qiskit.pulse as pulse
from qiskit.pulse import pulse_lib
from qiskit.compiler import assemble
from qiskit.providers.aer.openpulse.pulse_system_model import PulseSystemModel
from qiskit.providers.aer.openpulse.hamiltonian_model import HamiltonianModel
from qiskit.providers.aer.pulse.pulse_system_model import PulseSystemModel
from qiskit.providers.aer.pulse.hamiltonian_model import HamiltonianModel
class BaseTestPulseSystemModel(QiskitAerTestCase):

View File

@ -13,8 +13,8 @@
import sys
import unittest
import numpy as np
from qiskit.providers.aer.openpulse.qutip_lite.qobj import Qobj
from qiskit.providers.aer.openpulse.cy.test_python_to_cpp import \
from qiskit.providers.aer.pulse.qutip_lite.qobj import Qobj
from qiskit.providers.aer.pulse.cy.test_python_to_cpp import \
test_py_list_to_cpp_vec, test_py_list_of_lists_to_cpp_vector_of_vectors,\
test_py_dict_string_numeric_to_cpp_map_string_numeric,\
test_py_dict_string_list_of_list_of_doubles_to_cpp_map_string_vec_of_vecs_of_doubles,\