From 9068e5b2e0194b3e4eb3692fa81bfffdd96ea683 Mon Sep 17 00:00:00 2001 From: Christopher Wood Date: Fri, 31 Jan 2020 14:33:20 -0500 Subject: [PATCH 1/8] Move contents of `noise.errors` to `noise` --- docs/apidocs/aer_noise_errors.rst | 6 --- docs/apidocs/qiskit_aer.rst | 3 +- qiskit/providers/aer/noise/__init__.py | 48 ++++++++++++++++--- qiskit/providers/aer/noise/errors/__init__.py | 41 +--------------- 4 files changed, 44 insertions(+), 54 deletions(-) delete mode 100644 docs/apidocs/aer_noise_errors.rst diff --git a/docs/apidocs/aer_noise_errors.rst b/docs/apidocs/aer_noise_errors.rst deleted file mode 100644 index 6608fd39e0..0000000000 --- a/docs/apidocs/aer_noise_errors.rst +++ /dev/null @@ -1,6 +0,0 @@ -.. _aer-noise-errors: - -.. automodule:: qiskit.providers.aer.noise.errors - :no-members: - :no-inherited-members: - :no-special-members: \ No newline at end of file diff --git a/docs/apidocs/qiskit_aer.rst b/docs/apidocs/qiskit_aer.rst index 0be0c990bc..3c3d6e2335 100644 --- a/docs/apidocs/qiskit_aer.rst +++ b/docs/apidocs/qiskit_aer.rst @@ -9,8 +9,7 @@ API Documentation aer_provider aer_extensions - aer_pulse aer_noise - aer_noise_errors aer_noise_device aer_noise_utils + aer_pulse \ No newline at end of file diff --git a/qiskit/providers/aer/noise/__init__.py b/qiskit/providers/aer/noise/__init__.py index e70b26fd8d..4aed1d2d13 100644 --- a/qiskit/providers/aer/noise/__init__.py +++ b/qiskit/providers/aer/noise/__init__.py @@ -24,21 +24,40 @@ Classes ======= +The following are the classes used to represented noise and error terms. + .. autosummary:: :toctree: ../stubs/ NoiseModel + QuantumError + ReadoutError -Submodules -========== +Quantum Error Functions +======================= -Errors for Noise Models ------------------------ +The following functions can be used to generate many common types of +:class:`QuantumError` objects for inclusion in a :class:`NoiseModel`. -The :mod:`qiskit.providers.aer.noise.errors` submodule contains classes -and functions for constructing generating errors for custom noise models. +.. autosummary:: + :toctree: ../stubs/ + pauli_error + depolarizing_error + pauli_error + mixed_unitary_error + coherent_unitary_error + reset_error + amplitude_damping_error + phase_damping_error + phase_amplitude_damping_error + thermal_relaxation_error + kraus_error + + +Submodules +========== Device Noise Models ------------------- @@ -55,7 +74,24 @@ quantum circuits. """ +# Noise and Error classes from .noise_model import NoiseModel +from .errors import QuantumError +from .errors import ReadoutError + +# Error generating functions +from .errors import kraus_error +from .errors import mixed_unitary_error +from .errors import coherent_unitary_error +from .errors import pauli_error +from .errors import depolarizing_error +from .errors import reset_error +from .errors import thermal_relaxation_error +from .errors import phase_amplitude_damping_error +from .errors import amplitude_damping_error +from .errors import phase_damping_error + +# Submodules from . import errors from . import device from . import utils diff --git a/qiskit/providers/aer/noise/errors/__init__.py b/qiskit/providers/aer/noise/errors/__init__.py index 69e04a49a9..7a8dd4bc6f 100644 --- a/qiskit/providers/aer/noise/errors/__init__.py +++ b/qiskit/providers/aer/noise/errors/__init__.py @@ -11,46 +11,7 @@ # that they have been altered from the originals. """ -================================================================== -Errors for Noise Models (:mod:`qiskit.providers.aer.noise.errors`) -================================================================== - -.. currentmodule:: qiskit.providers.aer.noise.errors - - -Classes -======= - -The following are the base classes used to represented error terms in a -Qiskit Aer :class:`NoiseModel`. - -.. autosummary:: - :toctree: ../stubs/ - - QuantumError - ReadoutError - - -Generator Functions -=================== - -The following functions can be used to generate many common types of -:class:`QuantumError` objects for inclusion in a :class:`~qiskit.providers.aer.noise.NoiseModel`. - -.. autosummary:: - :toctree: ../stubs/ - - pauli_error - depolarizing_error - pauli_error - mixed_unitary_error - coherent_unitary_error - reset_error - amplitude_damping_error - phase_damping_error - phase_amplitude_damping_error - thermal_relaxation_error - kraus_error +Errors for qiskit-aer noise models. """ from .readout_error import ReadoutError From c44b6ffeac8e6e9265dd21a9877f27582aef7159 Mon Sep 17 00:00:00 2001 From: Christopher Wood Date: Fri, 31 Jan 2020 14:51:48 -0500 Subject: [PATCH 2/8] remove deprecated `as_dict` function --- .../aer/noise/errors/quantum_error.py | 22 +++++-------------- .../aer/noise/errors/readout_error.py | 22 +++++-------------- qiskit/providers/aer/noise/noise_model.py | 18 --------------- qiskit/providers/aer/utils/__init__.py | 1 - qiskit/providers/aer/utils/helpers.py | 22 ------------------- 5 files changed, 10 insertions(+), 75 deletions(-) delete mode 100644 qiskit/providers/aer/utils/helpers.py diff --git a/qiskit/providers/aer/noise/errors/quantum_error.py b/qiskit/providers/aer/noise/errors/quantum_error.py index af8c92d859..d14bc58110 100644 --- a/qiskit/providers/aer/noise/errors/quantum_error.py +++ b/qiskit/providers/aer/noise/errors/quantum_error.py @@ -13,7 +13,6 @@ Quantum error class for Qiskit Aer noise model """ import logging -import warnings import copy import numpy as np @@ -27,7 +26,6 @@ from .errorutils import circuit2superop from .errorutils import standard_instruction_channel from .errorutils import standard_instruction_operator -from ...utils.helpers import deprecation logger = logging.getLogger(__name__) @@ -287,16 +285,6 @@ def error_term(self, position): raise NoiseError("Position {} is greater than the number".format( position) + "of error outcomes {}".format(self.size)) - def as_dict(self): - """ - Return the current error as a dictionary (DEPRECATED). - - DEPRECATED: use :meth:`to_dict`. - """ - deprecation("QuantumError::as_dict() method is deprecated and will be removed after 0.3." - "Use '.to_dict()' instead") - return self.to_dict() - def to_dict(self): """Return the current error as a dictionary.""" error = { @@ -310,10 +298,13 @@ def to_dict(self): def compose(self, other, front=False): """Return the composition error channel other * self. + Note that for `front=True` this is equivalent to the + :meth:`QuantumError.dot` method. + Args: other (QuantumError): a quantum error channel. - front (bool): DEPRECATED If True return self * other instead. - [default: False] + front (bool): If True return the reverse order composation + self * other instead [default: False]. Returns: QuantumError: The composition error channel. @@ -323,9 +314,6 @@ def compose(self, other, front=False): or has incompatible dimensions. """ if front: - # DEPRECATED kwarg `front` - warnings.warn('`compose(other, front=True)` is deprecated, use `dot(other)` instead.', - DeprecationWarning) return self._matmul(other, left_multiply=False) return self._matmul(other, left_multiply=True) diff --git a/qiskit/providers/aer/noise/errors/readout_error.py b/qiskit/providers/aer/noise/errors/readout_error.py index 0288234eeb..5921826b9d 100644 --- a/qiskit/providers/aer/noise/errors/readout_error.py +++ b/qiskit/providers/aer/noise/errors/readout_error.py @@ -14,7 +14,6 @@ """ import copy -import warnings import numpy as np from numpy.linalg import norm @@ -24,7 +23,6 @@ from ..noiseerror import NoiseError from .errorutils import qubits_from_mat -from ...utils.helpers import deprecation class ReadoutError: @@ -156,16 +154,6 @@ def to_instruction(self): """Convert the ReadoutError to a circuit Instruction.""" return Instruction("roerror", 0, self.number_of_qubits, self._probabilities) - def as_dict(self): - """ - Return the current error as a dictionary (DEPRECATED). - - DEPRECATED: use :meth:`to_dict`. - """ - deprecation("ReadoutError::as_dict() method is deprecated and will be removed after 0.3." - "Use '.to_dict()' instead") - return self.to_dict() - def to_dict(self): """Return the current error as a dictionary.""" error = { @@ -178,10 +166,13 @@ def to_dict(self): def compose(self, other, front=False): """Return the composition readout error other * self. + Note that for `front=True` this is equivalent to the + :meth:`ReadoutError.dot` method. + Args: other (ReadoutError): a readout error. - front (bool): DEPRECATED If True return self * other instead. - [default: False] + front (bool): If True return the reverse order composation + self * other instead [default: False]. Returns: ReadoutError: The composition readout error. @@ -191,9 +182,6 @@ def compose(self, other, front=False): dimensions. """ if front: - # DEPRECATED kwarg `front` - warnings.warn('`compose(other, front=True)` is deprecated, use `dot(other)` instead.', - DeprecationWarning) return self._matmul(other) return self._matmul(other, left_multiply=True) diff --git a/qiskit/providers/aer/noise/noise_model.py b/qiskit/providers/aer/noise/noise_model.py index 5125f2aab3..e02bb5ea04 100644 --- a/qiskit/providers/aer/noise/noise_model.py +++ b/qiskit/providers/aer/noise/noise_model.py @@ -23,7 +23,6 @@ from .noiseerror import NoiseError from .errors.quantum_error import QuantumError from .errors.readout_error import ReadoutError -from ..utils.helpers import deprecation logger = logging.getLogger(__name__) @@ -546,23 +545,6 @@ def add_readout_error(self, error, qubits, warnings=True): "all-qubit readout error for these qubits.", qubits) self._noise_instructions.add("measure") - def as_dict(self, serializable=False): - """ - Return the noise model as a dictionary (DEPRECATED). - - DEPRECATED: Use :meth:`to_dict` - - Args: - serializable (bool): if `True`, return a dict containing only types - that can be serializable by the stdlib `json` module. - - Returns: - dict: a dictionary for a noise model. - """ - deprecation("NoiseModel::as_dict() method is deprecated and will be removed after 0.3." - "Use '.to_dict()' instead") - self.to_dict(serializable) - def to_dict(self, serializable=False): """ Return the noise model as a dictionary. diff --git a/qiskit/providers/aer/utils/__init__.py b/qiskit/providers/aer/utils/__init__.py index 133948e85b..4f3ab871f1 100644 --- a/qiskit/providers/aer/utils/__init__.py +++ b/qiskit/providers/aer/utils/__init__.py @@ -13,4 +13,3 @@ """Utilities""" from . import qobj_utils -from . import helpers diff --git a/qiskit/providers/aer/utils/helpers.py b/qiskit/providers/aer/utils/helpers.py deleted file mode 100644 index 92b967aeec..0000000000 --- a/qiskit/providers/aer/utils/helpers.py +++ /dev/null @@ -1,22 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2018, 2019. -# -# 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 -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# 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. - -""" -A bunch of usefull helper functions -""" - -from warnings import warn - - -def deprecation(message): - """ Shows a deprecation message to the user """ - warn(message, DeprecationWarning, stacklevel=2) From bf2333a61f380500c03ea89fb2e52a3327d10462 Mon Sep 17 00:00:00 2001 From: Christopher Wood Date: Fri, 31 Jan 2020 14:55:52 -0500 Subject: [PATCH 3/8] move device noise models to `aer.noise` --- docs/apidocs/aer_noise_device.rst | 6 -- docs/apidocs/qiskit_aer.rst | 1 - qiskit/providers/aer/noise/__init__.py | 25 +++++-- qiskit/providers/aer/noise/device/__init__.py | 54 +------------ qiskit/providers/aer/noise/device/models.py | 75 ++++++++----------- 5 files changed, 48 insertions(+), 113 deletions(-) delete mode 100644 docs/apidocs/aer_noise_device.rst diff --git a/docs/apidocs/aer_noise_device.rst b/docs/apidocs/aer_noise_device.rst deleted file mode 100644 index d51b5bbeca..0000000000 --- a/docs/apidocs/aer_noise_device.rst +++ /dev/null @@ -1,6 +0,0 @@ -.. _aer-noise-device: - -.. automodule:: qiskit.providers.aer.noise.device - :no-members: - :no-inherited-members: - :no-special-members: \ No newline at end of file diff --git a/docs/apidocs/qiskit_aer.rst b/docs/apidocs/qiskit_aer.rst index 3c3d6e2335..32774dafe7 100644 --- a/docs/apidocs/qiskit_aer.rst +++ b/docs/apidocs/qiskit_aer.rst @@ -10,6 +10,5 @@ API Documentation aer_provider aer_extensions aer_noise - aer_noise_device aer_noise_utils aer_pulse \ No newline at end of file diff --git a/qiskit/providers/aer/noise/__init__.py b/qiskit/providers/aer/noise/__init__.py index 4aed1d2d13..01c01c6dcf 100644 --- a/qiskit/providers/aer/noise/__init__.py +++ b/qiskit/providers/aer/noise/__init__.py @@ -56,18 +56,22 @@ kraus_error -Submodules -========== +Noise Model Functions +===================== -Device Noise Models -------------------- +The following functions can be used to generate approximate noise models for +IBMQ hardware devices based on the parameters in their backend properties. -The :mod:`qiskit.providers.aer.noise.device` submodule contains functions -for generating approximate noise models for a hardware device. +.. autosummary:: + :toctree: ../stubs/ + basic_device_noise_model + basic_device_readout_errors + basic_device_gate_errors -Noise Utilities ---------------- + +Noise Model Utilities +===================== The :mod:`qiskit.providers.aer.noise.utils` submodule contains utilities for remapping and approximating noise models, and inserting noise into @@ -91,6 +95,11 @@ from .errors import amplitude_damping_error from .errors import phase_damping_error +# Noise model generating functions +from .device.models import basic_device_noise_model +from .device.models import basic_device_readout_errors +from .device.models import basic_device_gate_errors + # Submodules from . import errors from . import device diff --git a/qiskit/providers/aer/noise/device/__init__.py b/qiskit/providers/aer/noise/device/__init__.py index e96a764c27..068fdee34d 100644 --- a/qiskit/providers/aer/noise/device/__init__.py +++ b/qiskit/providers/aer/noise/device/__init__.py @@ -11,59 +11,7 @@ # that they have been altered from the originals. """ -============================================================= -Device Noise Model (:mod:`qiskit.providers.aer.noise.device`) -============================================================= - -.. currentmodule:: qiskit.providers.aer.noise.device - -Approximate noise models for a hardware device can be generated from the -device properties using the functions in this module. - -Basic device noise model -======================== - -The :func:`basic_device_noise_model` function generates a noise model -based on: - -* 1 and 2 qubit gate errors consisting of a - :func:`~qiskit.providers.aer.noise.errors.depolarizing_error` followed - by a :func:`~qiskit.providers.aer.noise.errors.thermal_relaxation_error`. - -* Single qubit :class:`~qiskit.providers.aer.noise.errors.ReadoutError` on - all measurements. - -The Error error parameters are tuned for each individual qubit based on -the :math:`T_1`, :math:`T_2`, frequency and readout error parameters for -each qubit, and the gate error and gate time parameters for each gate -obtained from the device backend properties. - - -Functions -========= - -.. autosummary:: - :toctree: ../stubs/ - - basic_device_noise_model - basic_device_readout_errors - basic_device_gate_errors - - -Helper functions -================ - -The following helper functions can be used to extract parameters from -a device ``BackendProperties`` object. - -.. autosummary:: - :toctree: ../stubs/ - - parameters.gate_param_values - parameters.gate_error_values - parameters.gate_length_values - parameters.readout_error_values - parameters.thermal_relaxation_values +Functions for building noise models from backend properties. """ from .models import basic_device_noise_model diff --git a/qiskit/providers/aer/noise/device/models.py b/qiskit/providers/aer/noise/device/models.py index b6b4439dfb..f8e943f3fc 100644 --- a/qiskit/providers/aer/noise/device/models.py +++ b/qiskit/providers/aer/noise/device/models.py @@ -15,7 +15,6 @@ Simplified noise models for devices backends. """ -import warnings from numpy import inf, exp, allclose from .parameters import readout_error_values @@ -35,10 +34,24 @@ def basic_device_noise_model(properties, thermal_relaxation=True, temperature=0, gate_lengths=None, - gate_times=None, standard_gates=True): """ - Return a NoiseModel derived from a devices BackendProperties. + Return a noise model derived from a devices backend properties. + + This function generates a noise model based on: + + * 1 and 2 qubit gate errors consisting of a + :func:`depolarizing_error` followed + by a :func:`thermal_relaxation_error`. + + * Single qubit :class:`ReadoutError` on all measurements. + + The Error error parameters are tuned for each individual qubit based on + the :math:`T_1`, :math:`T_2`, frequency and readout error parameters for + each qubit, and the gate error and gate time parameters for each gate + obtained from the device backend properties. + + **Additional Information** The noise model includes the following errors: @@ -47,22 +60,21 @@ def basic_device_noise_model(properties, * If ``gate_error=True`` and ``thermal_relaxation=True`` include: - * Single-qubit gate errors consisting of a depolarizing error - followed by a thermal relaxation error for the qubit the gate - acts on. + * Single-qubit gate errors consisting of a :func:`depolarizing_error` + followed by a :func:`thermal_relaxation_error` for the qubit the + gate acts on. - * Two-qubit gate errors consisting of a 2-qubit depolarizing - error followed by single qubit thermal relaxation errors for - all qubits participating in the gate. + * Two-qubit gate errors consisting of a 2-qubit + :func:`depolarizing_error` followed by single qubit + :func:`thermal_relaxation_error` on each qubit participating in + the gate. * If ``gate_error=True`` is ``True`` and ``thermal_relaxation=False``: - * Single-qubit depolarizing gate errors. - - * Multi-qubit depolarizing gate errors. + * An N-qubit :func:`depolarizing_error` on each N-qubit gate. * If ``gate_error=False`` and ``thermal_relaxation=True`` include - single-qubit thermal relaxation errors for all qubits + single-qubit :func:`thermal_relaxation_errors` on each qubits participating in a multi-qubit gate. For best practice in simulating a backend make sure that the @@ -97,7 +109,6 @@ def basic_device_noise_model(properties, gate_lengths (list): Custom gate times for thermal relaxation errors. Used to extend or override the gate times in the backend properties (Default: None)) - gate_times (list): DEPRECATED -- use gate_lengths. standard_gates (bool): If true return errors as standard qobj gates. If false return as unitary qobj instructions (Default: True) @@ -105,18 +116,6 @@ def basic_device_noise_model(properties, Returns: NoiseModel: An approximate noise model for the device backend. """ - # Deprecation warning for change of name field in device model - # from gate_times to gate_lengths - if gate_times: - warnings.warn( - 'gate_times kwarg is deprecated and will be removed ' - 'in a future release. Use gate_lengths kwarg instead.', - DeprecationWarning) - # Convert deprecated kwarg to current kwarg if it is not - # also defined - if gate_lengths is None: - gate_lengths = gate_times - noise_model = NoiseModel() # Add single-qubit readout errors @@ -146,8 +145,8 @@ def basic_device_readout_errors(properties): properties (BackendProperties): device backend properties Returns: - list: A list of pairs ``(qubits, value)`` for qubits with non-zero - readout error values. + list: A list of pairs ``(qubits, ReadoutError)`` for qubits with + non-zero readout error values. """ errors = [] for qubit, value in enumerate(readout_error_values(properties)): @@ -161,7 +160,6 @@ def basic_device_gate_errors(properties, gate_error=True, thermal_relaxation=True, gate_lengths=None, - gate_times=None, # DEPRECATED temperature=0, standard_gates=True): """ @@ -181,7 +179,6 @@ def basic_device_gate_errors(properties, gate_lengths (list): Override device gate times with custom values. If None use gate times from backend properties. (Default: None). - gate_times (list): DEPRECATED -- use gate_lengths. temperature (double): qubit temperature in milli-Kelvin (mK) (Default: 0). standard_gates (bool): If true return errors as standard @@ -189,22 +186,10 @@ def basic_device_gate_errors(properties, qobj instructions (Default: True). Returns: - dict: A dictionary of pairs name: ``(qubits, error)``. If gate - error information is not available ``None`` will be returned for - value. + list: A list of tuples ``(label, qubits, QuantumError)``, for gates + with non-zero quantum error terms, where `label` is the label of the + noisy gate, `qubits` is the list of qubits for the gate. """ - # Decrecation warning for change of name field in device model - # from gate_times to gate_lengths - if gate_times: - warnings.warn( - 'gate_times kwarg is deprecated and will be removed ' - 'in a future release. Use gate_lengths kwarg instead.', - DeprecationWarning) - # Convert deprecated kwarg to current kwarg if it is not - # also defined - if gate_lengths is None: - gate_lengths = gate_times - # Initilize empty errors depol_error = None relax_error = None From 63fedafe51a91f48e3f2b0ea135ed9fefce55bf6 Mon Sep 17 00:00:00 2001 From: Christopher Wood Date: Thu, 30 Jan 2020 17:38:17 -0500 Subject: [PATCH 4/8] Deprecate old `qobj_utils` file --- qiskit/providers/aer/utils/qobj_utils.py | 63 ++++++++++++++++++++---- 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/qiskit/providers/aer/utils/qobj_utils.py b/qiskit/providers/aer/utils/qobj_utils.py index d8aba62393..f67bf93706 100644 --- a/qiskit/providers/aer/utils/qobj_utils.py +++ b/qiskit/providers/aer/utils/qobj_utils.py @@ -9,7 +9,6 @@ # 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. - """ Temporary hacks for qobj until Terra supports Aer instructions (likely 0.8) @@ -18,6 +17,7 @@ """ import copy +import warnings import numpy as np from qiskit.qobj import QasmQobjInstruction @@ -33,6 +33,9 @@ def append_instr(qobj, exp_index, instruction): Returns: qobj(Qobj): The Qobj object """ + warnings.warn( + 'This function is deprecated and will be removed in a future release.', + DeprecationWarning) qobj.experiments[exp_index].instructions.append(instruction) return qobj @@ -49,6 +52,9 @@ def insert_instr(qobj, exp_index, item, pos): Returns: qobj(Qobj): The Qobj object """ + warnings.warn( + 'This function is deprecated and will be removed in a future release.', + DeprecationWarning) qobj.experiments[exp_index].instructions.insert(pos, item) return qobj @@ -67,9 +73,14 @@ def get_instr_pos(qobj, exp_index, name): Returns: list[int]: A list of positions where the QasmQobjInstruction is located. """ + warnings.warn( + 'This funnction is deprecated and will be removed in a future release.', + DeprecationWarning) # Check only the name string of the item - positions = [i for i, val in enumerate(qobj.experiments[exp_index].instructions) - if val.name == name] + positions = [ + i for i, val in enumerate(qobj.experiments[exp_index].instructions) + if val.name == name + ] return positions @@ -100,43 +111,64 @@ def unitary_instr(mat, qubits, label=None): model so that noise may be applied to the implementation of this matrix. """ + warnings.warn( + 'This function is deprecated and will be removed in a future release.', + DeprecationWarning) array = np.array(mat, dtype=complex) - dim = 2 ** len(qubits) + dim = 2**len(qubits) if array.shape not in [(dim, dim), (1, dim)]: raise ValueError("Invalid") - instruction = {"name": "unitary", "qubits": list(qubits), - "params": [np.array(mat, dtype=complex)]} + instruction = { + "name": "unitary", + "qubits": list(qubits), + "params": [np.array(mat, dtype=complex)] + } if label is not None: instruction["label"] = str(label) return QasmQobjInstruction(**instruction) def measure_instr(qubits, memory, registers=None): - """Create a multi-qubit measure instruction""" + warnings.warn( + 'This function is deprecated and will be removed in a future release.', + DeprecationWarning) if len(qubits) != len(memory): raise ValueError("Number of qubits does not match number of memory") if registers is None: - return QasmQobjInstruction(name='measure', qubits=qubits, memory=memory) + return QasmQobjInstruction(name='measure', + qubits=qubits, + memory=memory) # Case where we also measure to registers if len(qubits) != len(registers): raise ValueError("Number of qubits does not match number of registers") - return QasmQobjInstruction(name='measure', qubits=qubits, memory=memory, + return QasmQobjInstruction(name='measure', + qubits=qubits, + memory=memory, register=registers) def reset_instr(qubits): """Create a multi-qubit reset instruction""" + warnings.warn( + 'This function is deprecated and will be removed in a future release.', + DeprecationWarning) return QasmQobjInstruction(name='reset', qubits=qubits) def barrier_instr(num_qubits): """Create a barrier QasmQobjInstruction.""" + warnings.warn( + 'This function is deprecated and will be removed in a future release.', + DeprecationWarning) return QasmQobjInstruction(name='barrier', qubits=list(range(num_qubits))) def iden_instr(qubit): """Create a barrier QasmQobjInstruction.""" + warnings.warn( + 'This function is deprecated and will be removed in a future release.', + DeprecationWarning) return QasmQobjInstruction(name='id', qubits=[qubit]) @@ -179,7 +211,15 @@ def snapshot_instr(snapshot_type, label, qubits=None, params=None): Matrix expectation value params: TODO """ - snap = {"name": "snapshot", "snapshot_type": snapshot_type, "label": str(label)} + warnings.warn( + 'This function is deprecated and will be removed in a future release.' + ' Use the snapshot circuit instructions in' + ' `qiskit.provider.aer.extensions` instead.', DeprecationWarning) + snap = { + "name": "snapshot", + "snapshot_type": snapshot_type, + "label": str(label) + } if qubits is not None: snap["qubits"] = list(qubits) if params is not None: @@ -211,6 +251,9 @@ def insert_snapshots_after_barriers(qobj, snapshot): Additional Information: """ + warnings.warn( + 'This function is deprecated and will be removed in a future release.', + DeprecationWarning) if snapshot.name != "snapshot": raise ValueError("Invalid snapshot instruction") label = snapshot.label From 3498cad361048bffc5664b46a0253e45ddc264d6 Mon Sep 17 00:00:00 2001 From: Christopher Wood Date: Thu, 30 Jan 2020 18:16:16 -0500 Subject: [PATCH 5/8] move noise.utils to utils --- docs/apidocs/aer_noise_utils.rst | 6 - docs/apidocs/aer_utils.rst | 6 + docs/apidocs/qiskit_aer.rst | 4 +- qiskit/providers/aer/noise/__init__.py | 8 - qiskit/providers/aer/noise/utils/__init__.py | 196 +++++++++++++++--- qiskit/providers/aer/utils/__init__.py | 39 +++- .../{noise => }/utils/noise_model_inserter.py | 0 .../aer/{noise => }/utils/noise_remapper.py | 4 +- .../{noise => }/utils/noise_transformation.py | 8 +- test/terra/noise/test_noise_inserter.py | 2 +- test/terra/noise/test_noise_remapper.py | 2 +- test/terra/noise/test_noise_transformation.py | 6 +- 12 files changed, 226 insertions(+), 55 deletions(-) delete mode 100644 docs/apidocs/aer_noise_utils.rst create mode 100644 docs/apidocs/aer_utils.rst rename qiskit/providers/aer/{noise => }/utils/noise_model_inserter.py (100%) rename qiskit/providers/aer/{noise => }/utils/noise_remapper.py (98%) rename qiskit/providers/aer/{noise => }/utils/noise_transformation.py (99%) diff --git a/docs/apidocs/aer_noise_utils.rst b/docs/apidocs/aer_noise_utils.rst deleted file mode 100644 index d0f7d05e9f..0000000000 --- a/docs/apidocs/aer_noise_utils.rst +++ /dev/null @@ -1,6 +0,0 @@ -.. _aer-noise-utils: - -.. automodule:: qiskit.providers.aer.noise.utils - :no-members: - :no-inherited-members: - :no-special-members: \ No newline at end of file diff --git a/docs/apidocs/aer_utils.rst b/docs/apidocs/aer_utils.rst new file mode 100644 index 0000000000..222a4f5fc3 --- /dev/null +++ b/docs/apidocs/aer_utils.rst @@ -0,0 +1,6 @@ +.. _aer-utils: + +.. automodule:: qiskit.providers.aer.utils + :no-members: + :no-inherited-members: + :no-special-members: \ No newline at end of file diff --git a/docs/apidocs/qiskit_aer.rst b/docs/apidocs/qiskit_aer.rst index 32774dafe7..892ab7c955 100644 --- a/docs/apidocs/qiskit_aer.rst +++ b/docs/apidocs/qiskit_aer.rst @@ -10,5 +10,5 @@ API Documentation aer_provider aer_extensions aer_noise - aer_noise_utils - aer_pulse \ No newline at end of file + aer_pulse + aer_utils \ No newline at end of file diff --git a/qiskit/providers/aer/noise/__init__.py b/qiskit/providers/aer/noise/__init__.py index 01c01c6dcf..ae3ae024f5 100644 --- a/qiskit/providers/aer/noise/__init__.py +++ b/qiskit/providers/aer/noise/__init__.py @@ -68,14 +68,6 @@ basic_device_noise_model basic_device_readout_errors basic_device_gate_errors - - -Noise Model Utilities -===================== - -The :mod:`qiskit.providers.aer.noise.utils` submodule contains utilities -for remapping and approximating noise models, and inserting noise into -quantum circuits. """ # Noise and Error classes diff --git a/qiskit/providers/aer/noise/utils/__init__.py b/qiskit/providers/aer/noise/utils/__init__.py index 16cb54898d..06712a5c62 100644 --- a/qiskit/providers/aer/noise/utils/__init__.py +++ b/qiskit/providers/aer/noise/utils/__init__.py @@ -9,41 +9,183 @@ # 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. - """ -========================================================= -Noise Utilities (:mod:`qiskit.providers.aer.noise.utils`) -========================================================= +The functions here have been moved to `qiskit.providers.aer.utils`. +""" -.. currentmodule:: qiskit.providers.aer.noise.utils +import warnings as warn -This module contains utilities for modifying -:class:`~qiskit.providers.aer.noise.NoiseModel` objects and ``QuantumCircuits`` -using noise models. +# DEPRECATED: these functions have been moved +from ...utils import remap_noise_model as _remap_noise_model +from ...utils import NoiseTransformer as _NoiseTransformer +from ...utils import approximate_quantum_error as _approximate_quantum_error +from ...utils import approximate_noise_model as _approximate_noise_model +from ...utils import insert_noise as _insert_noise -Functions -========= -.. autosummary:: - :toctree: ../stubs/ +def remap_noise_model(noise_model, + remapping, + discard_qubits=False, + warnings=True): + """Remap qubits in a noise model. - remap_noise_model - insert_noise - approximate_quantum_error - approximate_noise_model + This remaps the specified gate qubits for local quantum errors, the gate + and noise qubits for non-local quantum errors, and the gate qubits for + local ReadoutErrors. All-qubit quantum and readout errors are unaffected. + Args: + noise_model (NoiseModel): a noise model to remap qubits. + remapping (list): list or remappings of old qubit to new qubit. + See Additional Information. + discard_qubits (bool): if True discard qubits not in remapping keys, + if False an identity mapping wil be assumed + for unnamed qubits (Default: False). + warnings (bool): display warnings if qubits being remapped are not + in the input noise model (Default: True). -Classes -======= + Returns: + NoiseModel: a new noise model with the same errors but remapped + gate and noise qubits for local and non-local errors. -.. autosummary:: - :toctree: ../stubs/ + Raises: + NoiseError: if remapping has duplicate qubits in the remapped qubits. + + Additional Information: + * The remapping map be specified as either a list of pairs: + ``[(old, new), ...]``, or a list of old qubits where the new qubit is + inferred from the position: ``[old0, old1, ...]`` is treated as + ``[(old0, 0), (old1, 1), ...]``. + + * If ``discard_qubits`` is ``False``, any qubits in the noise model not + specified in the list of old qubits will be added to the remapping as + a trivial mapping ``(qubit, qubit)``. + """ + warn.warn( + 'This function is been moved to `qiskit.providers.aer.utils.remap_noise_model`.' + ' Importing it from `qiskit.providers.aer.noise.utils` will be' + ' removed in a future release.', DeprecationWarning) + return _remap_noise_model(noise_model, + remapping, + discard_qubits=discard_qubits, + warnings=warnings) + + +def insert_noise(circuits, noise_model, transpile=False): + """Return a noisy version of a QuantumCircuit. + + Args: + circuits (QuantumCircuit or list[QuantumCircuit]): Input noise-free circuits. + noise_model (NoiseModel): The noise model containing the errors to add + transpile (Boolean): Should the circuit be transpiled into the noise model basis gates + + Returns: + QuantumCircuit: The new circuit with the Kraus noise instructions inserted. + + Additional Information: + The noisy circuit return by this function will consist of the + original circuit with ``Kraus`` instructions inserted after all + instructions referenced in the ``noise_model``. The resulting circuit + cannot be ran on a quantum computer but can be executed on the + :class:`~qiskit.providers.aer.QasmSimulator`. + """ + warn.warn( + 'This function is been moved to `qiskit.providers.aer.utils.insert_noise`.' + ' Importing it from `qiskit.providers.aer.noise.utils` will be' + ' removed in a future release.', DeprecationWarning) + return _insert_noise(circuits, noise_model, transpile=transpile) + + +def approximate_quantum_error(error, + *, + operator_string=None, + operator_dict=None, + operator_list=None): + """ + Return an approximate QuantumError bases on the Hilbert-Schmidt metric. + + Currently this is only implemented for 1-qubit QuantumErrors. + + Args: + error (QuantumError): the error to be approximated. + operator_string (string or None): a name for a pre-made set of + building blocks for the output channel (Default: None). + operator_dict (dict or None): a dictionary whose values are the + building blocks for the output channel (Default: None). + operator_list (dict or None): list of building blocks for the + output channel (Default: None). + + Returns: + QuantumError: the approximate quantum error. + + Raises: + NoiseError: if number of qubits is not supported or approximation + failed. + RuntimeError: If there's no information about the noise type. + + Additional Information: + The operator input precedence is: ``list`` < ``dict`` < ``str``. + If a string is given, dict is overwritten; if a dict is given, list is + overwritten. Oossible values for string are ``'pauli'``, ``'reset'``, + ``'clifford'``. + For further information see :meth:`NoiseTransformer.named_operators`. + """ + warn.warn( + 'This function is been moved to `qiskit.providers.aer.utils.approximate_qauntum_error`.' + ' Importing it from `qiskit.providers.aer.noise.utils` will be removed' + ' in a future release.', + DeprecationWarning) + return _approximate_quantum_error(error, + operator_string=operator_string, + operator_dict=operator_dict, + operator_list=operator_list) + + +def approximate_noise_model(model, + *, + operator_string=None, + operator_dict=None, + operator_list=None): + """ + Return an approximate noise model. + + Args: + model (NoiseModel): the noise model to be approximated. + operator_string (string or None): a name for a pre-made set of + building blocks for the output channel (Default: None). + operator_dict (dict or None): a dictionary whose values are the + building blocks for the output channel (Default: None). + operator_list (dict or None): list of building blocks for the + output channel (Default: None). + + Returns: + NoiseModel: the approximate noise model. + + Raises: + NoiseError: if number of qubits is not supported or approximation + failed. + + Additional Information: + The operator input precedence is: ``list`` < ``dict`` < ``str``. + If a string is given, dict is overwritten; if a dict is given, list is + overwritten. Oossible values for string are ``'pauli'``, ``'reset'``, + ``'clifford'``. + For further information see :meth:`NoiseTransformer.named_operators`. + """ + warn.warn( + 'This function is been moved to `qiskit.providers.aer.utils.approximate_noise_model`.' + ' Importing it from `qiskit.providers.aer.noise.utils` will be removed in a' + ' future release.', DeprecationWarning) + return _approximate_noise_model(model, + operator_string=operator_string, + operator_dict=operator_dict, + operator_list=operator_list) - NoiseTransformer -""" -from .noise_remapper import remap_noise_model -from .noise_transformation import NoiseTransformer -from .noise_transformation import approximate_quantum_error -from .noise_transformation import approximate_noise_model -from .noise_model_inserter import insert_noise +class NoiseTransformer(_NoiseTransformer): + """Transforms one quantum channel to another based on a specified criteria.""" + def __init__(self): + warn.warn( + 'This function is been moved to `qiskit.providers.aer.utils.NoiseTransformer`.' + ' Importing it from `qiskit.providers.aer.noise.utils` will be removed in a' + ' future release.', DeprecationWarning) + super().__init__() diff --git a/qiskit/providers/aer/utils/__init__.py b/qiskit/providers/aer/utils/__init__.py index 4f3ab871f1..b64ad32a39 100644 --- a/qiskit/providers/aer/utils/__init__.py +++ b/qiskit/providers/aer/utils/__init__.py @@ -10,6 +10,43 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -"""Utilities""" +""" +============================================= +Utilities (:mod:`qiskit.providers.aer.utils`) +============================================= + +.. currentmodule:: qiskit.providers.aer.utils + +This module contains utility functions for modifying +:class:`~qiskit.providers.aer.noise.NoiseModel` objects and ``QuantumCircuits`` +using noise models. + + +Classes +======= + +.. autosummary:: + :toctree: ../stubs/ + + NoiseTransformer + + +Functions +========= + +.. autosummary:: + :toctree: ../stubs/ + + remap_noise_model + insert_noise + approximate_quantum_error + approximate_noise_model +""" + +from .noise_remapper import remap_noise_model +from .noise_transformation import NoiseTransformer +from .noise_transformation import approximate_quantum_error +from .noise_transformation import approximate_noise_model +from .noise_model_inserter import insert_noise from . import qobj_utils diff --git a/qiskit/providers/aer/noise/utils/noise_model_inserter.py b/qiskit/providers/aer/utils/noise_model_inserter.py similarity index 100% rename from qiskit/providers/aer/noise/utils/noise_model_inserter.py rename to qiskit/providers/aer/utils/noise_model_inserter.py diff --git a/qiskit/providers/aer/noise/utils/noise_remapper.py b/qiskit/providers/aer/utils/noise_remapper.py similarity index 98% rename from qiskit/providers/aer/noise/utils/noise_remapper.py rename to qiskit/providers/aer/utils/noise_remapper.py index 16c10c2611..248c4b77a0 100644 --- a/qiskit/providers/aer/noise/utils/noise_remapper.py +++ b/qiskit/providers/aer/utils/noise_remapper.py @@ -16,8 +16,8 @@ import logging -from ..noise_model import NoiseModel -from ..noiseerror import NoiseError +from ..noise.noise_model import NoiseModel +from ..noise.noiseerror import NoiseError logger = logging.getLogger(__name__) diff --git a/qiskit/providers/aer/noise/utils/noise_transformation.py b/qiskit/providers/aer/utils/noise_transformation.py similarity index 99% rename from qiskit/providers/aer/noise/utils/noise_transformation.py rename to qiskit/providers/aer/utils/noise_transformation.py index 562ddb3dbc..2b254f57d4 100644 --- a/qiskit/providers/aer/noise/utils/noise_transformation.py +++ b/qiskit/providers/aer/utils/noise_transformation.py @@ -31,12 +31,12 @@ import logging import numpy -from qiskit.providers.aer.noise.errors import QuantumError -from qiskit.providers.aer.noise import NoiseModel -from qiskit.providers.aer.noise.noiseerror import NoiseError -from qiskit.providers.aer.noise.errors.errorutils import single_qubit_clifford_instructions from qiskit.quantum_info.operators.channel import Kraus from qiskit.quantum_info.operators.channel import SuperOp +from ..noise.errors import QuantumError +from ..noise.noise_model import NoiseModel +from ..noise.noiseerror import NoiseError +from ..noise.errors.errorutils import single_qubit_clifford_instructions logger = logging.getLogger(__name__) diff --git a/test/terra/noise/test_noise_inserter.py b/test/terra/noise/test_noise_inserter.py index b72a4a5d2a..f84fdf4f77 100644 --- a/test/terra/noise/test_noise_inserter.py +++ b/test/terra/noise/test_noise_inserter.py @@ -14,7 +14,7 @@ """ from qiskit import QuantumRegister, QuantumCircuit -from qiskit.providers.aer.noise.utils import insert_noise +from qiskit.providers.aer.utils import insert_noise from qiskit.providers.aer.noise import NoiseModel from qiskit.providers.aer.noise.errors.standard_errors import pauli_error from qiskit.qasm import pi diff --git a/test/terra/noise/test_noise_remapper.py b/test/terra/noise/test_noise_remapper.py index cbee8533af..185e4fda03 100644 --- a/test/terra/noise/test_noise_remapper.py +++ b/test/terra/noise/test_noise_remapper.py @@ -7,7 +7,7 @@ from qiskit.providers.aer.noise import NoiseModel from qiskit.providers.aer.noise.noiseerror import NoiseError from qiskit.providers.aer.noise.errors import depolarizing_error -from qiskit.providers.aer.noise.utils import remap_noise_model +from qiskit.providers.aer.utils import remap_noise_model class TestNoiseRemapper(common.QiskitAerTestCase): diff --git a/test/terra/noise/test_noise_transformation.py b/test/terra/noise/test_noise_transformation.py index 58cf09f212..a0fded0e5e 100644 --- a/test/terra/noise/test_noise_transformation.py +++ b/test/terra/noise/test_noise_transformation.py @@ -17,9 +17,9 @@ import numpy from qiskit.providers.aer.noise.errors.errorutils import standard_gate_unitary from qiskit.providers.aer.noise import NoiseModel -from qiskit.providers.aer.noise.utils import NoiseTransformer -from qiskit.providers.aer.noise.utils import approximate_quantum_error -from qiskit.providers.aer.noise.utils import approximate_noise_model +from qiskit.providers.aer.utils import NoiseTransformer +from qiskit.providers.aer.utils import approximate_quantum_error +from qiskit.providers.aer.utils import approximate_noise_model from qiskit.providers.aer.noise.errors.standard_errors import amplitude_damping_error from qiskit.providers.aer.noise.errors.standard_errors import reset_error from qiskit.providers.aer.noise.errors.standard_errors import pauli_error From dc903be4de99f6c7baa266426d24cca4e7a88e1b Mon Sep 17 00:00:00 2001 From: Christopher Wood Date: Fri, 31 Jan 2020 15:30:36 -0500 Subject: [PATCH 6/8] Update changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d205246b14..a5172ddda0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,9 +57,19 @@ Added Changed ------- +- Moved the location of several functions (\#568): + - Moved contents of `qiskit.provider.aer.noise.errors` into the `qiskit.providers.noise` module + - Moved contents of `qiskit.provider.aer.noise.device` into the `qiskit.providers.noise` module. + - Moved contents of `qiskit.provider.aer.noise.utils` into the `qiskit.provider.aer.utils` module. + +Deprecated +---------- +- Deprecated `utils.qobj_utils` functions (\#568) Removed ------- +- Removed `NoiseModel.as_dict`, `QuantumError.as_dict`, `ReadoutError.as_dict`, and + `QuantumError.kron` methods that were deprecated in 0.3 (\#568). Fixed ----- From 98eb69aed8947a26c2db93e457ad76fbc7132ba5 Mon Sep 17 00:00:00 2001 From: Christopher Wood Date: Fri, 31 Jan 2020 15:51:33 -0500 Subject: [PATCH 7/8] Update readme --- README.md | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 1964a9e860..e94e3b3288 100755 --- a/README.md +++ b/README.md @@ -26,42 +26,41 @@ $ python ``` ```python -from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute +from qiskit import QuantumCircuit, execute from qiskit import Aer, IBMQ # import the Aer and IBMQ providers -from qiskit.providers.aer import noise # import Aer noise models +from qiskit.providers.aer import noise # import Aer noise module # Choose a real device to simulate provider = IBMQ.load_account() -device = provider.get_backend('ibmq_16_melbourne') +device = provider.get_backend('ibmq_vigo') properties = device.properties() coupling_map = device.configuration().coupling_map # Generate an Aer noise model for device -noise_model = noise.device.basic_device_noise_model(properties) +noise_model = noise.basic_device_noise_model(properties) basis_gates = noise_model.basis_gates -# Generate a quantum circuit -q = QuantumRegister(2) -c = ClassicalRegister(2) -qc = QuantumCircuit(q, c) - -qc.h(q[0]) -qc.cx(q[0], q[1]) -qc.measure(q, c) +# Generate 3-qubit GHZ state +num_qubits = 3 +circ = QuantumCircuit(3, 3) +circ.h(0) +circ.cx(0, 1) +circ.cx(1, 2) +circ.measure([0, 1, 2], [0, 1 ,2]) # Perform noisy simulation backend = Aer.get_backend('qasm_simulator') -job_sim = execute(qc, backend, - coupling_map=coupling_map, - noise_model=noise_model, - basis_gates=basis_gates) -sim_result = job_sim.result() +job = execute(circ, backend, + coupling_map=coupling_map, + noise_model=noise_model, + basis_gates=basis_gates) +result = job.result() -print(sim_result.get_counts(qc)) +print(result.get_counts(0)) ``` ```python -{'11': 412, '00': 379, '10': 117, '01': 116} +{'000': 495, '001': 18, '010': 8, '011': 18, '100': 2, '101': 14, '110': 28, '111': 441} ``` From 091791e14e20b9688902abeeaf1ca5fd8af0cd17 Mon Sep 17 00:00:00 2001 From: Christopher Wood Date: Fri, 31 Jan 2020 15:58:02 -0500 Subject: [PATCH 8/8] Fixup shot value for statevector unitary * Change the max shots value of the statevector and unitary simulator from 1 to 1e6. This is so an exception isnt raised if these backends are called with default number of shots. Note that htese backends will only perform a single shot simulation regardless of the value of shots in the qobj. --- qiskit/providers/aer/backends/pulse_simulator.py | 4 ++-- qiskit/providers/aer/backends/qasm_simulator.py | 4 ++-- qiskit/providers/aer/backends/statevector_simulator.py | 8 ++++++-- qiskit/providers/aer/backends/unitary_simulator.py | 9 ++++++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/qiskit/providers/aer/backends/pulse_simulator.py b/qiskit/providers/aer/backends/pulse_simulator.py index db9a6a3a90..95fc93759b 100644 --- a/qiskit/providers/aer/backends/pulse_simulator.py +++ b/qiskit/providers/aer/backends/pulse_simulator.py @@ -98,8 +98,8 @@ class PulseSimulator(AerBackend): 'conditional': True, 'open_pulse': True, 'memory': False, - 'max_shots': 10**6, - 'description': 'A pulse-based Hamiltonian simulator', + 'max_shots': int(1e6), + 'description': 'A pulse-based Hamiltonian simulator for Pulse Qobj files', 'gates': [], 'basis_gates': [] } diff --git a/qiskit/providers/aer/backends/qasm_simulator.py b/qiskit/providers/aer/backends/qasm_simulator.py index ccfda4d51c..932f004aa4 100644 --- a/qiskit/providers/aer/backends/qasm_simulator.py +++ b/qiskit/providers/aer/backends/qasm_simulator.py @@ -207,8 +207,8 @@ class QasmSimulator(AerBackend): 'conditional': True, 'open_pulse': False, 'memory': True, - 'max_shots': 100000, - 'description': 'A C++ simulator with realistic noise for qobj files', + 'max_shots': int(1e6), + 'description': 'A C++ simulator with realistic noise for QASM Qobj files', 'coupling_map': None, 'basis_gates': [ 'u1', 'u2', 'u3', 'cx', 'cz', 'id', 'x', 'y', 'z', 'h', 's', 'sdg', diff --git a/qiskit/providers/aer/backends/statevector_simulator.py b/qiskit/providers/aer/backends/statevector_simulator.py index 92754ec080..cd3680eee1 100644 --- a/qiskit/providers/aer/backends/statevector_simulator.py +++ b/qiskit/providers/aer/backends/statevector_simulator.py @@ -80,8 +80,12 @@ class StatevectorSimulator(AerBackend): 'conditional': True, 'open_pulse': False, 'memory': True, - 'max_shots': 1, - 'description': 'A C++ statevector simulator for qobj files', + 'max_shots': int(1e6), # Note that this backend will only ever + # perform a single shot. This value is just + # so that the default shot value for execute + # will not raise an error when trying to run + # a simulation + 'description': 'A C++ statevector simulator for QASM Qobj files', 'coupling_map': None, 'basis_gates': [ 'u1', 'u2', 'u3', 'cx', 'cz', 'id', 'x', 'y', 'z', 'h', 's', 'sdg', diff --git a/qiskit/providers/aer/backends/unitary_simulator.py b/qiskit/providers/aer/backends/unitary_simulator.py index 3e94dd219c..c65d1b779d 100644 --- a/qiskit/providers/aer/backends/unitary_simulator.py +++ b/qiskit/providers/aer/backends/unitary_simulator.py @@ -87,9 +87,12 @@ class UnitarySimulator(AerBackend): 'conditional': False, 'open_pulse': False, 'memory': False, - 'max_shots': 1, - 'description': 'A Python simulator for computing the unitary' - 'matrix for experiments in qobj files', + 'max_shots': int(1e6), # Note that this backend will only ever + # perform a single shot. This value is just + # so that the default shot value for execute + # will not raise an error when trying to run + # a simulation + 'description': 'A C++ unitary simulator for QASM Qobj files', 'coupling_map': None, 'basis_gates': [ 'u1', 'u2', 'u3', 'cx', 'cz', 'id', 'x', 'y', 'z', 'h', 's', 'sdg',