Skip to content

Commit

Permalink
Limiting the Search Space in Optimal Quantum Circuit Mapping (#6)
Browse files Browse the repository at this point in the history
 - ⚡ actually enables -march=native -mtune=native for source builds via pip
 - ⚡ setup.py now runs on as many threads as available
 - 🏗️ switch to PEP 517 `pyproject.toml`
 - 💚 switch cibuildwheel configuration to `pyproject.toml`
 - 🚀 added Python 3.10 wheels
 - ♻️ refactor the Python bindings to make them easier to use
 - ⬆️ updated all external submodules to their most recent version
 - 📝 updated documentation

Co-authored-by: Lukas Burgholzer <[email protected]>
Co-authored-by: Sarah.S <[email protected]>
Co-authored-by: burgholzer <[email protected]>
  • Loading branch information
4 people authored Nov 28, 2021
1 parent d8f4f5c commit 99c9476
Show file tree
Hide file tree
Showing 41 changed files with 2,741 additions and 1,609 deletions.
123 changes: 42 additions & 81 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,23 @@ jobs:
with:
submodules: recursive

- name: Installing boost
run: sudo apt-get install -y libboost-program-options-dev

- name: Cache Z3
id: cache-z3
uses: actions/cache@v2
- uses: actions/setup-python@v2
name: Install Python
with:
path: z3
key: ${{ runner.OS }}-z3-${{ env.Z3_GIT_TAG }}-static
python-version: '3.9'

- name: Building Z3
if: steps.cache-z3.outputs.cache-hit != 'true'
run: |
git clone --branch $Z3_GIT_TAG --depth 1 https://github.com/Z3Prover/z3.git
cmake -S z3 -B z3/build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DZ3_BUILD_LIBZ3_SHARED=FALSE
cmake --build z3/build --config $BUILD_TYPE
- name: Installing boost
run: sudo apt-get install -y libboost-program-options-dev

- name: Install Z3
run: python -m pip install z3-solver

- name: Configure CMake
run: cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_QMAP_TESTS=ON -DZ3_ROOT=z3/build -DBINDINGS=ON
run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/python/cp39-cp39/lib/python3.9/site-packages/z3/lib
export Z3_ROOT=/opt/python/cp39-cp39/lib/python3.9/site-packages/z3
export Z3_DIR=/opt/python/cp39-cp39/lib/python3.9/site-packages/z3
cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_QMAP_TESTS=ON -DBINDINGS=ON
- name: Build
run: |
Expand All @@ -70,16 +68,17 @@ jobs:

- name: Coverage
run: |
cmake -S "${{github.workspace}}" -B "${{github.workspace}}/buildCov" -DCMAKE_BUILD_TYPE=Debug -DBUILD_QMAP_TESTS=ON -DCOVERAGE=ON -DBINDINGS=ON -DZ3_ROOT=z3/build
cmake --build "${{github.workspace}}/buildCov" --config Debug --target qmap_exact_test
cmake --build "${{github.workspace}}/buildCov" --config Debug --target qmap_heuristic_test
cd buildCov/test
ctest -C $BUILD_TYPE --output-on-failure
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/python/cp39-cp39/lib/python3.9/site-packages/z3/lib
export Z3_ROOT=/opt/python/cp39-cp39/lib/python3.9/site-packages/z3
export Z3_DIR=/opt/python/cp39-cp39/lib/python3.9/site-packages/z3
cmake -S "${{github.workspace}}" -B "${{github.workspace}}/buildCov" -DCMAKE_BUILD_TYPE=Debug -DBUILD_QMAP_TESTS=ON -DCOVERAGE=ON -DBINDINGS=ON
cmake --build "${{github.workspace}}/buildCov" --config Debug --target qmap_exact_test
cmake --build "${{github.workspace}}/buildCov" --config Debug --target qmap_heuristic_test
cd buildCov/test
ctest -C $BUILD_TYPE --output-on-failure
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
# with:
# fail_ci_if_error: true

macOS-ci:
runs-on: macos-latest
Expand All @@ -89,32 +88,18 @@ jobs:
with:
submodules: recursive

- name: Installing boost
run: brew install boost

- name: Cache Z3
id: cache-z3
uses: actions/cache@v2
with:
path: z3
key: ${{ runner.OS }}-z3-${{ env.Z3_GIT_TAG }}-static

- name: Building Z3
if: steps.cache-z3.outputs.cache-hit != 'true'
run: |
git clone --branch $Z3_GIT_TAG --depth 1 https://github.com/Z3Prover/z3.git
cmake -S z3 -B z3/build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DZ3_BUILD_LIBZ3_SHARED=FALSE
cmake --build z3/build --config $BUILD_TYPE
- name: Installing boost and Z3
run: brew install boost z3

- name: Configure CMake
run: cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_QMAP_TESTS=ON -DZ3_ROOT=z3/build
run: cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_QMAP_TESTS=ON

- name: Build
run: |
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_heuristic
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_exact
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_heuristic_test
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_exact_test
run: |
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_heuristic
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_exact
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_heuristic_test
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_exact_test
- name: Test
working-directory: ${{github.workspace}}/build/test
Expand All @@ -127,55 +112,31 @@ jobs:
with:
submodules: recursive

- name: Cache Boost
id: cache-boost
uses: actions/cache@v2
with:
path: ${{github.workspace}}/boost_1_70_0
key: ${{ runner.OS }}-boost170

- name: Download boost
if: steps.cache-boost.outputs.cache-hit != 'true'
shell: cmd
run: C:\msys64\usr\bin\wget.exe https://boostorg.jfrog.io/artifactory/main/release/1.70.0/source/boost_1_70_0.7z --no-check-certificate

- uses: ilammy/msvc-dev-cmd@v1

- name: Building boost
if: steps.cache-boost.outputs.cache-hit != 'true'
run: |
"/c/Program Files/7-Zip/7z.exe" x boost_1_70_0.7z "-o${{github.workspace}}"
cd boost_1_70_0
./bootstrap.bat
./b2.exe -j8 address-model=64 link=static threading=multi runtime-link=shared variant=release --build-type=minimal --with-program_options
- name: Cache Z3
id: cache-z3
uses: actions/cache@v2
with:
path: z3
key: ${{ runner.OS }}-z3-${{ env.Z3_GIT_TAG }}-static

- name: Building Z3
if: steps.cache-z3.outputs.cache-hit != 'true'
run: |
git clone --branch $Z3_GIT_TAG --depth 1 https://github.com/Z3Prover/z3.git
cmake -S z3 -B z3/build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G "Visual Studio 16 2019" -A x64 -DZ3_BUILD_LIBZ3_SHARED=FALSE
cmake --build z3/build --config $BUILD_TYPE
- name: Building Z3
if: steps.cache-z3.outputs.cache-hit != 'true'
run: |
git clone --branch $Z3_GIT_TAG --depth 1 https://github.com/Z3Prover/z3.git
cmake -S z3 -B z3/build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G "Visual Studio 16 2019" -A x64 -DZ3_BUILD_LIBZ3_SHARED=FALSE -DZ3_BUILD_EXECUTABLE=False -DZ3_BUILD_TEST_EXECUTABLES=False
cmake --build z3/build --config $BUILD_TYPE
- name: Configure CMake
run: |
setx path "%path%;${{github.workspace}}\boost_1_70_0"
setx lib "%lib%;${{github.workspace}}\boost_1_70_0\stage\lib"
setx libpath "%libpath%;${{github.workspace}}\boost_1_70_0\stage\lib"
cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -T "ClangCl" -DBoost_USE_STATIC_LIBS=ON -DBoost_USE_MULTITHREADED=ON -DBoost_USE_STATIC_RUNTIME=OFF -DBOOST_ROOT="${{github.workspace}}\boost_1_70_0" -DBOOST_INCLUDEDIR="${{github.workspace}}\boost_1_70_0\include" -DBOOST_LIBRARYDIR="${{github.workspace}}\boost_1_70_0\stage\lib" -DZ3_ROOT=z3/build
- name: Configure CMake
run: cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -T "ClangCl" -DZ3_ROOT=z3/build -DBUILD_QMAP_TESTS=ON

- name: Build
run: cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE

- name: Test
working-directory: ${{github.workspace}}/build/apps
run: |
cd $BUILD_TYPE
./qmap_exact.exe --in ../../../examples/3_17_13.qasm --out 3_17_13me.qasm --arch ../../../extern/architectures/ibmq_london.arch --ps;
./qmap_heuristic.exe --in ../../../examples/3_17_13.qasm --out 3_17_13mh.qasm --arch ../../../extern/architectures/ibmq_london.arch --ps;
working-directory: ${{github.workspace}}/build/test
run: |
cd $BUILD_TYPE
./qmap_exact_test
./qmap_heuristic_test
34 changes: 14 additions & 20 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@ on:
workflow_dispatch:

env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_LINUX: >
/opt/python/cp38-cp38/bin/python -m pip install z3-solver;
CIBW_ENVIRONMENT_LINUX: "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/python/cp38-cp38/lib/python3.8/site-packages/z3/lib Z3_ROOT=/opt/python/cp38-cp38/lib/python3.8/site-packages/z3 Z3_DIR=/opt/python/cp38-cp38/lib/python3.8/site-packages/z3"
CIBW_BUILD: cp3?-*
# CIBW_ARCHS_MACOS: "x86_64 arm64"
# CIBW_TEST_SKIP: "*_arm64"
CIBW_SKIP: "*-win32 *-manylinux_i686"
CIBW_BUILD_VERBOSITY: 3
CIBW_TEST_COMMAND: "python -c \"from jkq import qmap\""
Z3_GIT_TAG: z3-4.8.10
Z3_GIT_TAG: z3-4.8.13

jobs:
build_manylinux_wheels:
name: Build wheels on manylinux2014
name: Build wheels on Linux
runs-on: ubuntu-latest

steps:
Expand All @@ -36,14 +26,14 @@ jobs:
with:
python-version: '3.9'
- name: Build wheels
uses: pypa/cibuildwheel@v2.1.1
uses: pypa/cibuildwheel@v2.3.0
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

build_macos_wheels:
name: Build wheels on macOS
runs-on: macos-latest
runs-on: macos-11

steps:
- uses: actions/checkout@v2
Expand All @@ -56,7 +46,7 @@ jobs:
- name: Install Z3
run: brew install z3
- name: Build wheels
uses: pypa/cibuildwheel@v2.1.1
uses: pypa/cibuildwheel@v2.3.0
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
Expand Down Expand Up @@ -92,14 +82,14 @@ jobs:
working-directory: ${{github.workspace}}/z3/build
run: cmake --build . --config Release --target INSTALL;
- name: Build wheels
uses: pypa/cibuildwheel@v2.1.1
uses: pypa/cibuildwheel@v2.3.0
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: macos-latest
runs-on: macos-11
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -111,7 +101,9 @@ jobs:
- name: Install Z3
run: brew install z3
- name: Build sdist
run: python setup.py sdist
run: |
pip install -q build
python -m build --sdist
- name: Test sdist
run: pip install --verbose dist/*.tar.gz
- uses: actions/upload-artifact@v2
Expand All @@ -129,5 +121,7 @@ jobs:
path: dist
- uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
user: __token__
password: ${{ secrets.pypi_password }}
skip_existing: true
verbose: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ venv
dist
*egg-info
.eggs
.vscode*
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.14...3.19)
cmake_minimum_required(VERSION 3.14...3.21)

project(qmap
LANGUAGES CXX
VERSION 1.4.0
VERSION 1.5.0
DESCRIPTION "QMAP - A JKQ library for mapping of quantum circuits to quantum architectures"
)

Expand All @@ -16,13 +16,18 @@ option(COVERAGE "Configure for coverage report generation")
option(GENERATE_POSITION_INDEPENDENT_CODE "Generate position independent code")
option(BUILD_QMAP_TESTS "Also build tests for QMAP project")

if (DEFINED ENV{DEPLOY})
set(DEPLOY $ENV{DEPLOY} CACHE BOOL "Use deployment configuration from environment" FORCE)
message(STATUS "Setting deployment configuration to '${DEPLOY}' from environment")
endif ()

# build type settings
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
endif ()

macro(check_submodule_present MODULENAME)
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/${MODULENAME}/CMakeLists.txt")
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include src/heuristic/*
include include/*
include include/exact/*
include include/heuristic/*
include include/configuration/*
include cmake/*
include apps/*
graft jkq/*
Expand Down
Loading

0 comments on commit 99c9476

Please sign in to comment.