Skip to content

Commit

Permalink
Merge pull request #1111 from chriseclectic/backports-0.7.3
Browse files Browse the repository at this point in the history
Release 0.7.3 backports
  • Loading branch information
chriseclectic authored Jan 25, 2021
2 parents f1293f1 + ace05f8 commit b508a7d
Show file tree
Hide file tree
Showing 28 changed files with 454 additions and 100 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ jobs:
with:
python-version: 3.8
- name: Install deps
run: python -m pip install -U cibuildwheel==1.7.0
run: python -m pip install -U cibuildwheel==1.7.1
- name: Build Wheels
env:
CIBW_BEFORE_ALL_LINUX: "yum install -y https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm && yum install -y openblas-devel"
CIBW_BEFORE_BUILD: "pip install -U virtualenv pybind11"
CIBW_SKIP: "cp27-* cp34-* cp35-* cp39-* pp*"
CIBW_SKIP: "cp27-* cp34-* cp35-* pp*"
CIBW_MANYLINUX_X86_64_IMAGE: "quay.io/pypa/manylinux2010_x86_64:2020-12-03-912b0de"
CIBW_MANYLINUX_I686_IMAGE: "quay.io/pypa/manylinux2010_i686:2020-12-03-912b0de"
CIBW_TEST_COMMAND: "python3 {project}/tools/verify_wheels.py"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
python-version: '3.7'
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel==1.5.5
python -m pip install cibuildwheel==1.7.1
- name: Build wheels
env:
CIBW_BEFORE_ALL_LINUX: "yum install -y https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm && yum install -y openblas-devel"
Expand Down Expand Up @@ -74,14 +74,14 @@ jobs:
python-version: '3.7'
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel==1.5.5
python -m pip install cibuildwheel==1.7.1
- name: Build wheels
env:
CIBW_BEFORE_ALL: "yum install -y yum-utils wget && wget https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-rhel6-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm && rpm -i cuda-repo-rhel6-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm && yum clean all && yum -y install cuda-10-1 && yum install -y https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm"
CIBW_BEFORE_ALL: "yum install -y yum-utils wget && wget https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-rhel6-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm && rpm -i cuda-repo-rhel6-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm && yum clean all && yum -y install cuda-10-1"
CIBW_BEFORE_BUILD: "pip install -U Cython pip virtualenv pybind11 && yum install -y openblas-devel"
CIBW_SKIP: "cp27-* cp34-* cp35-* *-manylinux_i686 pp*"
CIBW_MANYLINUX_X86_64_IMAGE: "quay.io/pypa/manylinux2010_x86_64:2020-12-03-912b0de"
CIBW_MANYLINUX_I686_IMAGE: "quay.io/pypa/manylinux2010_i686:2020-12-03-912b0de"
CIBW_MANYLINUX_X86_64_IMAGE: "quay.io/pypa/manylinux2010_x86_64:latest"
CIBW_MANYLINUX_I686_IMAGE: "quay.io/pypa/manylinux2010_i686:latest"
CIBW_ENVIRONMENT: QISKIT_AER_PACKAGE_NAME=qiskit-aer-gpu AER_THRUST_BACKEND=CUDA CUDACXX=/usr/local/cuda/bin/nvcc
CIBW_TEST_COMMAND: "python3 {project}/tools/verify_wheels.py"
CIBW_TEST_REQUIRES: "git+https://github.com/Qiskit/qiskit-terra.git"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
needs: ["lint"]
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]
platform: [
{ os: "ubuntu-latest", python-architecture: "x64" },
]
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
timeout-minutes: 25
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]
os: ["ubuntu-latest"]
env:
AER_THRUST_BACKEND: OMP
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
needs: ["lint"]
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]
platform: [
{ os: "macOS-latest", python-architecture: "x64"},
]
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
timeout-minutes: 25
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]
os: ["macOS-latest"]
env:
AER_THRUST_BACKEND: OMP
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
timeout-minutes: 25
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]
os: ["windows-latest"]
env:
AER_THRUST_BACKEND: OMP
Expand Down
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@ option(BUILD_TESTS "Specify whether we want to build tests or not" FALSE)

# Allow disabling conan for downstream package managers. Requires all libraries to be present in path
# Default is value of environment variable if defined or ON
if(DEFINED ENV{DISABLE_CONAN})
set(_DISABLE_CONAN_DEFAULT ENV{DISABLE_CONAN})
else()
set(_DISABLE_CONAN_DEFAULT OFF)
if(NOT DEFINED DISABLE_CONAN AND DEFINED ENV{DISABLE_CONAN})
set(DISABLE_CONAN $ENV{DISABLE_CONAN})
endif()
option(DISABLE_CONAN "Disable Conan package manager to find dependencies. If disabled, you must have all dependencies present on your system." ${_DISABLE_CONAN_DEFAULT})

include(CTest)
include(compiler_utils)
Expand Down
8 changes: 6 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ stages:
python.version: '3.7'
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
variables:
PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip
steps:
Expand Down Expand Up @@ -229,6 +231,8 @@ stages:
python.version: '3.7'
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
variables:
PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip
steps:
Expand All @@ -243,7 +247,7 @@ stages:
source activate qiskit-aer
conda update --yes -n base conda
conda config --add channels conda-forge
conda install --yes --quiet --name qiskit-aer python=$(python.version) numpy cmake pip setuptools pybind11 cython scipy
conda install --yes --quiet --name qiskit-aer python=$(python.version) numpy cmake pip setuptools wheel pybind11 cython scipy
displayName: Create Anaconda environments
- bash: |
set -x
Expand All @@ -255,7 +259,7 @@ stages:
set -x
set -e
source activate qiskit-aer
pip install -U setuptools wheel
pip install -U setuptools
pip install dist/*tar.gz
pip install git+https://github.com/Qiskit/qiskit-terra
python tools/verify_wheels.py
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = '0.7.2'
release = '0.7.3'

# -- General configuration ---------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[build-system]
requires = ["setuptools", "wheel", "urllib3<1.26", "conan>=1.22.2", "scikit-build", "cmake!=3.17.1,!=3.17.0", "ninja", "pybind11>2.4", "Cython>0.27.1"]
requires = ["setuptools", "wheel", "urllib3<1.26", "conan>=1.22.2", "scikit-build",
"cmake!=3.17.1,!=3.17.0", "ninja", "pybind11>2.4", "Cython>0.27.1", "numpy>1.16.3"]
2 changes: 1 addition & 1 deletion qiskit/providers/aer/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.2
0.7.3
89 changes: 63 additions & 26 deletions qiskit/providers/aer/backends/qasm_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,18 @@ class QasmSimulator(AerBackend):
'max_shots': int(1e6),
'description': 'A C++ QasmQobj simulator with noise',
'coupling_map': None,
'basis_gates': [
'basis_gates': sorted([
'u1', 'u2', 'u3', 'u', 'p', 'r', 'rx', 'ry', 'rz', 'id', 'x',
'y', 'z', 'h', 's', 'sdg', 'sx', 't', 'tdg', 'swap', 'cx',
'cy', 'cz', 'csx', 'cp', 'cu1', 'cu2', 'cu3', 'rxx', 'ryy',
'rzz', 'rzx', 'ccx', 'cswap', 'mcx', 'mcy', 'mcz', 'mcsx',
'mcp', 'mcu1', 'mcu2', 'mcu3', 'mcrx', 'mcry', 'mcrz',
'mcr', 'mcswap', 'unitary', 'diagonal', 'multiplexer',
'initialize', 'kraus', 'roerror', 'delay'
],
'initialize', 'delay',
# Custom instructions
'kraus', 'roerror', 'snapshot'
]),
'custom_instructions': sorted(['roerror', 'kraus', 'snapshot']),
'gates': []
}

Expand All @@ -291,6 +294,9 @@ def __init__(self,

if configuration is None:
configuration = self._method_configuration()
elif not hasattr(configuration, 'custom_instructions'):
configuration.custom_instructions = []

super().__init__(configuration,
properties=properties,
available_methods=QasmSimulator._AVAILABLE_METHODS,
Expand All @@ -312,6 +318,12 @@ def from_backend(cls, backend, **options):
name = configuration.backend_name
configuration.backend_name = 'qasm_simulator({})'.format(name)

# Basis gates and Custom instructions
basis_gates = set(configuration.basis_gates)
custom_instr = cls._DEFAULT_CONFIGURATION['custom_instructions']
configuration.custom_instructions = sorted(custom_instr)
configuration.basis_gates = sorted(basis_gates.union(custom_instr))

# Use automatic noise model if none is provided
if 'noise_model' not in options:
noise_model = NoiseModel.from_backend(backend)
Expand Down Expand Up @@ -348,27 +360,49 @@ def _set_option(self, key, value):
# If key is noise_model we also change the simulator config
# to use the noise_model basis gates by default.
if key == 'noise_model' and value is not None:
self._set_configuration_option('basis_gates', value.basis_gates)
basis_gates = set(self._configuration.basis_gates) # Method basis gates
intersection = basis_gates.intersection(value.basis_gates)
self._check_basis_gates(basis_gates, value.basis_gates, intersection)
self._set_option('basis_gates', intersection)

# If key is method we update our configurations
if key == 'method':
method_config = self._method_configuration(value)
self._set_configuration_option('description', method_config.description)
self._set_configuration_option('backend_name', method_config.backend_name)
self._set_configuration_option('n_qubits', method_config.n_qubits)

# Take intersection of method basis gates and noise model basis gates
# if there is a noise model which has already set the basis gates
basis_gates = method_config.basis_gates
self._set_configuration_option('custom_instructions',
method_config.custom_instructions)
# Take intersection of method basis gates with configuration
# basis gates and noise model basis gates
basis_gates = set(self._configuration.basis_gates)
basis_gates = basis_gates.intersection(method_config.basis_gates)
if 'noise_model' in self.options:
noise_basis_gates = self.options['noise_model'].basis_gates
basis_gates = list(
set(basis_gates).intersection(noise_basis_gates))
self._set_configuration_option('basis_gates', basis_gates)
noise_gates = self.options['noise_model'].basis_gates
intersection = basis_gates.intersection(noise_gates)
self._check_basis_gates(basis_gates, noise_gates, intersection)
basis_gates = intersection
self._set_option('basis_gates', basis_gates)

# When setting basis gates always append custom simulator instructions for
# the current method
if key == 'basis_gates':
value = sorted(set(value).union(self.configuration().custom_instructions))

# Set all other options from AerBackend
super()._set_option(key, value)

@staticmethod
def _check_basis_gates(method_gates, noise_gates, intersection=None):
"""Check if intersection of method basis gates and noise basis gates is empty"""
if intersection is None:
intersection = set(method_gates).intersection(noise_gates)
if not intersection:
logger.warning(
"The intersection of NoiseModel basis gates (%s) and "
"backend basis gates (%s) is empty",
sorted(noise_gates), sorted(method_gates))

def _validate(self, qobj):
"""Semantic validations of the qobj which cannot be done via schemas.
Expand Down Expand Up @@ -409,38 +443,41 @@ def _method_configuration(method=None):
]:
config.n_qubits = config.n_qubits // 2
config.description = 'A C++ QasmQobj density matrix simulator with noise'
config.basis_gates = [
config.custom_instructions = sorted(['roerror', 'snapshot', 'kraus', 'superop'])
config.basis_gates = sorted([
'u1', 'u2', 'u3', 'u', 'p', 'r', 'rx', 'ry', 'rz', 'id', 'x',
'y', 'z', 'h', 's', 'sdg', 'sx', 't', 'tdg', 'swap', 'cx',
'cy', 'cz', 'cp', 'cu1', 'rxx', 'ryy',
'rzz', 'rzx', 'ccx', 'unitary', 'diagonal', 'kraus', 'superop'
'roerror', 'delay'
]
'cy', 'cz', 'cp', 'cu1', 'rxx', 'ryy', 'rzz', 'rzx', 'ccx',
'unitary', 'diagonal', 'delay',
] + config.custom_instructions)

# Matrix product state method
elif method == 'matrix_product_state':
config.description = 'A C++ QasmQobj matrix product state simulator with noise'
config.basis_gates = [
config.custom_instructions = sorted(['roerror', 'snapshot', 'kraus'])
config.basis_gates = sorted([
'u1', 'u2', 'u3', 'u', 'p', 'cp', 'cx', 'cz', 'id', 'x', 'y', 'z', 'h', 's',
'sdg', 'sx', 't', 'tdg', 'swap', 'ccx', 'unitary', 'roerror', 'delay'
]
'sdg', 'sx', 't', 'tdg', 'swap', 'ccx', 'unitary', 'delay'
] + config.custom_instructions)

# Stabilizer method
elif method == 'stabilizer':
config.n_qubits = 5000 # TODO: estimate from memory
config.description = 'A C++ QasmQobj Clifford stabilizer simulator with noise'
config.basis_gates = [
config.custom_instructions = sorted(['roerror', 'snapshot'])
config.basis_gates = sorted([
'id', 'x', 'y', 'z', 'h', 's', 'sdg', 'sx', 'cx', 'cy', 'cz',
'swap', 'roerror', 'delay'
]
'swap', 'delay',
] + config.custom_instructions)

# Extended stabilizer method
elif method == 'extended_stabilizer':
config.n_qubits = 63 # TODO: estimate from memory
config.description = 'A C++ QasmQobj ranked stabilizer simulator with noise'
config.basis_gates = [
config.custom_instructions = sorted(['roerror', 'snapshot'])
config.basis_gates = sorted([
'cx', 'cz', 'id', 'x', 'y', 'z', 'h', 's', 'sdg', 'sx', 'swap',
'u0', 'u1', 'p', 'ccx', 'ccz', 'roerror', 'delay'
]
'u0', 'u1', 'p', 'ccx', 'ccz', 'delay'
] + config.custom_instructions)

return config
19 changes: 12 additions & 7 deletions qiskit/providers/aer/noise/noise_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ class NoiseModel:

# Checks for standard 1-3 qubit instructions
_1qubit_instructions = set([
"x90", "u1", "u2", "u3", "U", "id", "x", "y", "z", "h", "s", "sdg",
"t", "tdg", "r", "rx", "ry", "rz", "p"
])
_2qubit_instructions = set(["cx", "cy", "cz", "swap", "rxx", "ryy", "rzz",
"rzx", "cu1", "cu2", "cu3", "cp"])
_3qubit_instructions = set(["ccx", "cswap"])
'u1', 'u2', 'u3', 'u', 'p', 'r', 'rx', 'ry', 'rz', 'id', 'x',
'y', 'z', 'h', 's', 'sdg', 'sx', 't', 'tdg'])
_2qubit_instructions = set([
'swap', 'cx', 'cy', 'cz', 'csx', 'cp', 'cu1', 'cu2', 'cu3', 'rxx',
'ryy', 'rzz', 'rzx'])
_3qubit_instructions = set(['ccx', 'cswap'])

def __init__(self, basis_gates=None):
"""Initialize an empty noise model.
Expand Down Expand Up @@ -271,15 +271,20 @@ def from_backend(cls, backend,
"""
if isinstance(backend, BaseBackend):
properties = backend.properties()
basis_gates = backend.configuration().basis_gates
if not properties:
raise NoiseError('Qiskit backend {} does not have a '
'BackendProperties'.format(backend))
elif isinstance(backend, BackendProperties):
properties = backend
basis_gates = set()
for prop in properties.gates:
basis_gates.add(prop.gate)
basis_gates = list(basis_gates)
else:
raise NoiseError('{} is not a Qiskit backend or'
' BackendProperties'.format(backend))
noise_model = NoiseModel()
noise_model = NoiseModel(basis_gates=basis_gates)

# Add single-qubit readout errors
if readout_error:
Expand Down
10 changes: 10 additions & 0 deletions releasenotes/notes/add-python3.9-83b3b4e5c3d59571.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
features:
- |
Python 3.9 support has been added in this release. You can now run Qiskit
Aer using Python 3.9 without building from source.
deprecations:
- |
Python 3.6 support has been deprecated and will be removed in a future
release. When support is removed you will need to upgrade the Python
version you're using to Python 3.7 or above.
11 changes: 11 additions & 0 deletions releasenotes/notes/fix-backend-noise-model-f22e9d6254d70852.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
fixes:
- |
Fixes issue with setting :class:`~qiskit.providers.aer.QasmSimulator`
basis gates when using ``"method"`` and ``"noise_model"`` options
together, and when using them with a simulator constructed using
:meth:`~qiskit.providers.aer.QasmSimulator.from_backend`. Now the
listed basis gates will be the intersection of gates supported by
the backend configuration, simulation method, and noise model basis
gates. If the intersection of the noise model basis gates and
simulator basis gates is empty a warning will be logged.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Fixes a bug that resulted in `c_if` not working when the
width of the conditional register was greater than 64. See
`#1077 <https://github.com/Qiskit/qiskit-aer/issues/1077>`.
11 changes: 11 additions & 0 deletions releasenotes/notes/fix-noise-basis-gates-ecdfa43394ff78e3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
fixes:
- |
Fixes bug in
:meth:`~qiskit.providers.aer.noise.NoiseModel.from_backend` and
:meth:`~qiskit.providers.aer.QasmSimulator.from_backend` where
:attr:`~qiskit.providers.aer.noise.NoiseModel.basis_gates` was set
incorrectly for IBMQ devices with basis gate set
``['id', 'rz', 'sx', 'x', 'cx']``. Now the noise model will always
have the same basis gates as the backend basis gates regardless of
whether those instructions have errors in the noise model or not.
Loading

0 comments on commit b508a7d

Please sign in to comment.