Skip to content

Commit 99c9476

Browse files
IsFairyburgholzerWhoisourHacker
authored
Limiting the Search Space in Optimal Quantum Circuit Mapping (#6)
- ⚡ 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 <lukas.burgholzer@jku.at> Co-authored-by: Sarah.S <25271312+WhoisourHacker@users.noreply.github.com> Co-authored-by: burgholzer <burgholzer@me.com>
1 parent d8f4f5c commit 99c9476

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2741
-1609
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,23 @@ jobs:
3737
with:
3838
submodules: recursive
3939

40-
- name: Installing boost
41-
run: sudo apt-get install -y libboost-program-options-dev
42-
43-
- name: Cache Z3
44-
id: cache-z3
45-
uses: actions/cache@v2
40+
- uses: actions/setup-python@v2
41+
name: Install Python
4642
with:
47-
path: z3
48-
key: ${{ runner.OS }}-z3-${{ env.Z3_GIT_TAG }}-static
43+
python-version: '3.9'
4944

50-
- name: Building Z3
51-
if: steps.cache-z3.outputs.cache-hit != 'true'
52-
run: |
53-
git clone --branch $Z3_GIT_TAG --depth 1 https://github.com/Z3Prover/z3.git
54-
cmake -S z3 -B z3/build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DZ3_BUILD_LIBZ3_SHARED=FALSE
55-
cmake --build z3/build --config $BUILD_TYPE
45+
- name: Installing boost
46+
run: sudo apt-get install -y libboost-program-options-dev
47+
48+
- name: Install Z3
49+
run: python -m pip install z3-solver
5650

5751
- name: Configure CMake
58-
run: cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_QMAP_TESTS=ON -DZ3_ROOT=z3/build -DBINDINGS=ON
52+
run: |
53+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/python/cp39-cp39/lib/python3.9/site-packages/z3/lib
54+
export Z3_ROOT=/opt/python/cp39-cp39/lib/python3.9/site-packages/z3
55+
export Z3_DIR=/opt/python/cp39-cp39/lib/python3.9/site-packages/z3
56+
cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_QMAP_TESTS=ON -DBINDINGS=ON
5957
6058
- name: Build
6159
run: |
@@ -70,16 +68,17 @@ jobs:
7068

7169
- name: Coverage
7270
run: |
73-
cmake -S "${{github.workspace}}" -B "${{github.workspace}}/buildCov" -DCMAKE_BUILD_TYPE=Debug -DBUILD_QMAP_TESTS=ON -DCOVERAGE=ON -DBINDINGS=ON -DZ3_ROOT=z3/build
74-
cmake --build "${{github.workspace}}/buildCov" --config Debug --target qmap_exact_test
75-
cmake --build "${{github.workspace}}/buildCov" --config Debug --target qmap_heuristic_test
76-
cd buildCov/test
77-
ctest -C $BUILD_TYPE --output-on-failure
71+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/python/cp39-cp39/lib/python3.9/site-packages/z3/lib
72+
export Z3_ROOT=/opt/python/cp39-cp39/lib/python3.9/site-packages/z3
73+
export Z3_DIR=/opt/python/cp39-cp39/lib/python3.9/site-packages/z3
74+
cmake -S "${{github.workspace}}" -B "${{github.workspace}}/buildCov" -DCMAKE_BUILD_TYPE=Debug -DBUILD_QMAP_TESTS=ON -DCOVERAGE=ON -DBINDINGS=ON
75+
cmake --build "${{github.workspace}}/buildCov" --config Debug --target qmap_exact_test
76+
cmake --build "${{github.workspace}}/buildCov" --config Debug --target qmap_heuristic_test
77+
cd buildCov/test
78+
ctest -C $BUILD_TYPE --output-on-failure
7879
7980
- name: Upload coverage to Codecov
8081
uses: codecov/codecov-action@v1
81-
# with:
82-
# fail_ci_if_error: true
8382

8483
macOS-ci:
8584
runs-on: macos-latest
@@ -89,32 +88,18 @@ jobs:
8988
with:
9089
submodules: recursive
9190

92-
- name: Installing boost
93-
run: brew install boost
94-
95-
- name: Cache Z3
96-
id: cache-z3
97-
uses: actions/cache@v2
98-
with:
99-
path: z3
100-
key: ${{ runner.OS }}-z3-${{ env.Z3_GIT_TAG }}-static
101-
102-
- name: Building Z3
103-
if: steps.cache-z3.outputs.cache-hit != 'true'
104-
run: |
105-
git clone --branch $Z3_GIT_TAG --depth 1 https://github.com/Z3Prover/z3.git
106-
cmake -S z3 -B z3/build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DZ3_BUILD_LIBZ3_SHARED=FALSE
107-
cmake --build z3/build --config $BUILD_TYPE
91+
- name: Installing boost and Z3
92+
run: brew install boost z3
10893

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

11297
- name: Build
113-
run: |
114-
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_heuristic
115-
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_exact
116-
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_heuristic_test
117-
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_exact_test
98+
run: |
99+
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_heuristic
100+
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_exact
101+
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_heuristic_test
102+
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qmap_exact_test
118103
119104
- name: Test
120105
working-directory: ${{github.workspace}}/build/test
@@ -127,55 +112,31 @@ jobs:
127112
with:
128113
submodules: recursive
129114

130-
- name: Cache Boost
131-
id: cache-boost
132-
uses: actions/cache@v2
133-
with:
134-
path: ${{github.workspace}}/boost_1_70_0
135-
key: ${{ runner.OS }}-boost170
136-
137-
- name: Download boost
138-
if: steps.cache-boost.outputs.cache-hit != 'true'
139-
shell: cmd
140-
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
141-
142115
- uses: ilammy/msvc-dev-cmd@v1
143116

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

159-
- name: Building Z3
160-
if: steps.cache-z3.outputs.cache-hit != 'true'
161-
run: |
162-
git clone --branch $Z3_GIT_TAG --depth 1 https://github.com/Z3Prover/z3.git
163-
cmake -S z3 -B z3/build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G "Visual Studio 16 2019" -A x64 -DZ3_BUILD_LIBZ3_SHARED=FALSE
164-
cmake --build z3/build --config $BUILD_TYPE
124+
- name: Building Z3
125+
if: steps.cache-z3.outputs.cache-hit != 'true'
126+
run: |
127+
git clone --branch $Z3_GIT_TAG --depth 1 https://github.com/Z3Prover/z3.git
128+
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
129+
cmake --build z3/build --config $BUILD_TYPE
165130
166-
- name: Configure CMake
167-
run: |
168-
setx path "%path%;${{github.workspace}}\boost_1_70_0"
169-
setx lib "%lib%;${{github.workspace}}\boost_1_70_0\stage\lib"
170-
setx libpath "%libpath%;${{github.workspace}}\boost_1_70_0\stage\lib"
171-
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
131+
- name: Configure CMake
132+
run: cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -T "ClangCl" -DZ3_ROOT=z3/build -DBUILD_QMAP_TESTS=ON
172133

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

176137
- name: Test
177-
working-directory: ${{github.workspace}}/build/apps
178-
run: |
179-
cd $BUILD_TYPE
180-
./qmap_exact.exe --in ../../../examples/3_17_13.qasm --out 3_17_13me.qasm --arch ../../../extern/architectures/ibmq_london.arch --ps;
181-
./qmap_heuristic.exe --in ../../../examples/3_17_13.qasm --out 3_17_13mh.qasm --arch ../../../extern/architectures/ibmq_london.arch --ps;
138+
working-directory: ${{github.workspace}}/build/test
139+
run: |
140+
cd $BUILD_TYPE
141+
./qmap_exact_test
142+
./qmap_heuristic_test

.github/workflows/deploy.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,11 @@ on:
1010
workflow_dispatch:
1111

1212
env:
13-
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
14-
CIBW_BEFORE_ALL_LINUX: >
15-
/opt/python/cp38-cp38/bin/python -m pip install z3-solver;
16-
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"
17-
CIBW_BUILD: cp3?-*
18-
# CIBW_ARCHS_MACOS: "x86_64 arm64"
19-
# CIBW_TEST_SKIP: "*_arm64"
20-
CIBW_SKIP: "*-win32 *-manylinux_i686"
21-
CIBW_BUILD_VERBOSITY: 3
22-
CIBW_TEST_COMMAND: "python -c \"from jkq import qmap\""
23-
Z3_GIT_TAG: z3-4.8.10
13+
Z3_GIT_TAG: z3-4.8.13
2414

2515
jobs:
2616
build_manylinux_wheels:
27-
name: Build wheels on manylinux2014
17+
name: Build wheels on Linux
2818
runs-on: ubuntu-latest
2919

3020
steps:
@@ -36,14 +26,14 @@ jobs:
3626
with:
3727
python-version: '3.9'
3828
- name: Build wheels
39-
uses: pypa/cibuildwheel@v2.1.1
29+
uses: pypa/cibuildwheel@v2.3.0
4030
- uses: actions/upload-artifact@v2
4131
with:
4232
path: ./wheelhouse/*.whl
4333

4434
build_macos_wheels:
4535
name: Build wheels on macOS
46-
runs-on: macos-latest
36+
runs-on: macos-11
4737

4838
steps:
4939
- uses: actions/checkout@v2
@@ -56,7 +46,7 @@ jobs:
5646
- name: Install Z3
5747
run: brew install z3
5848
- name: Build wheels
59-
uses: pypa/cibuildwheel@v2.1.1
49+
uses: pypa/cibuildwheel@v2.3.0
6050
- uses: actions/upload-artifact@v2
6151
with:
6252
path: ./wheelhouse/*.whl
@@ -92,14 +82,14 @@ jobs:
9282
working-directory: ${{github.workspace}}/z3/build
9383
run: cmake --build . --config Release --target INSTALL;
9484
- name: Build wheels
95-
uses: pypa/cibuildwheel@v2.1.1
85+
uses: pypa/cibuildwheel@v2.3.0
9686
- uses: actions/upload-artifact@v2
9787
with:
9888
path: ./wheelhouse/*.whl
9989

10090
build_sdist:
10191
name: Build source distribution
102-
runs-on: macos-latest
92+
runs-on: macos-11
10393
steps:
10494
- uses: actions/checkout@v2
10595
with:
@@ -111,7 +101,9 @@ jobs:
111101
- name: Install Z3
112102
run: brew install z3
113103
- name: Build sdist
114-
run: python setup.py sdist
104+
run: |
105+
pip install -q build
106+
python -m build --sdist
115107
- name: Test sdist
116108
run: pip install --verbose dist/*.tar.gz
117109
- uses: actions/upload-artifact@v2
@@ -129,5 +121,7 @@ jobs:
129121
path: dist
130122
- uses: pypa/gh-action-pypi-publish@master
131123
with:
132-
user: __token__
133-
password: ${{ secrets.pypi_password }}
124+
user: __token__
125+
password: ${{ secrets.pypi_password }}
126+
skip_existing: true
127+
verbose: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ venv
55
dist
66
*egg-info
77
.eggs
8+
.vscode*

CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
cmake_minimum_required(VERSION 3.14...3.19)
1+
cmake_minimum_required(VERSION 3.14...3.21)
22

33
project(qmap
44
LANGUAGES CXX
5-
VERSION 1.4.0
5+
VERSION 1.5.0
66
DESCRIPTION "QMAP - A JKQ library for mapping of quantum circuits to quantum architectures"
77
)
88

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

19+
if (DEFINED ENV{DEPLOY})
20+
set(DEPLOY $ENV{DEPLOY} CACHE BOOL "Use deployment configuration from environment" FORCE)
21+
message(STATUS "Setting deployment configuration to '${DEPLOY}' from environment")
22+
endif ()
23+
1924
# build type settings
2025
set(default_build_type "Release")
21-
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
26+
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
2227
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
2328
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
2429
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
25-
endif()
30+
endif ()
2631

2732
macro(check_submodule_present MODULENAME)
2833
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/${MODULENAME}/CMakeLists.txt")

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ include src/heuristic/*
55
include include/*
66
include include/exact/*
77
include include/heuristic/*
8+
include include/configuration/*
89
include cmake/*
910
include apps/*
1011
graft jkq/*

0 commit comments

Comments
 (0)