From 80e302638c587b134aa35c55edb454a0a4082129 Mon Sep 17 00:00:00 2001 From: Michael Hucka Date: Thu, 5 Sep 2024 10:51:02 -0700 Subject: [PATCH 1/3] Slightly relax tolerance in a test case of Apply1InteriorArbitrary (#671) The test case in third_party/qsim/tests/mps_simulator_test.cc on line 262 fails if the Eigen linear algebra library is updated to a recent version available from https://gitlab.com/libeigen/eigen. Specifically, commit 59498c96 in the Eigen repo (which can be seen at https://gitlab.com/libeigen/eigen/-/merge_requests/1663) changed the code in Eigen/src/Core/arch/Complex.h for pmul() to use a fused multiply-add-subtract (FMA) instruction (fmaddsub) instead of the previous separate multiply and add-subtract instructions. The new code improved accuracy for many of the tests in mps_simulator_test.cc, slightly worsened accuracy for some of the tests, and in the case of the one on line 262, made it cross the absolute tolerance value of 1e-5 by a very small amount. After considering various alternatives, the least-worst option seems to be to increase the tolerance for this one case. The qsim repository on GitHub has its own vendored copy of Eigen, so this change is not strictly necessary; however, if we ever update qsim's internal copy of Eigen, then this change will become relevant. Note: the original debugging & solution are the work of @pavoljuhas. --- tests/mps_simulator_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mps_simulator_test.cc b/tests/mps_simulator_test.cc index c607d1aa..e2fc8351 100644 --- a/tests/mps_simulator_test.cc +++ b/tests/mps_simulator_test.cc @@ -259,7 +259,7 @@ TEST(MPSSimulator, Apply1InteriorArbitrary) { ASSERT_NEAR(state.get()[l_offset + 56], -11.8, 1e-5); ASSERT_NEAR(state.get()[l_offset + 57], 138, 1e-5); ASSERT_NEAR(state.get()[l_offset + 58], -12.2, 1e-5); - ASSERT_NEAR(state.get()[l_offset + 59], 143.2, 1e-5); + ASSERT_NEAR(state.get()[l_offset + 59], 143.2, 2e-5); ASSERT_NEAR(state.get()[l_offset + 60], -12.6, 1e-5); ASSERT_NEAR(state.get()[l_offset + 61], 148.4, 1e-5); ASSERT_NEAR(state.get()[l_offset + 62], -13, 1e-5); From cd646a9156513471f154e7d6ffb3eec45346122c Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Sat, 14 Sep 2024 16:04:12 -0700 Subject: [PATCH 2/3] Fix CI actions on GitHub (#672) * update linux runners to ubuntu-22 or ubuntu-latest, but run test-mem job on ubuntu-20 for it for some reason fails on ubuntu-22 * bump up CI actions to be compatible with node 20, namely bump up to actions/checkout@v4, actions/setup-python@v5, download-artifact@v4, upload-artifact@v4 * update steps involving download-artifact and upload-artifact actions per https://github.com/actions/download-artifact/blob/main/docs/MIGRATION.md * migrate to docker compose v2 * to build binary wheels for mac os, set MACOSX_DEPLOYMENT_TARGET according to the macos version * stop building and testing wheels for old Python versions 3.7, 3.8 --- .github/workflows/bazeltest.yml | 10 +++---- .github/workflows/cirq_compatibility.yml | 6 ++--- .github/workflows/dockertest.yml | 6 ++--- .github/workflows/python_format.yml | 4 +-- .github/workflows/release_wheels.yml | 34 ++++++++++++++---------- .github/workflows/testing_wheels.yml | 28 ++++++++++--------- docs/docker.md | 6 ++--- 7 files changed, 52 insertions(+), 42 deletions(-) diff --git a/.github/workflows/bazeltest.yml b/.github/workflows/bazeltest.yml index 41e6f0b3..495cb1ef 100644 --- a/.github/workflows/bazeltest.yml +++ b/.github/workflows/bazeltest.yml @@ -12,7 +12,7 @@ jobs: # Run tests with Bazel v5.3.0. test: name: Test with Bazel - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: # Hardware optimizers. @@ -21,7 +21,7 @@ jobs: parallel_opt: [openmp,nopenmp] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init --recursive - name: Install Bazel on CI @@ -43,14 +43,14 @@ jobs: test-san: name: Sanitizer tests - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: # Test sanitizers sanitizer_opt: [msan,asan] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init --recursive - name: Install Bazel on CI @@ -75,7 +75,7 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init --recursive - name: Install Bazel on CI diff --git a/.github/workflows/cirq_compatibility.yml b/.github/workflows/cirq_compatibility.yml index ce402d43..626cd82e 100644 --- a/.github/workflows/cirq_compatibility.yml +++ b/.github/workflows/cirq_compatibility.yml @@ -7,10 +7,10 @@ on: jobs: consistency: name: Nightly Compatibility - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: '3.7' architecture: 'x64' diff --git a/.github/workflows/dockertest.yml b/.github/workflows/dockertest.yml index 2f83183b..4f0750d7 100644 --- a/.github/workflows/dockertest.yml +++ b/.github/workflows/dockertest.yml @@ -20,11 +20,11 @@ jobs: os: [ubuntu-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init --recursive - name: Build Docker images - run: docker-compose build + run: docker compose build - name: Run C++ tests run: docker run --rm qsim-cxx-tests:latest - name: Run Python tests @@ -34,4 +34,4 @@ jobs: - name: Test install process run: | cd install/tests - docker-compose up --build + docker compose up --build diff --git a/.github/workflows/python_format.yml b/.github/workflows/python_format.yml index 213abf2e..8c58f58f 100644 --- a/.github/workflows/python_format.yml +++ b/.github/workflows/python_format.yml @@ -17,10 +17,10 @@ jobs: name: Format check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v5 with: python-version: '3.7' architecture: 'x64' diff --git a/.github/workflows/release_wheels.yml b/.github/workflows/release_wheels.yml index 4eeb81cd..094f6086 100644 --- a/.github/workflows/release_wheels.yml +++ b/.github/workflows/release_wheels.yml @@ -14,46 +14,51 @@ jobs: include: - os: macos-12 # x86_64 name: mac + env: + macosx_deployment_target: "12.0" cibw: - build: "cp37* cp38* cp39* cp310* cp311* cp312*" + build: "cp39* cp310* cp311* cp312*" - os: macos-13-large # Apple Silicon name: mac_arm64 + env: + macosx_deployment_target: "13.0" cibw: - build: "cp37* cp38* cp39* cp310* cp311* cp312*" - - os: ubuntu-20.04 + build: "cp39* cp310* cp311* cp312*" + - os: ubuntu-22.04 name: manylinux2014 cibw: arch: x86_64 - build: "cp37* cp38* cp39* cp310* cp311* cp312*" + build: "cp39* cp310* cp311* cp312*" manylinux_image: manylinux2014 - os: windows-2019 name: win_amd64 architecture: x64 cibw: - build: "cp37-win_amd64 cp38-win_amd64 cp39-win_amd64 cp310-win_amd64 cp311-win_amd64 cp312-win_amd64" + build: "cp39-win_amd64 cp310-win_amd64 cp311-win_amd64 cp312-win_amd64" env: + MACOSX_DEPLOYMENT_TARGET: "${{ matrix.env.macosx_deployment_target }}" CIBW_BUILD: "${{ matrix.cibw.build || '*' }}" CIBW_SKIP: "*musllinux*" CIBW_ARCHS: "${{ matrix.cibw.arch || 'auto' }}" CIBW_MANYLINUX_X86_64_IMAGE: "${{ matrix.cibw.manylinux_image }}" - CIBW_BEFORE_BUILD_MACOS: "brew install libomp llvm && brew link --overwrite python@3.11 && brew link --force libomp" + CIBW_BEFORE_BUILD_MACOS: "brew install libomp llvm@12 && brew link --overwrite python@3.11 && brew link --force libomp" CIBW_REPAIR_WHEEL_COMMAND_MACOS: "delocate-listdeps {wheel} && delocate-wheel --verbose --require-archs {delocate_archs} -w {dest_dir} {wheel}" # to install latest delocate package CIBW_DEPENDENCY_VERSIONS: "latest" # due to package and module name conflict have to temporarily move it away to run tests - CIBW_BEFORE_TEST: mv {package}/qsimcirq /tmp + CIBW_BEFORE_TEST: "mv {package}/qsimcirq /tmp" CIBW_TEST_EXTRAS: "dev" CIBW_TEST_COMMAND: "pytest {package}/qsimcirq_tests/qsimcirq_test.py && mv /tmp/qsimcirq {package}" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # Used to host cibuildwheel - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install cibuildwheel and twine - run: python -m pip install cibuildwheel==2.16.2 + run: python -m pip install cibuildwheel==2.20.0 - name: Install requirements run: python -m pip install -r requirements.txt @@ -64,9 +69,9 @@ jobs: - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: - name: python-wheels + name: python-wheels-${{ matrix.name }} path: ./wheelhouse/*.whl release-wheels: name: Publish all wheels @@ -74,10 +79,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Download build artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: - name: python-wheels path: dist/ + pattern: python-wheels-* + merge-multiple: true - name: Publish wheels uses: pypa/gh-action-pypi-publish@release/v1 with: diff --git a/.github/workflows/testing_wheels.yml b/.github/workflows/testing_wheels.yml index de263fe6..a67b8556 100644 --- a/.github/workflows/testing_wheels.yml +++ b/.github/workflows/testing_wheels.yml @@ -19,29 +19,34 @@ jobs: include: - os: macos-12 # x86_64 name: mac + env: + macosx_deployment_target: "12.0" cibw: - build: "cp37* cp38* cp39* cp310* cp311* cp312*" + build: "cp39* cp310* cp311* cp312*" - os: macos-13-large # Apple Silicon name: mac_arm64 + env: + macosx_deployment_target: "13.0" cibw: - build: "cp37* cp38* cp39* cp310* cp311* cp312*" - - os: ubuntu-20.04 + build: "cp39* cp310* cp311* cp312*" + - os: ubuntu-22.04 name: manylinux2014 cibw: arch: x86_64 - build: "cp37* cp38* cp39* cp310* cp311* cp312*" + build: "cp39* cp310* cp311* cp312*" manylinux_image: manylinux2014 - os: windows-2019 name: win_amd64 architecture: x64 cibw: - build: "cp37-win_amd64 cp38-win_amd64 cp39-win_amd64 cp310-win_amd64 cp311-win_amd64 cp312-win_amd64" + build: "cp39-win_amd64 cp310-win_amd64 cp311-win_amd64 cp312-win_amd64" env: + MACOSX_DEPLOYMENT_TARGET: "${{ matrix.env.macosx_deployment_target }}" CIBW_BUILD: "${{ matrix.cibw.build || '*' }}" CIBW_SKIP: "*musllinux*" CIBW_ARCHS: "${{ matrix.cibw.arch || 'auto' }}" CIBW_MANYLINUX_X86_64_IMAGE: "${{ matrix.cibw.manylinux_image }}" - CIBW_BEFORE_BUILD_MACOS: "brew install libomp llvm && brew link --overwrite python@3.11 && brew link --force libomp" + CIBW_BEFORE_BUILD_MACOS: "brew install libomp llvm@12 && brew link --overwrite python@3.11 && brew link --force libomp" CIBW_REPAIR_WHEEL_COMMAND_MACOS: "delocate-listdeps {wheel} && delocate-wheel --verbose --require-archs {delocate_archs} -w {dest_dir} {wheel}" # to install latest delocate package CIBW_DEPENDENCY_VERSIONS: "latest" @@ -50,15 +55,15 @@ jobs: CIBW_TEST_EXTRAS: "dev" CIBW_TEST_COMMAND: "pytest {package}/qsimcirq_tests/qsimcirq_test.py && mv /tmp/qsimcirq {package}" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # Used to host cibuildwheel - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install cibuildwheel and twine - run: python -m pip install cibuildwheel==2.16.2 + run: python -m pip install cibuildwheel==2.20.0 - name: Install requirements run: python -m pip install -r requirements.txt @@ -69,8 +74,7 @@ jobs: - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: - name: python-wheels + name: python-wheels-${{ matrix.name }} path: ./wheelhouse/*.whl - diff --git a/docs/docker.md b/docs/docker.md index 72b50429..39a1d4de 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -19,10 +19,10 @@ git submodule update --init --recursive To build qsim and run all the tests: ``` -# docker-compose up --build +# docker compose up --build ``` -`docker-compose` will create the `qsim`, `qsim-cxx-tests`, and `qsim-py-tests` +`docker compose` will create the `qsim`, `qsim-cxx-tests`, and `qsim-py-tests` images and automatically run all tests. A successful run should have the following messages somewhere in the logs: @@ -34,7 +34,7 @@ qsim-py-tests exited with code 0 To build without running tests, simply run: ``` -# docker-compose build +# docker compose build ``` ## Run Simulations From c4eab57e332ea5df8d62d8f12929ba6c964a1b35 Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Mon, 16 Sep 2024 10:49:11 -0700 Subject: [PATCH 3/3] CI - test cirq compatibility under Python 3.10 (#673) CI - test cirq compatibility using Python 3.10 cirq requires minimum Python version 3.10. Running under Python 3.7 installs cirq from June 2023. Also change the pip3 command to install a pre-release of cirq with stable dependencies. Run the "Format check" job under Python 3.10 as well. --- .github/workflows/cirq_compatibility.yml | 4 ++-- .github/workflows/python_format.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cirq_compatibility.yml b/.github/workflows/cirq_compatibility.yml index 626cd82e..d34dcc10 100644 --- a/.github/workflows/cirq_compatibility.yml +++ b/.github/workflows/cirq_compatibility.yml @@ -12,10 +12,10 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.7' + python-version: '3.10' architecture: 'x64' - name: Install Cirq nightly - run: pip3 install -U cirq --pre + run: pip3 install --upgrade cirq~=1.0.dev - name: Install qsim requirements run: pip3 install -r requirements.txt - name: Install test requirements diff --git a/.github/workflows/python_format.yml b/.github/workflows/python_format.yml index 8c58f58f..1f3b689d 100644 --- a/.github/workflows/python_format.yml +++ b/.github/workflows/python_format.yml @@ -22,7 +22,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-python@v5 with: - python-version: '3.7' + python-version: '3.10' architecture: 'x64' - name: Install dev requirements run: pip install -r dev-requirements.txt