diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..555bbb9a6d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,86 @@ +name: Build +on: + push: + branches: [master, 'stable/*'] + pull_request: + branches: [master, 'stable/*'] +jobs: + standalone: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["macOS-latest", "ubuntu-latest", "windows-latest"] + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Install deps + run: pip install "urllib3<1.26" conan + - name: Install openblas + run: | + set -e + sudo apt-get update + sudo apt-get install -y libopenblas-dev + shell: bash + if: runner.os == 'Linux' + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.0.2 + if: runner.os == 'Windows' + - name: Compile Standalone Windows + run: | + set -e + mkdir out; cd out; cmake .. -DBUILD_TESTS=1 + cmake --build . --config Release + shell: bash + if: runner.os == 'Windows' + - name: Compile Standalone + run: | + set -e + mkdir out; cd out; cmake .. -DBUILD_TESTS=1 + make + shell: bash + if: runner.os != 'Windows' + - name: Run Unit Tests + run: | + cd out/bin + for test in test* + do echo $test + if ! ./$test + then + ERR=1 + fi + done + if [ ! -z "$ERR" ] + then + exit 1 + fi + shell: bash + wheel: + runs-on: ${{ matrix.os }} + needs: ["standalone"] + strategy: + matrix: + os: ["macOS-latest", "ubuntu-latest"] + steps: + - uses: actions/checkout@v2 + - name: Set up Python Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install deps + run: python -m pip install -U cibuildwheel==1.7.0 + - 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_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" + CIBW_TEST_REQUIRES: "git+https://github.com/Qiskit/qiskit-terra.git" + run: cibuildwheel --output-dir wheelhouse + - uses: actions/upload-artifact@v2 + with: + path: ./wheelhouse/*.whl diff --git a/.github/workflows/wheels.yml b/.github/workflows/deploy.yml similarity index 83% rename from .github/workflows/wheels.yml rename to .github/workflows/deploy.yml index 932f0f8249..2ad5c1f7a0 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Build +name: Deploy on: push: tags: @@ -21,11 +21,11 @@ jobs: python -m pip install cibuildwheel==1.5.5 - name: Build wheels env: - CIBW_BEFORE_ALL_LINUX: "yum install -y openblas-devel" + 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 Cython pip virtualenv pybind11" CIBW_SKIP: "cp27-* cp34-* cp35-* pp*" - CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2010" - CIBW_MANYLINUX_I686_IMAGE: "manylinux2010" + 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" CIBW_TEST_REQUIRES: "git+https://github.com/Qiskit/qiskit-terra.git" run: | @@ -77,11 +77,11 @@ jobs: python -m pip install cibuildwheel==1.5.5 - 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" + 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_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: "manylinux2010" - CIBW_MANYLINUX_I686_IMAGE: "manylinux2010" + 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_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" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000000..893ab04efa --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,88 @@ +name: Docs and Tutorial +on: + push: + branches: [master, 'stable/*'] + pull_request: + branches: [master, 'stable/*'] +jobs: + docs: + runs-on: ubuntu-latest + timeout-minutes: 60 + strategy: + matrix: + python-version: [3.7] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-docs-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-docs- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install Deps + run: | + set -e + pip install -U pip virtualenv wheel + pip install -U tox + sudo apt-get update + sudo apt-get install -y build-essential libopenblas-dev + shell: bash + - name: Run Docs Build + run: tox -edocs + - uses: actions/upload-artifact@v2 + with: + name: html_docs + path: docs/_build/html + tutorials: + runs-on: ubuntu-latest + needs: [docs] + strategy: + matrix: + python-version: [3.7] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~\AppData\Local\pip\Cache + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-tutorials-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-tutorials- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}}- + - name: Setup tutorials job + run: | + set -e + git clone https://github.com/Qiskit/qiskit-tutorials --depth=1 + python -m pip install --upgrade pip wheel + pip install -U -r requirements-dev.txt -c constraints.txt + pip install -c constraints.txt git+https://github.com/Qiskit/qiskit-terra + pip install -c constraints.txt . + pip install -U "qiskit-ibmq-provider" "z3-solver" "qiskit-ignis" "qiskit-aqua" "pyscf<1.7.4" "matplotlib<3.3.0" jupyter pylatexenc sphinx nbsphinx sphinx_rtd_theme cvxpy -c constraints.txt + python setup.py build_ext --inplace + sudo apt install -y graphviz pandoc libopenblas-dev + pip check + shell: bash + - name: Run Tutorials + run: | + set -e + cd qiskit-tutorials + rm -rf tutorials/chemistry tutorials/circuits tutorials/circuits_advanced tutorials/finance tutorials/optimization tutorials/algorithms tutorials/operators tutorials/noise + sphinx-build -b html . _build/html + - uses: actions/upload-artifact@v2 + with: + name: tutorials_html + path: qiskit-tutorials/_build/html diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 5111b9e875..0000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,303 +0,0 @@ -name: Compile tests -on: - push: - branches: [master, 'stable/*'] - pull_request: - branches: [master, 'stable/*'] -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-lint-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} - restore-keys: | - ${{ runner.os }}-pip-lint- - ${{ runner.os }}-pip- - ${{ runner.os }}- - - name: Install deps - run: | - set -e - pip install -U pip wheel - pip install -U -c constraints.txt git+https://github.com/Qiskit/qiskit-terra - pip install -U -c constraints.txt -r requirements-dev.txt - shell: bash - - name: Run Lint - run: | - set -e - pycodestyle --ignore=E402,W504 --max-line-length=100 qiskit/providers/aer - pylint -j 2 -rn qiskit/providers/aer - docs: - runs-on: ubuntu-latest - timeout-minutes: 60 - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set up Python 3.7 - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-docs-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} - restore-keys: | - ${{ runner.os }}-pip-docs- - ${{ runner.os }}-pip- - ${{ runner.os }}- - - name: Install Deps - run: | - set -e - pip install -U pip virtualenv wheel - pip install -U tox - sudo apt-get update - sudo apt-get install -y build-essential libopenblas-dev - shell: bash - - name: Run Docs Build - run: tox -edocs - - uses: actions/upload-artifact@v2 - with: - name: html_docs - path: docs/_build/html - standalone: - name: compile-standalone-${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: ["macOS-latest", "ubuntu-latest", "windows-latest"] - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.7 - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - name: Install deps - run: pip install conan - - name: Install openblas - run: | - set -e - sudo apt-get update - sudo apt-get install -y libopenblas-dev - shell: bash - if: runner.os == 'Linux' - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.1 - if: runner.os == 'Windows' - - name: Compile Standalone Windows - run: | - set -e - mkdir out; cd out; cmake .. - cmake --build . --config Release - shell: bash - if: runner.os == 'Windows' - - name: Compile Standalone - run: | - set -e - mkdir out; cd out; cmake .. - make - shell: bash - if: runner.os != 'Windows' - sdist: - name: compile-sdist-python${{ matrix.python-version }}-${{ matrix.platform.os }} - runs-on: ${{ matrix.platform.os }} - needs: ["lint"] - strategy: - matrix: - python-version: [3.6, 3.7, 3.8] - platform: [ - { os: "macOS-latest", python-architecture: "x64"}, - { os: "ubuntu-latest", python-architecture: "x64" }, - ] - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-${{ matrix.python-version}}-pip-sdist-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.python-version}}-pip-sdist- - ${{ runner.os }}-${{ matrix.python-version}}-pip- - ${{ runner.os }}-${{ matrix.python-version}}- - - name: Install Deps - run: python -m pip install -U setuptools wheel virtualenv - - name: Install openblas - run: | - set -e - sudo apt-get update - sudo apt-get install -y libopenblas-dev - shell: bash - if: runner.os == 'Linux' - - name: Build Sdist - run: python setup.py sdist - - name: Install from sdist and test - run: | - set -e - mkdir out; cd out; virtualenv aer-test - aer-test/bin/pip install ../dist/*tar.gz - aer-test/bin/pip install -c ../constraints.txt git+https://github.com/Qiskit/qiskit-terra - aer-test/bin/python ../tools/verify_wheels.py - aer-test/bin/pip check - shell: bash - wheel: - name: compile-wheel-${{ matrix.os }} - runs-on: ${{ matrix.os }} - needs: ["lint"] - strategy: - matrix: - os: ["macOS-latest", "ubuntu-latest"] - steps: - - uses: actions/checkout@v2 - - name: Set up Python Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install deps - run: python -m pip install -U cibuildwheel==1.5.5 - - name: Build Wheels - env: - CIBW_BEFORE_ALL_LINUX: "yum install -y openblas-devel" - CIBW_BEFORE_BUILD: "pip install -U Cython virtualenv pybind11" - CIBW_SKIP: "cp27-* cp34-* cp35-* pp*" - CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2010" - CIBW_MANYLINUX_I686_IMAGE: "manylinux2010" - CIBW_TEST_COMMAND: "python3 {project}/tools/verify_wheels.py" - CIBW_TEST_REQUIRES: "git+https://github.com/Qiskit/qiskit-terra.git" - run: cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl - tests: - name: tests-python${{ matrix.python-version }}-${{ matrix.os }} - runs-on: ${{ matrix.os }} - needs: [standalone, sdist, lint, docs] - timeout-minutes: 25 - strategy: - matrix: - python-version: [3.6, 3.7, 3.8] - os: ["macOS-latest", "ubuntu-latest", "windows-latest"] - env: - AER_THRUST_BACKEND: OMP - QISKIT_TEST_CAPTURE_STREAMS: 1 - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - 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}}- - if: runner.os != 'Windows' - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-${{ matrix.python-version}}-pip-${{ 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}}- - if: runner.os == 'Windows' - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.1 - if: runner.os == 'Windows' - - name: Install Deps - run: python -m pip install -U -r requirements-dev.txt wheel git+https://github.com/Qiskit/qiskit-terra - - name: Install openblas - run: | - set -e - sudo apt-get update - sudo apt-get install -y libopenblas-dev - shell: bash - if: runner.os == 'Linux' - - name: Install Aer - run: python -m pip install -U . - if: runner.os != 'Windows' - - name: Install Aer Windows - run: | - set -e - python setup.py bdist_wheel -- -G 'Visual Studio 16 2019' - pip install --find-links=dist qiskit-aer - shell: bash - if: runner.os == 'Windows' - - name: Run Tests - env: - QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y - run: | - set -e - pip check - stestr run --slowest - shell: bash - if: runner.os != 'macOS' || matrix.python-version != '3.8' - - name: Run Tests macOS 3.8 - env: - QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y - QISKIT_IN_PARALLEL: TRUE - run: | - set -e - pip check - stestr run --slowest - shell: bash - if: runner.os == 'macOS' && matrix.python-version == '3.8' - tutorials: - name: Tutorials - runs-on: ubuntu-latest - needs: [standalone, sdist, lint, docs] - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.7 - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-pip-tutorials-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} - restore-keys: | - ${{ runner.os }}-pip-tutorials- - ${{ runner.os }}-pip- - ${{ runner.os }}- - - name: Setup tutorials job - run: | - set -e - git clone https://github.com/Qiskit/qiskit-tutorials --depth=1 - python -m pip install --upgrade pip wheel - pip install -U -r requirements-dev.txt -c constraints.txt - pip install -c constraints.txt git+https://github.com/Qiskit/qiskit-terra - pip install -c constraints.txt . - pip install -U "qiskit-ibmq-provider" "z3-solver" "qiskit-ignis" "qiskit-aqua" "pyscf<1.7.4" "matplotlib<3.3.0" jupyter pylatexenc sphinx nbsphinx sphinx_rtd_theme cvxpy -c constraints.txt - python setup.py build_ext --inplace - sudo apt install -y graphviz pandoc libopenblas-dev - pip check - shell: bash - - name: Run Tutorials - run: | - set -e - cd qiskit-tutorials - rm -rf tutorials/chemistry tutorials/circuits tutorials/circuits_advanced tutorials/finance tutorials/optimization tutorials/noise - sphinx-build -b html . _build/html - - uses: actions/upload-artifact@v2 - with: - name: tutorials_html - path: qiskit-tutorials/_build/html diff --git a/.github/workflows/tests_linux.yml b/.github/workflows/tests_linux.yml new file mode 100644 index 0000000000..ccb2523f74 --- /dev/null +++ b/.github/workflows/tests_linux.yml @@ -0,0 +1,126 @@ +name: Tests Linux +on: + push: + branches: [master, 'stable/*'] + pull_request: + branches: [master, 'stable/*'] +jobs: + lint: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-lint-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-lint- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install deps + run: | + set -e + pip install -U pip wheel + pip install -U -c constraints.txt git+https://github.com/Qiskit/qiskit-terra + pip install -U -c constraints.txt -r requirements-dev.txt + shell: bash + - name: Run Lint + run: | + set -e + pycodestyle --ignore=E402,W504 --max-line-length=100 qiskit/providers/aer + pylint -j 2 -rn qiskit/providers/aer + sdist: + runs-on: ${{ matrix.platform.os }} + needs: ["lint"] + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + platform: [ + { os: "ubuntu-latest", python-architecture: "x64" }, + ] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-sdist-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-sdist- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install Deps + run: python -m pip install -U setuptools wheel virtualenv + - name: Install openblas + run: | + set -e + sudo apt-get update + sudo apt-get install -y libopenblas-dev + shell: bash + - name: Build Sdist + run: python setup.py sdist + - name: Install from sdist and test + run: | + set -e + mkdir out; cd out; virtualenv aer-test + aer-test/bin/pip install ../dist/*tar.gz + aer-test/bin/pip install -c ../constraints.txt git+https://github.com/Qiskit/qiskit-terra + aer-test/bin/python ../tools/verify_wheels.py + aer-test/bin/pip check + shell: bash + tests: + runs-on: ${{ matrix.os }} + needs: [sdist, lint] + timeout-minutes: 25 + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + os: ["ubuntu-latest"] + env: + AER_THRUST_BACKEND: OMP + QISKIT_TEST_CAPTURE_STREAMS: 1 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - 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 Deps + run: python -m pip install -U -r requirements-dev.txt wheel git+https://github.com/Qiskit/qiskit-terra + - name: Install openblas + run: | + set -e + sudo apt-get update + sudo apt-get install -y libopenblas-dev + shell: bash + - name: Install Aer + run: python -m pip install -U . + - name: Run Tests + env: + QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y + run: | + set -e + pip check + stestr run --slowest + shell: bash diff --git a/.github/workflows/tests_mac.yml b/.github/workflows/tests_mac.yml new file mode 100644 index 0000000000..44045d0b74 --- /dev/null +++ b/.github/workflows/tests_mac.yml @@ -0,0 +1,125 @@ +name: Tests MacOS +on: + push: + branches: [master, 'stable/*'] + pull_request: + branches: [master, 'stable/*'] +jobs: + lint: + runs-on: macOS-latest + strategy: + matrix: + python-version: [3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-lint-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-lint- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install deps + run: | + set -e + pip install -U pip wheel + pip install -U -c constraints.txt git+https://github.com/Qiskit/qiskit-terra + pip install -U -c constraints.txt -r requirements-dev.txt + shell: bash + - name: Run Lint + run: | + set -e + pycodestyle --ignore=E402,W504 --max-line-length=100 qiskit/providers/aer + pylint -j 2 -rn qiskit/providers/aer + sdist: + runs-on: ${{ matrix.platform.os }} + needs: ["lint"] + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + platform: [ + { os: "macOS-latest", python-architecture: "x64"}, + ] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-sdist-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-sdist- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install Deps + run: python -m pip install -U setuptools wheel virtualenv + - name: Build Sdist + run: python setup.py sdist + - name: Install from sdist and test + run: | + set -e + mkdir out; cd out; virtualenv aer-test + aer-test/bin/pip install ../dist/*tar.gz + aer-test/bin/pip install -c ../constraints.txt git+https://github.com/Qiskit/qiskit-terra + aer-test/bin/python ../tools/verify_wheels.py + aer-test/bin/pip check + shell: bash + tests: + runs-on: ${{ matrix.os }} + needs: [sdist, lint] + timeout-minutes: 25 + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + os: ["macOS-latest"] + env: + AER_THRUST_BACKEND: OMP + QISKIT_TEST_CAPTURE_STREAMS: 1 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - 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 Deps + run: python -m pip install -U -r requirements-dev.txt wheel git+https://github.com/Qiskit/qiskit-terra + - name: Install Aer + run: python -m pip install -U . + - name: Run Tests + env: + QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y + run: | + set -e + pip check + stestr run --slowest + shell: bash + if: runner.os != 'macOS' || matrix.python-version != '3.8' + - name: Run Tests macOS 3.8 + env: + QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y + QISKIT_IN_PARALLEL: TRUE + run: | + set -e + pip check + stestr run --slowest + shell: bash + if: runner.os == 'macOS' && matrix.python-version == '3.8' diff --git a/.github/workflows/tests_windows.yml b/.github/workflows/tests_windows.yml new file mode 100644 index 0000000000..4e1a8e01d4 --- /dev/null +++ b/.github/workflows/tests_windows.yml @@ -0,0 +1,83 @@ +name: Tests Windows +on: + push: + branches: [master, 'stable/*'] + pull_request: + branches: [master, 'stable/*'] +jobs: + lint: + runs-on: windows-latest + strategy: + matrix: + python-version: [3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~\AppData\Local\pip\Cache + key: ${{ runner.os }}-${{ matrix.python-version}}-pip-lint-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version}}-pip-lint- + ${{ runner.os }}-${{ matrix.python-version}}-pip- + ${{ runner.os }}-${{ matrix.python-version}}- + - name: Install deps + run: | + set -e + pip install -U -c constraints.txt git+https://github.com/Qiskit/qiskit-terra + pip install -U -c constraints.txt -r requirements-dev.txt + shell: bash + - name: Run Lint + run: | + set -e + pycodestyle --ignore=E402,W504 --max-line-length=100 qiskit/providers/aer + pylint -j 2 -rn qiskit/providers/aer + shell: bash + tests: + runs-on: ${{ matrix.os }} + needs: ["lint"] + timeout-minutes: 25 + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + os: ["windows-latest"] + env: + AER_THRUST_BACKEND: OMP + QISKIT_TEST_CAPTURE_STREAMS: 1 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Pip cache + uses: actions/cache@v2 + with: + path: ~\AppData\Local\pip\Cache + 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: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.0.2 + - name: Install Deps + run: python -m pip install -U -r requirements-dev.txt wheel git+https://github.com/Qiskit/qiskit-terra + - name: Install Aer Windows + run: | + set -e + python setup.py bdist_wheel -- -G 'Visual Studio 16 2019' + pip install --find-links=dist qiskit-aer + shell: bash + - name: Run Tests + env: + QISKIT_SUPPRESS_PACKAGING_WARNINGS: Y + run: | + set -e + pip check + stestr run --slowest + shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 60b9bed3bf..6c52bf7a92 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,11 +45,20 @@ option(STATIC_LINKING "Specify if we want statically link the executable (for redistribution mainly)" FALSE) 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) +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) include(Linter) include(findBLASInSpecificPath) -include(conan_utils) +include(dependency_utils) # Get version information get_version(${VERSION_NUM}) @@ -137,29 +146,33 @@ endif() # # Looking for external libraries # - -setup_conan() +set(BACKEND_REDIST_DEPS "") # List of redistributable dependencies +setup_dependencies() # If we do not set them with a space CMake fails afterwards if nothing is set for this vars! set(AER_LINKER_FLAGS " ") set(AER_COMPILER_FLAGS " ") -message(STATUS "Looking for OpenMP support...") -if(APPLE) - set(OPENMP_FOUND TRUE) - if(NOT SKBUILD) - set(AER_LIBRARIES ${AER_LIBRARIES} CONAN_PKG::llvm-openmp) - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CONAN_CXX_FLAGS_LLVM-OPENMP}") - set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_LLVM-OPENMP}) - endif() -else() +if(NOT OPENMP_FOUND) # Could already be setup for macos with conan + message(STATUS "Looking for OpenMP support...") find_package(OpenMP QUIET) if(OPENMP_FOUND) set(AER_COMPILER_FLAGS "${AER_COMPILER_FLAGS} ${OpenMP_CXX_FLAGS}") set(AER_LINKER_FLAGS "${AER_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") + if(APPLE) + set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${OpenMP_CXX_INCLUDE_DIRS}) + # On Apple and clang, we do need to link against the library unless we are building + # the Terra Addon, see issue: https://github.com/Qiskit/qiskit-aer/issues/1 + if(NOT SKBUILD) + set(AER_LIBRARIES "${AER_LIBRARIES}" "${OpenMP_${OpenMP_CXX_LIB_NAMES}_LIBRARY}") + message(STATUS "Adding Clang: ${OpenMP_${OpenMP_CXX_LIB_NAMES}_LIBRARY}") + else() + get_filename_component(OPENMP_LIB_TO_COPY ${OpenMP_${OpenMP_CXX_LIB_NAMES}_LIBRARY} REALPATH) #Needed to follow symlinks + set(BACKEND_REDIST_DEPS ${BACKEND_REDIST_DEPS} ${OPENMP_LIB_TO_COPY}) + endif() + endif() message(STATUS "OpenMP found!") message(STATUS "OpenMP_CXX_FLAGS = ${OpenMP_CXX_FLAGS}") message(STATUS "OpenMP_EXE_LINKER_FLAGS = ${OpenMP_EXE_LINKER_FLAGS}") @@ -180,8 +193,8 @@ if(STATIC_LINKING) set(BLA_STATIC TRUE) endif() -if(BLAS_LIB_PATH) - find_BLAS_in_specific_path(${BLAS_LIB_PATH}) +if(AER_BLAS_LIB_PATH) + find_BLAS_in_specific_path(${AER_BLAS_LIB_PATH}) else() if(APPLE) message(STATUS "Looking for Apple BLAS & Lapack library...") @@ -197,7 +210,7 @@ else() set(WIN_ARCH "win32") endif() execute_process(COMMAND ${CMAKE_COMMAND} -E tar "xvfj" "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${WIN_ARCH}/lib/openblas.7z" WORKING_DIRECTORY "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${WIN_ARCH}/lib/") - set(OPENBLAS_DLLs "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${WIN_ARCH}/lib/libopenblas.dll") + set(BACKEND_REDIST_DEPS ${BACKEND_REDIST_DEPS} "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${WIN_ARCH}/lib/libopenblas.dll") set(BLAS_LIBRARIES "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${WIN_ARCH}/lib/libopenblas.dll.a") # Seems CMake is unable to find it on its own set(BLAS_FOUND True) else() @@ -249,21 +262,19 @@ if(AER_THRUST_SUPPORTED) set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -ccbin \"${CMAKE_CXX_COMPILER}\" ${AER_CUDA_ARCH_FLAGS_EXPAND} -DAER_THRUST_CUDA -I${AER_SIMULATOR_CPP_SRC_DIR} -isystem ${AER_SIMULATOR_CPP_SRC_DIR}/third-party/headers -use_fast_math --expt-extended-lambda") set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA) - set(THRUST_DEPENDANT_LIBS "") + set(THRUST_DEPENDENT_LIBS "") elseif(AER_THRUST_BACKEND STREQUAL "TBB") message(STATUS "TBB Support found!") - set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_THRUST}) - set(THRUST_DEPENDANT_LIBS CONAN_PKG::tbb) + set(THRUST_DEPENDENT_LIBS AER_DEPENDENCY_PKG::tbb) set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} AER_THRUST_CPU=TRUE) elseif(AER_THRUST_BACKEND STREQUAL "OMP") message(STATUS "Thrust library: Setting OMP backend") if(NOT OPENMP_FOUND) message(FATAL_ERROR "There's no OMP support. We cannot set Thrust backend to OMP!!") endif() - set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_THRUST}) set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} AER_THRUST_CPU=TRUE) # We don't need to add OMP because it's already an AER dependency - set(THRUST_DEPENDANT_LIBS "") + set(THRUST_DEPENDENT_LIBS "") else() message(STATUS "No Thrust supported backend") set(AER_THRUST_SUPPORTED FALSE) @@ -281,16 +292,16 @@ endif() set(AER_LIBRARIES ${AER_LIBRARIES} ${BLAS_LIBRARIES} - CONAN_PKG::nlohmann_json + AER_DEPENDENCY_PKG::nlohmann_json + AER_DEPENDENCY_PKG::spdlog Threads::Threads - CONAN_PKG::spdlog ${DL_LIB} - ${THRUST_DEPENDANT_LIBS}) + ${THRUST_DEPENDENT_LIBS}) set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} ${CONAN_DEFINES}) # Cython build is only enabled if building through scikit-build. if(SKBUILD) # Terra Addon build - set(AER_LIBRARIES ${AER_LIBRARIES} CONAN_PKG::muparserx) + set(AER_LIBRARIES ${AER_LIBRARIES} AER_DEPENDENCY_PKG::muparserx) add_subdirectory(qiskit/providers/aer/pulse/qutip_extra_lite/cy) add_subdirectory(qiskit/providers/aer/backends/wrappers) add_subdirectory(src/open_pulse) @@ -341,11 +352,11 @@ else() # Standalone build PRIVATE ${AER_SIMULATOR_CPP_EXTERNAL_LIBS}) target_compile_definitions(qasm_simulator PRIVATE ${AER_COMPILER_DEFINITIONS}) - if(WIN32 AND NOT BLAS_LIB_PATH) + if(WIN32 AND NOT AER_BLAS_LIB_PATH) add_custom_command(TARGET qasm_simulator POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${OPENBLAS_DLLs} + ${BACKEND_REDIST_DEPS} $) - install(FILES ${OPENBLAS_DLLs} DESTINATION bin) + install(FILES ${BACKEND_REDIST_DEPS} DESTINATION bin) endif() install(TARGETS qasm_simulator DESTINATION bin) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 159eca449b..f82b61c5f6 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,113 +1,9 @@ -# Code of Conduct - -## Our Pledge - -The Qiskit Community is dedicated to our values of treating every individual -with respect and dignity. In the interest of fostering an open and welcoming -environment, all participants, including attendees, speakers, sponsors, -volunteers, online contributors, and IBM employees are expected to show -courtesy for each other and our community by creating a harassment-free -experience for everyone, regardless of age, personal appearance, disability, -ethnicity, gender identity and expression, body size, level of experience, -nationality, race, religion, caste, or sexual identity and orientation. -Expected behavior applies to both online and offline engagement within the -Qiskit Community. - -## Scope - -The purpose of this Code of Conduct is to define and enforce the values and -conduct of contributors and participants in the Qiskit open source community. -The Code of Conduct applies both within project spaces and in public spaces -when an individual is engaging with the Qiskit open source community. Examples -include attending a Qiskit event, contributing to online projects, commentary -on Slack, or representing a project or community, including using an official -project e-mail address, posting via an official social media account, or -acting as an appointed representative at an online or offline event. -Representation of a project may be further defined and clarified by project -maintainers. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: + -- Using welcoming and inclusive language -- Being respectful of differing viewpoints, experiences, and cultures -- Gracefully accepting constructive criticism -- Focusing on what is best for the community -- Showing empathy towards other community members -- Being mindful of your surroundings and your fellow participants and listening - to others -- Valuing the contributions of all participants -- Engaging in collaboration before conflict -- Pointing out unintentionally racist, sexist, casteist, or biased comments and - jokes made by community members when they happen - -Examples of unacceptable behavior by participants, even when presented as -"ironic" or "joking," include: - -- The use of sexualized language or imagery and unwelcome physical contact, - sexual attention, or advances -- Trolling, insulting/derogatory comments, and personal or political attacks -- Public or private harassment, including offensive or degrading language -- Publishing others' private information, such as a physical or electronic - address, without explicit permission. This includes any sort of "outing" of - any aspect of someone's identity without their consent. -- "Doxxing," Publishing screenshots or quotes, especially from identity slack - channels, private chat, or public events, without all quoted users' explicit - consent. -- Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Responsibilities & Enforcement - -The entire Qiskit community is responsible for upholding the terms of the Code -of Conduct in Qiskit Community events and spaces and reporting violations if -they see them. The internal Qiskit team at IBM is ultimately responsible for -clarifying the standards of acceptable behavior and enforcement, and is expected -to take appropriate and fair corrective action in response to any instances of -unacceptable behavior. - -If a participant or contributor engages in negative or harmful behavior, IBM -will take any action they deem appropriate, including but not limited to -issuing warnings, expulsion from an event with no refund, deleting comments, -permanent banning from future events or online community, or calling local law -enforcement. IBM has the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, or to temporarily or permanently ban any -contributor or participant for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -If you see a Code of Conduct violation: +# Code of Conduct +All members of this project agree to adhere to the Qiskit Code of Conduct listed at [https://github.com/Qiskit/qiskit/blob/master/CODE_OF_CONDUCT.md](https://github.com/Qiskit/qiskit/blob/master/CODE_OF_CONDUCT.md) -1. If you feel comfortable, let the person know that what they did is not - appropriate and ask them to stop and/or edit or delete their message(s) or - comment(s). -2. If the person does not immediately stop the behavior or correct the issue, - or if you're uncomfortable speaking up, flag a moderator and, if appropriate, - fill out the anonymous - [Code of Conduct violation form](https://airtable.com/shrl5mEF4Eun1aIDm). -3. The Qiskit Community will open an investigation upon receiving your form - entry. When reporting, please include any relevant details, links, - screenshots, context, or other information that may be used to better - understand and resolve the situation. -4. If the code of conduct violation occurs at an event and requires immediate - response or contains a concern about an individual attending an upcoming - event, contact the event's on-call Code of Conduct point of contact listed - in the event specific code of conduct document. If you don't feel comfortable - speaking to the point of contact in person, fill out a Code of Conduct - violation form entry and include the details of the event so that the Code of - Conduct enforcement board can contact the event's on-call Code of Conduct - point of contact. -5. If an IBM employee witnesses a Code of Conduct violation at any time, such as - at events, in a Slack channel, or open source forums, it is their - responsibility to file a Code of Conduct violation report. +---- -This Code of Conduct does not supersede existing IBM corporate policies, such as -the IBM Business Conduct Guidelines and IBM Business Partner Code of Conduct. -IBM employees must follow IBM's Business Conduct Guidelines. IBM's business -partners must follow the IBM Business Partner Code of Conduct. IBM employees -concerned with a fellow IBMer's behavior should follow IBM's own internal HR -reporting protocols, which include engaging the offending IBMer's manager and -involving IBM Concerns and Appeals. IBM employees concerned with an IBM -business partner's behavior should notify tellibm@us.ibm.com. +License: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), +Copyright Contributors to Qiskit. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5f8a0ace60..68fc2d0cdf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -249,7 +249,7 @@ window $ git clone https://github.com/Qiskit/qiskit-aer ``` -- Next, install the platform-specific dependencies for your operating system [Linux](#linux-dependencies) | [macOS](#mac-dependencies) | [Windows](#win-dependencies). +- Next, install the platform-specific dependencies for your operating system [Linux](#linux-dependencies) | [macOS](#mac-dependencies) | [Windows](#win-dependencies). - The common dependencies can then be installed via *pip*, using the `requirements-dev.txt` file, e.g.: @@ -258,11 +258,14 @@ window $ pip install -r requirements-dev.txt ``` -This will also install [**Conan**](https://conan.io/), a C/C++ package manager written in Python. This tool will handle -most of the dependencies needed by the C++ source code. Internet connection may be needed for the first build or -when dependencies are added/updated, in order to download the required packages if they are not in your **Conan** local +This will also install [**Conan**](https://conan.io/), a C/C++ package manager written in Python. This tool will handle +most of the dependencies needed by the C++ source code. Internet connection may be needed for the first build or +when dependencies are added/updated, in order to download the required packages if they are not in your **Conan** local repository. +> Note: Conan use can be disabled with the flag or environment variable ``DISABLE_CONAN=ON`` . +This is useful for building from source offline, or to reuse the installed package dependencies. + If we are only building the standalone version and do not want to install all Python requirements you can just install **Conan**: @@ -607,7 +610,7 @@ For example, qiskit-aer$ python ./setup.py bdist_wheel -- -DAER_THRUST_BACKEND=CUDA -If we want to specify the CUDA® architecture instead of letting the build system +If we want to specify the CUDA® architecture instead of letting the build system auto detect it, we can use the AER_CUDA_ARCH flag (can also be set as an ENV variable with the same name, although the flag takes precedence). For example: @@ -661,7 +664,7 @@ These are the flags: Tells CMake the directory to look for the BLAS library instead of the usual paths. If no BLAS library is found under that directory, CMake will raise an error and stop. - + It can also be set as an ENV variable with the same name, although the flag takes precedence. Values: An absolute path. @@ -700,11 +703,29 @@ These are the flags: This flag allows us we to specify the CUDA architecture instead of letting the build system auto detect it. It can also be set as an ENV variable with the same name, although the flag takes precedence. - + Values: Auto | Common | All | List of valid CUDA architecture(s). Default: Auto Example: ``python ./setup.py bdist_wheel -- -DAER_THRUST_BACKEND=CUDA -DAER_CUDA_ARCH="5.2; 5.3"`` +* DISABLE_CONAN + + This flag allows disabling the Conan package manager. This will force CMake to look for + the libraries in use on your system path, relying on FindPackage CMake mechanism and + the appropriate configuration of libraries in order to use it. + If a specific version is not found, the build system will look for any version available, + although this may produce build errors or incorrect behaviour. + + __WARNING__: This is not the official procedure to build AER. Thus, the user is responsible + of providing all needed libraries and corresponding files to make them findable to CMake. + + This is also available as the environment variable ``DISABLE_CONAN``, which overrides + the CMake flag of the same name. + + Values: ON | OFF + Default: OFF + Example: ``python ./setup.py bdist_wheel -- -DDISABLE_CONAN=ON`` + ## Tests Code contribution are expected to include tests that provide coverage for the diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a3e0787417..1f1f7b4299 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -147,15 +147,6 @@ stages: submodules: true - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" displayName: Add conda to PATH - - task: Cache@2 - inputs: - key: 'pip | "$(Agent.OS)" | "$(python.version)" |"$(Build.BuildNumber)"' - restoreKeys: | - pip | "$(Agent.OS)" | "$(python.version)" - pip | "$(Agent.OS)" - pip - path: $(PIP_CACHE_DIR) - displayName: Cache pip - bash: | set -x set -e @@ -193,15 +184,6 @@ stages: submodules: true - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" displayName: Add conda to PATH - - task: Cache@2 - inputs: - key: 'pip | "$(Agent.OS)" | "$(python.version)" |"$(Build.BuildNumber)"' - restoreKeys: | - pip | "$(Agent.OS)" | "$(python.version)" - pip | "$(Agent.OS)" - pip - path: $(PIP_CACHE_DIR) - displayName: Cache pip - bash: | set -x set -e @@ -254,15 +236,6 @@ stages: submodules: true - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" displayName: Add conda to PATH - - task: Cache@2 - inputs: - key: 'pip | "$(Agent.OS)" | "$(python.version)" |"$(Build.BuildNumber)"' - restoreKeys: | - pip | "$(Agent.OS)" | "$(python.version)" - pip | "$(Agent.OS)" - pip - path: $(PIP_CACHE_DIR) - displayName: Cache pip - bash: | set -x set -e diff --git a/cmake/conan_utils.cmake b/cmake/conan_utils.cmake index 9f9720a60b..2fbc30f53b 100644 --- a/cmake/conan_utils.cmake +++ b/cmake/conan_utils.cmake @@ -1,13 +1,20 @@ include(conan) +macro(_rename_conan_lib package) + add_library(AER_DEPENDENCY_PKG::${package} INTERFACE IMPORTED) + target_link_libraries(AER_DEPENDENCY_PKG::${package} PUBLIC INTERFACE CONAN_PKG::${package}) +endmacro() + macro(setup_conan) # Right now every dependency shall be static set(CONAN_OPTIONS ${CONAN_OPTIONS} "*:shared=False") set(REQUIREMENTS nlohmann_json/3.1.1 spdlog/1.5.0) + list(APPEND AER_CONAN_LIBS nlohmann_json spdlog) if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(REQUIREMENTS ${REQUIREMENTS} llvm-openmp/8.0.1) + list(APPEND AER_CONAN_LIBS llvm-openmp) if(SKBUILD) set(CONAN_OPTIONS ${CONAN_OPTIONS} "llvm-openmp:shared=True") endif() @@ -15,6 +22,7 @@ macro(setup_conan) 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() @@ -22,12 +30,17 @@ macro(setup_conan) if(AER_THRUST_BACKEND AND NOT AER_THRUST_BACKEND STREQUAL "CUDA") set(REQUIREMENTS ${REQUIREMENTS} thrust/1.9.5) + list(APPEND AER_CONAN_LIBS thrust) string(TOLOWER ${AER_THRUST_BACKEND} THRUST_BACKEND) set(CONAN_OPTIONS ${CONAN_OPTIONS} "thrust:device_system=${THRUST_BACKEND}") + if(THRUST_BACKEND MATCHES "tbb") + list(APPEND AER_CONAN_LIBS tbb) + endif() endif() if(BUILD_TESTS) set(REQUIREMENTS ${REQUIREMENTS} catch2/2.12.1) + list(APPEND AER_CONAN_LIBS catch2) endif() # Add Appleclang-12 until officially supported by Conan @@ -40,4 +53,25 @@ macro(setup_conan) CMAKE_TARGETS KEEP_RPATHS BUILD missing) + + # Headers includes + if(AER_THRUST_BACKEND AND NOT AER_THRUST_BACKEND STREQUAL "CUDA") + set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_THRUST}) + endif() + + # Reassign targets from CONAN_PKG to AER_DEPENDENCY_PKG + foreach(CONAN_LIB ${AER_CONAN_LIBS}) + _rename_conan_lib(${CONAN_LIB}) + endforeach() + + if(APPLE) + set(OPENMP_FOUND TRUE) + if(NOT SKBUILD) + set(AER_LIBRARIES ${AER_LIBRARIES} AER_DEPENDENCY_PKG::llvm-openmp) + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CONAN_CXX_FLAGS_LLVM-OPENMP}") + set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_LLVM-OPENMP}) + set(BACKEND_REDIST_DEPS ${BACKEND_REDIST_DEPS} "${CONAN_LIB_DIRS_LLVM-OPENMP}/libomp.dylib") + endif() + endif() endmacro() diff --git a/cmake/dependency_utils.cmake b/cmake/dependency_utils.cmake new file mode 100644 index 0000000000..0952da0a2e --- /dev/null +++ b/cmake/dependency_utils.cmake @@ -0,0 +1,64 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2020 +# +# 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. + + +macro(setup_dependencies) + # Defines AER_DEPENDENCY_PKG alias which refers to either conan-provided or system libraries. + if(DISABLE_CONAN) + _use_system_libraries() + else() + include(conan_utils) + setup_conan() + endif() +endmacro() + +macro(_use_system_libraries) + # Use system libraries + _import_aer_system_dependency(nlohmann_json 3.1.1) + _import_aer_system_dependency(spdlog 1.5.0) + + 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) + endif() + + if(BUILD_TESTS) + _import_aer_system_dependency(Catch2 2.12.1) + endif() + + if(APPLE) + # Fix linking. See https://stackoverflow.com/questions/54068035 + link_directories(/usr/local/lib) #brew + link_directories(/opt/local/lib) #ports + endif() +endmacro() + +macro(_import_aer_system_dependency package version) + # Arguments: + # package: name of package to search for using find_package() + # version: version of package to search for + + find_package(${package} ${version} EXACT QUIET) + if(NOT ${package}_FOUND) + message(STATUS "${package} ${version} NOT found! Looking for any other version available.") + find_package(${package} REQUIRED) + message(STATUS "${package} version found: ${${package}_VERSION}. WARNING: This version may not work!!!") + endif() + string(TOLOWER ${package} PACKAGE_LOWER) # Conan use lowercase for every lib + add_library(AER_DEPENDENCY_PKG::${PACKAGE_LOWER} INTERFACE IMPORTED) + target_link_libraries(AER_DEPENDENCY_PKG::${PACKAGE_LOWER} PUBLIC INTERFACE ${package}) + message(STATUS "Using system-provided ${PACKAGE_LOWER} library") +endmacro() diff --git a/docs/conf.py b/docs/conf.py index 3fb1f4358f..49d0d093f6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -46,7 +46,7 @@ # The short X.Y version version = '' # The full version, including alpha/beta/rc tags -release = '0.7.1' +release = '0.7.2' # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 04b39f580f..0e00e6d818 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,2 @@ [build-system] -requires = ["setuptools", "wheel", "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"] diff --git a/qiskit/providers/aer/VERSION.txt b/qiskit/providers/aer/VERSION.txt index 39e898a4f9..7486fdbc50 100644 --- a/qiskit/providers/aer/VERSION.txt +++ b/qiskit/providers/aer/VERSION.txt @@ -1 +1 @@ -0.7.1 +0.7.2 diff --git a/qiskit/providers/aer/backends/backend_utils.py b/qiskit/providers/aer/backends/backend_utils.py index 053722aeae..6d080cc465 100644 --- a/qiskit/providers/aer/backends/backend_utils.py +++ b/qiskit/providers/aer/backends/backend_utils.py @@ -61,6 +61,7 @@ def available_methods(controller, methods): for method in methods: qobj = assemble(dummy_circ, optimization_level=0, + shots=1, method=method) result = cpp_execute(controller, qobj) if result.get('success', False): diff --git a/qiskit/providers/aer/backends/wrappers/CMakeLists.txt b/qiskit/providers/aer/backends/wrappers/CMakeLists.txt index 9f03653bd7..e3cff03581 100644 --- a/qiskit/providers/aer/backends/wrappers/CMakeLists.txt +++ b/qiskit/providers/aer/backends/wrappers/CMakeLists.txt @@ -44,8 +44,4 @@ target_compile_definitions(controller_wrappers PRIVATE ${AER_COMPILER_DEFINITION install(TARGETS controller_wrappers LIBRARY DESTINATION qiskit/providers/aer/backends) # Install redistributable dependencies -if(APPLE) - install(FILES "${CONAN_LIB_DIRS_LLVM-OPENMP}/libomp.dylib" DESTINATION qiskit/providers/aer/backends) -elseif(WIN32 AND NOT BLAS_LIB_PATH) - install(FILES ${OPENBLAS_DLLs} DESTINATION qiskit/providers/aer/backends) -endif() +install(FILES ${BACKEND_REDIST_DEPS} DESTINATION qiskit/providers/aer/backends) diff --git a/qiskit/providers/aer/pulse/controllers/digest_pulse_qobj.py b/qiskit/providers/aer/pulse/controllers/digest_pulse_qobj.py index e504e75d66..b0a3d8a557 100644 --- a/qiskit/providers/aer/pulse/controllers/digest_pulse_qobj.py +++ b/qiskit/providers/aer/pulse/controllers/digest_pulse_qobj.py @@ -340,7 +340,9 @@ def experiment_to_structs(experiment, ham_chans, pulse_inds, pulse_to_int, dt, q structs['channels'][chan_name][1].extend([inst['t0'] * dt, inst['phase'], cond]) - + # Delay instruction + elif inst['name'] == 'delay': + pass # nothing to be done in this case # A standard pulse else: start = inst['t0'] * dt diff --git a/releasenotes/notes/cmake-optional-conan-bc99a895fc4345e1.yaml b/releasenotes/notes/cmake-optional-conan-bc99a895fc4345e1.yaml new file mode 100644 index 0000000000..ba3343d86f --- /dev/null +++ b/releasenotes/notes/cmake-optional-conan-bc99a895fc4345e1.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + Add the CMake flag ``DISABLE_CONAN`` (default=``OFF``)s. When installing from source, + setting this to ``ON`` allows bypassing the Conan package manager to find libraries + that are already installed on your system. This is also available as an environment + variable ``DISABLE_CONAN``, which takes precedence over the CMake flag. + This is not the official procedure to build AER. Thus, the user is responsible + of providing all needed libraries and corresponding files to make them findable to CMake. diff --git a/releasenotes/notes/fix-omp-nested-9d120cd1a08725ab.yaml b/releasenotes/notes/fix-omp-nested-9d120cd1a08725ab.yaml new file mode 100644 index 0000000000..bab20a0be8 --- /dev/null +++ b/releasenotes/notes/fix-omp-nested-9d120cd1a08725ab.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes a bug with nested OpenMP flag was being set to true when it + shouldn't be. diff --git a/requirements-dev.txt b/requirements-dev.txt index 0b1eb58f5a..28811fb80a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,7 +4,7 @@ conan>=1.22.2 scikit-build cython asv -cvxpy>=1.0.0 +cvxpy>=1.0.0;python_version>'3.6' and python_version<='3.8' pylint pycodestyle Sphinx>=1.8.3 @@ -14,3 +14,6 @@ sphinx-automodapi jupyter-sphinx;python_version<'3.8' reno>=3.1.0 ddt>=1.2.0,!=1.4.0 + +# Problem with Conan and urllib3==1.26 +urllib3<1.26 diff --git a/setup.py b/setup.py index e0d5ad6cc6..cf88f2b5e9 100644 --- a/setup.py +++ b/setup.py @@ -3,13 +3,17 @@ """ Main setup file for qiskit-aer """ - +import distutils.util +import importlib +import inspect import os +import setuptools import subprocess import sys -import inspect + PACKAGE_NAME = os.getenv('QISKIT_AER_PACKAGE_NAME', 'qiskit-aer') +_DISABLE_CONAN = distutils.util.strtobool(os.getenv("DISABLE_CONAN", "OFF").lower()) try: from Cython.Build import cythonize @@ -18,11 +22,15 @@ subprocess.call([sys.executable, '-m', 'pip', 'install', 'Cython>=0.27.1']) from Cython.Build import cythonize -try: - from conans import client -except ImportError: - subprocess.call([sys.executable, '-m', 'pip', 'install', 'conan']) - from conans import client +if not _DISABLE_CONAN: + try: + from conans import client + except ImportError: + # Problem with Conan and urllib3 1.26 + subprocess.call([sys.executable, '-m', 'pip', 'install', 'urllib3<1.26']) + + subprocess.call([sys.executable, '-m', 'pip', 'install', 'conan']) + from conans import client try: from skbuild import setup @@ -34,7 +42,8 @@ except ImportError: subprocess.call([sys.executable, '-m', 'pip', 'install', 'pybind11>=2.4']) -import setuptools +from skbuild import setup + # These are requirements that are both runtime/install dependencies and # also build time/setup requirements and will be added to both lists @@ -52,8 +61,10 @@ setup_requirements = common_requirements + [ 'scikit-build', 'cmake!=3.17,!=3.17.0', - 'conan>=1.22.2' ] +if not _DISABLE_CONAN: + setup_requirements.append('urllib3<1.26') + setup_requirements.append('conan>=1.22.2') requirements = common_requirements + ['qiskit-terra>=0.12.0'] diff --git a/src/controllers/controller.hpp b/src/controllers/controller.hpp index b2c7fccda2..ec93065adc 100755 --- a/src/controllers/controller.hpp +++ b/src/controllers/controller.hpp @@ -217,6 +217,7 @@ class Controller { int parallel_experiments_; int parallel_shots_; int parallel_state_update_; + bool parallel_nested_ = false; }; //========================================================================= @@ -251,6 +252,7 @@ void Controller::set_config(const json_t &config) { max_parallel_threads_ = 1; max_parallel_shots_ = 1; max_parallel_experiments_ = 1; + parallel_nested_ = false; #endif // Load configurations for parallelization @@ -297,6 +299,7 @@ void Controller::clear_parallelization() { parallel_experiments_ = 1; parallel_shots_ = 1; parallel_state_update_ = 1; + parallel_nested_ = false; explicit_parallelization_ = false; max_memory_mb_ = get_system_memory_mb() / 2; @@ -517,8 +520,24 @@ Result Controller::execute(std::vector &circuits, result.metadata["max_memory_mb"] = max_memory_mb_; #ifdef _OPENMP - if (parallel_shots_ > 1 || parallel_state_update_ > 1) + // Check if circuit parallelism is nested with one of the others + if (parallel_experiments_ > 1 && parallel_experiments_ < max_parallel_threads_) { + // Nested parallel experiments + parallel_nested_ = true; + #ifdef _WIN32 omp_set_nested(1); + #else + omp_set_max_active_levels(3); + #endif + result.metadata["omp_nested"] = parallel_nested_; + } else { + parallel_nested_ = false; + #ifdef _WIN32 + omp_set_nested(0); + #else + omp_set_max_active_levels(1); + #endif + } #endif // then- and else-blocks have intentionally duplication. // Nested omp has significant overheads even though a guard condition exists. @@ -620,6 +639,27 @@ void Controller::execute_circuit(Circuit &circ, // Vector to store parallel thread output data std::vector par_results(parallel_shots_); std::vector error_msgs(parallel_shots_); + + #ifdef _OPENMP + if (!parallel_nested_) { + if (parallel_shots_ > 1 && parallel_state_update_ > 1) { + // Nested parallel shots + state update + #ifdef _WIN32 + omp_set_nested(1); + #else + omp_set_max_active_levels(2); + #endif + result.metadata["omp_nested"] = true; + } else { + #ifdef _WIN32 + omp_set_nested(0); + #else + omp_set_max_active_levels(1); + #endif + } + } + #endif + #pragma omp parallel for if (parallel_shots_ > 1) num_threads(parallel_shots_) for (int i = 0; i < parallel_shots_; i++) { try { diff --git a/src/misc/clang_omp_symbols.hpp b/src/misc/clang_omp_symbols.hpp index 5d405d2b2b..0e3bae3671 100644 --- a/src/misc/clang_omp_symbols.hpp +++ b/src/misc/clang_omp_symbols.hpp @@ -218,6 +218,11 @@ extern "C" { void __KAI_KMPC_CONVENTION omp_set_nested(int foo){ _hook_omp_set_nested(foo); } + using omp_set_max_active_levels_t = void(*)(int); + omp_set_max_active_levels_t _hook_omp_set_max_active_levels; + void __KAI_KMPC_CONVENTION omp_set_max_active_levels(int foo){ + _hook_omp_set_max_active_levels(foo); + } using omp_get_num_procs_t = int(*)(void); omp_get_num_procs_t _hook_omp_get_num_procs; int __KAI_KMPC_CONVENTION omp_get_num_procs(void) { @@ -325,6 +330,7 @@ void populate_hooks(void * handle){ _hook_omp_get_num_threads = reinterpret_cast(dlsym(handle, "omp_get_num_threads")); _hook_omp_get_thread_num = reinterpret_cast(dlsym(handle, "omp_get_thread_num")); _hook_omp_set_nested = reinterpret_cast(dlsym(handle, "omp_set_nested")); + _hook_omp_set_max_active_levels = reinterpret_cast(dlsym(handle, "omp_set_max_active_levels")); _hook_omp_get_num_procs = reinterpret_cast(dlsym(handle, "omp_get_num_procs")); } diff --git a/src/misc/gcc_omp_symbols.hpp b/src/misc/gcc_omp_symbols.hpp index 3268d1dbee..3ff2b0f162 100644 --- a/src/misc/gcc_omp_symbols.hpp +++ b/src/misc/gcc_omp_symbols.hpp @@ -71,6 +71,11 @@ extern "C" { void __KAI_KMPC_CONVENTION omp_set_nested(int foo){ _hook_omp_set_nested(foo); } + using omp_set_max_active_levels_t = void(*)(int); + omp_set_max_active_levels_t _hook_omp_set_max_active_levels; + void __KAI_KMPC_CONVENTION omp_set_max_active_levels(int foo){ + _hook_omp_set_max_active_levels(foo); + } using omp_get_num_threads_t = int(*)(void); omp_get_num_threads_t _hook_omp_get_num_threads; int __KAI_KMPC_CONVENTION omp_get_num_threads(void) { @@ -101,6 +106,7 @@ namespace Hacks { _hook_omp_get_num_threads = reinterpret_cast(dlsym(handle, "omp_get_num_threads")); _hook_omp_get_max_threads = reinterpret_cast(dlsym(handle, "omp_get_max_threads")); _hook_omp_set_nested = reinterpret_cast(dlsym(handle, "omp_set_nested")); + _hook_omp_set_max_active_levels = reinterpret_cast(dlsym(handle, "omp_set_max_active_levels")); _hook_omp_get_thread_num = reinterpret_cast(dlsym(handle, "omp_get_thread_num")); _hook_omp_get_num_procs = reinterpret_cast(dlsym(handle, "omp_get_num_procs")); } diff --git a/src/simulators/statevector/qv_avx2.cpp b/src/simulators/statevector/qv_avx2.cpp index adf9f2e60f..8434e037c0 100644 --- a/src/simulators/statevector/qv_avx2.cpp +++ b/src/simulators/statevector/qv_avx2.cpp @@ -22,7 +22,7 @@ /** * DISCLAIMER: We want to compile this code in isolation of the rest of the *codebase, because it contains AVX specific instructions, so is very CPU arch - *dependant. We will detect CPU features at runtime and derive the execution + *dependent. We will detect CPU features at runtime and derive the execution *path over here if AVX is supported, if it's not supported the QubitVector *normal class will be used instead (so no SIMD whatsoever). Because of this, we *don't want to depend on any other library, otherwise the linker could take AVX diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fe9b1589b1..ea92f6946c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,9 +8,14 @@ macro(add_test_executable target_name) PRIVATE ${AER_SIMULATOR_CPP_SRC_DIR} PRIVATE ${AER_SIMULATOR_CPP_EXTERNAL_LIBS}) target_link_libraries(${target_name} - PRIVATE CONAN_PKG::catch2 + PRIVATE AER_DEPENDENCY_PKG::catch2 PRIVATE ${AER_LIBRARIES}) add_test(${target_name} ${target_name}) + if(WIN32 AND NOT BLAS_LIB_PATH) + add_custom_command(TARGET test_linalg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${BACKEND_REDIST_DEPS} + $) + endif() endmacro() add_test_executable(test_linalg "src/test_linalg.cpp") diff --git a/test/src/test_linalg.cpp b/test/src/test_linalg.cpp index f1fdfffecc..e3843f1544 100644 --- a/test/src/test_linalg.cpp +++ b/test/src/test_linalg.cpp @@ -12,6 +12,8 @@ * that they have been altered from the originals. */ +#define _USE_MATH_DEFINES +#include #include #include #include diff --git a/test/terra/backends/qasm_simulator/qasm_fusion.py b/test/terra/backends/qasm_simulator/qasm_fusion.py index a10f4947ce..b5d54ea4b5 100644 --- a/test/terra/backends/qasm_simulator/qasm_fusion.py +++ b/test/terra/backends/qasm_simulator/qasm_fusion.py @@ -188,7 +188,7 @@ def test_kraus_noise_fusion(self): backend=self.SIMULATOR, basis_gates=noise_model.basis_gates, optimization_level=0) - qobj = assemble([circuit], + qobj = assemble(circuit, self.SIMULATOR, shots=shots, seed_simulator=1) @@ -217,7 +217,7 @@ def test_non_kraus_noise_fusion(self): backend=self.SIMULATOR, basis_gates=noise_model.basis_gates, optimization_level=0) - qobj = assemble([circuit], + qobj = assemble(circuit, self.SIMULATOR, shots=shots, seed_simulator=1) diff --git a/test/terra/backends/test_config_pulse_simulator.py b/test/terra/backends/test_config_pulse_simulator.py index c88185b4df..171ff48c5a 100644 --- a/test/terra/backends/test_config_pulse_simulator.py +++ b/test/terra/backends/test_config_pulse_simulator.py @@ -66,7 +66,7 @@ def test_from_backend(self): for idx, entry in enumerate(sim_dict[key]): for entry_key in entry: if entry_key == 'samples': - self.assertTrue(all(entry[entry_key] == backend_dict[key][idx][entry_key])) + self.assertTrue(np.array_equal(entry[entry_key], backend_dict[key][idx][entry_key])) else: self.assertTrue(entry[entry_key] == backend_dict[key][idx][entry_key]) else: diff --git a/test/terra/noise/test_noise_transformation.py b/test/terra/noise/test_noise_transformation.py index a35eb7a40f..edda242942 100644 --- a/test/terra/noise/test_noise_transformation.py +++ b/test/terra/noise/test_noise_transformation.py @@ -13,6 +13,7 @@ NoiseTransformer class tests """ +import unittest from ..common import QiskitAerTestCase import numpy @@ -26,7 +27,13 @@ from qiskit.providers.aer.noise.errors.standard_errors import pauli_error from qiskit.providers.aer.noise.errors.quantum_error import QuantumError +try: + import cvxpy + HAS_CVXPY = True +except ImportError: + HAS_CVXPY = False +@unittest.skipUnless(HAS_CVXPY, 'cvxpy is required to run these tests') class TestNoiseTransformer(QiskitAerTestCase): def setUp(self): super().setUp()