Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj committed Feb 5, 2024
2 parents 07794b4 + 03221ac commit fa9e02e
Show file tree
Hide file tree
Showing 17 changed files with 279 additions and 181 deletions.
57 changes: 36 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,18 @@ jobs:
aer-test/bin/pip check
shell: bash
tests_linux:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
name: Linux Python ${{ matrix.python-version }}${{ matrix.qiskit-extra && format(' ({0})', matrix.qiskit-extra) }}
needs: [sdist, lint]
timeout-minutes: 60
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
os: ["ubuntu-latest"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12.0"]
qiskit-extra: [""]
include:
- python-version: "3.10"
qiskit-extra: "'qiskit>=1.0.0rc1'"

env:
AER_THRUST_BACKEND: OMP
QISKIT_TEST_CAPTURE_STREAMS: 1
Expand All @@ -116,17 +121,19 @@ jobs:
${{ runner.os }}-${{ matrix.python-version}}-pip-test-
${{ runner.os }}-${{ matrix.python-version}}-pip-
${{ runner.os }}-${{ matrix.python-version}}-
- name: Install Deps
run: python -m pip install -U -c constraints.txt -r requirements-dev.txt wheel
- name: Install openblas
run: |
set -e
sudo apt-get update
sudo apt-get install -y libopenblas-dev
shell: bash
- name: Install Aer
- name: Install Aer and dependencies
run: |
python -m pip install -U .
python -m pip install -U \
-c constraints.txt \
-r requirements-dev.txt \
${{ matrix.qiskit-extra }} \
.
- name: Run Tests
run: |
set -e
Expand Down Expand Up @@ -185,13 +192,13 @@ jobs:
stestr run --slowest
shell: bash
tests_macos:
runs-on: ${{ matrix.os }}
runs-on: macOS-latest
name: macOS Python ${{ matrix.python-version }}
needs: [sdist, lint]
timeout-minutes: 60
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", '3.11']
os: ["macOS-latest"]
python-version: [3.8, 3.9, "3.10", '3.11', "3.12.0"]
env:
AER_THRUST_BACKEND: OMP
QISKIT_TEST_CAPTURE_STREAMS: 1
Expand All @@ -214,12 +221,13 @@ jobs:
${{ runner.os }}-${{ matrix.python-version}}-pip-test-
${{ runner.os }}-${{ matrix.python-version}}-pip-
${{ runner.os }}-${{ matrix.python-version}}-
- name: Install Deps
- name: Install Aer and dependencies
run: |
set -e
pip install -U -c constraints.txt -r requirements-dev.txt
- name: Install Aer
run: python -m pip install -U .
pip install -U \
-c constraints.txt \
-r requirements-dev.txt \
.
- name: Run Tests
run: |
set -e
Expand All @@ -228,13 +236,13 @@ jobs:
stestr run --slowest
shell: bash
tests_windows:
runs-on: ${{ matrix.os }}
runs-on: windows-2019
name: Windows Python ${{ matrix.python-version }}
needs: ["lint", "sdist"]
timeout-minutes: 60
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
os: ["windows-2019"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12.0"]
env:
AER_THRUST_BACKEND: OMP
QISKIT_TEST_CAPTURE_STREAMS: 1
Expand All @@ -259,15 +267,22 @@ jobs:
${{ runner.os }}-${{ matrix.python-version}}-
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
- name: Install Deps
run: python -m pip install -U -c constraints.txt -r requirements-dev.txt wheel build
- name: Install Aer Windows
- name: Build Aer Windows
env:
CMAKE_GENERATOR: "Visual Studio 16 2019"
run: |
set -e
pip install build
python -I -m build --wheel
pip install --find-links=dist qiskit-aer
shell: bash
- name: Install Aer and dependencies
run: |
set -e
shopt -s failglob
pip install -U \
-c constraints.txt \
-r requirements-dev.txt \
dist/*.whl
shell: bash
- name: Run Tests
env:
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/unit-tests-latest-qiskit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Unit Tests for latest Qiskit
on:
schedule:
- cron: '0 5 * * *'
concurrency:
group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
unit-tests-latest-qiskit:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
AER_THRUST_BACKEND: OMP
QISKIT_TEST_CAPTURE_STREAMS: 1
# Needed to suppress a warning in jupyter-core 5.x by eagerly migrating to
# a new internal interface that will be the default in jupyter-core 6.x.
# This variable should become redundant on release of jupyter-core 6.
JUPYTER_PLATFORM_DIRS: 1
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version}}-pip-test-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version}}-pip-test-
${{ runner.os }}-${{ matrix.python-version}}-pip-
${{ runner.os }}-${{ matrix.python-version}}-
- name: Install openblas
run: |
set -e
sudo apt-get update
sudo apt-get install -y libopenblas-dev
shell: bash
- name: Install dependencies and Aer
run: |
python -m pip install -U setuptools wheel
python -m pip install -U \
-c constraints.txt \
-r requirements-dev.txt \
'git+https://github.com/Qiskit/qiskit.git@main' \
.
- name: Run Tests
run: |
set -e
pip check
rm -rf qiskit_aer
stestr run --slowest
shell: bash

1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ 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_aer/backends/wrappers)
else() # Standalone build
set(AER_LIBRARIES
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $ python
```python
import qiskit
from qiskit_aer import AerSimulator
from qiskit.providers.fake_provider import FakeManilaV2
from qiskit_ibm_runtime import QiskitRuntimeService

# Generate 3-qubit GHZ state
circ = qiskit.QuantumCircuit(3)
Expand All @@ -71,10 +71,10 @@ counts_ideal = result_ideal.get_counts(0)
print('Counts(ideal):', counts_ideal)
# Counts(ideal): {'000': 493, '111': 531}

# Construct a noisy simulator backend from an IBMQ backend
# This simulator backend will be automatically configured
# using the device configuration and noise model
backend = FakeManilaV2()
# Construct a simulator using a noise model
# from a real backend.
provider = QiskitRuntimeService()
backend = provider.get_backend("ibm_kyoto")
aersim_backend = AerSimulator.from_backend(backend)

# Perform noisy simulation
Expand Down
10 changes: 1 addition & 9 deletions cmake/conan_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,7 @@ macro(setup_conan)
endif()
endif()

if(SKBUILD)
set(REQUIREMENTS ${REQUIREMENTS} muparserx/4.0.8)
list(APPEND AER_CONAN_LIBS muparserx)
if(NOT MSVC)
set(CONAN_OPTIONS ${CONAN_OPTIONS} "muparserx:fPIC=True")
endif()
endif()

if(AER_THRUST_BACKEND AND NOT AER_THRUST_BACKEND STREQUAL "CUDA")
if(AER_THRUST_BACKEND AND NOT AER_THRUST_BACKEND STREQUAL "CUDA" AND NOT AER_THRUST_BACKEND STREQUAL "ROCM")
set(REQUIREMENTS ${REQUIREMENTS} thrust/1.9.5)
list(APPEND AER_CONAN_LIBS thrust)
string(TOLOWER ${AER_THRUST_BACKEND} THRUST_BACKEND)
Expand Down
4 changes: 0 additions & 4 deletions cmake/dependency_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ macro(_use_system_libraries)
_import_aer_system_dependency(nlohmann_json 3.1.1)
_import_aer_system_dependency(spdlog 1.9.2)

if(SKBUILD)
_import_aer_system_dependency(muparserx 4.0.8)
endif()

if(AER_THRUST_BACKEND AND NOT AER_THRUST_BACKEND STREQUAL "CUDA")
string(TOLOWER ${AER_THRUST_BACKEND} THRUST_BACKEND)
_import_aer_system_dependency(Thrust 1.9.5)
Expand Down
8 changes: 7 additions & 1 deletion qiskit_aer/primitives/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ def __init__(
If approximation is True, this parameter is ignored and assumed to be False.
"""
super().__init__(options=run_options)
# These three private attributes used to be created by super, but were deprecated in Qiskit
# 0.46. See https://github.com/Qiskit/qiskit/pull/11051
self._circuits = []
self._parameters = []
self._observables = []

backend_options = {} if backend_options is None else backend_options
method = (
Expand Down Expand Up @@ -161,7 +166,8 @@ def _run(
parameter_values,
**run_options,
)
job.submit()
# The public submit method was removed in Qiskit 0.46
(job.submit if hasattr(job, "submit") else job._submit)() # pylint: disable=no-member
return job

def _compute(self, circuits, observables, parameter_values, run_options):
Expand Down
8 changes: 7 additions & 1 deletion qiskit_aer/primitives/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def __init__(
skip_transpilation: if True, transpilation is skipped.
"""
super().__init__(options=run_options)
# These two private attributes used to be created by super, but were deprecated in Qiskit
# 0.46. See https://github.com/Qiskit/qiskit/pull/11051
self._circuits = []
self._parameters = []

self._backend = AerSimulator()
backend_options = {} if backend_options is None else backend_options
self._backend.set_options(**backend_options)
Expand Down Expand Up @@ -151,7 +156,8 @@ def _run(
self._circuits.append(circuit)
self._parameters.append(circuit.parameters)
job = PrimitiveJob(self._call, circuit_indices, parameter_values, **run_options)
job.submit()
# The public submit method was removed in Qiskit 0.46
(job.submit if hasattr(job, "submit") else job._submit)() # pylint: disable=no-member
return job

@staticmethod
Expand Down
54 changes: 0 additions & 54 deletions test/terra/backends/aer_simulator/test_from_backend.py

This file was deleted.

14 changes: 10 additions & 4 deletions test/terra/backends/aer_simulator/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@
"""

from ddt import ddt, data
from qiskit import QuantumCircuit, transpile
from qiskit_aer.noise import NoiseModel
from test.terra.backends.simulator_test_case import SimulatorTestCase, supported_methods

import qiskit
from qiskit import QuantumCircuit, transpile
from qiskit.quantum_info.random import random_unitary
from qiskit.quantum_info import state_fidelity
from qiskit.providers.fake_provider import FakeMontreal

if qiskit.__version__.startswith("0."):
from qiskit.providers.fake_provider import FakeAlmaden as Fake20QV1
else:
from qiskit.providers.fake_provider import Fake20QV1

from qiskit_aer import AerSimulator

Expand Down Expand Up @@ -299,8 +305,8 @@ def test_statevector_memory(self):
def test_num_qubits(self, method):
"""Test number of qubits is correctly checked"""

num_qubits = FakeMontreal().configuration().num_qubits
backend = AerSimulator.from_backend(FakeMontreal(), method=method)
num_qubits = Fake20QV1().configuration().num_qubits
backend = AerSimulator.from_backend(Fake20QV1(), method=method)
self.assertGreaterEqual(backend.configuration().num_qubits, num_qubits)

def test_mps_svd_method(self):
Expand Down
13 changes: 10 additions & 3 deletions test/terra/backends/aer_simulator/test_truncate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@
AerSimulator Integration Tests
"""
from ddt import ddt
from qiskit import transpile, QuantumCircuit, Aer
from qiskit.providers.fake_provider import FakeQuito

import qiskit
from qiskit import transpile, QuantumCircuit

if qiskit.__version__.startswith("0."):
from qiskit.providers.fake_provider import FakeQuito as Fake5QV1
else:
from qiskit.providers.fake_provider import Fake5QV1

from qiskit_aer.noise import NoiseModel
from test.terra.backends.simulator_test_case import SimulatorTestCase, supported_methods

Expand Down Expand Up @@ -46,7 +53,7 @@ def create_circuit_for_truncate(self):
return circuit

def device_backend(self):
return FakeQuito()
return Fake5QV1()

def test_truncate_ideal_sparse_circuit(self):
"""Test qubit truncation for large circuit with unused qubits."""
Expand Down
Loading

0 comments on commit fa9e02e

Please sign in to comment.