Skip to content

Commit fde8944

Browse files
authored
Update to newest QFR version (#8)
* ⬆️ update QFR submodule and hence DD Package library * 🐛 fix complex vector export * 🐛 fix bindings code * 🐛 fix use of C++-20 feature * 🔖 bump version * 📄 updating license * 🐛 fixing MANIFEST.in * 📝 adjusting README.md * 👷 also test python wheels and source distribution build on each commit * 💚 simplifying CI script * 💚 exclude tests from coverage * 💚 build Apple Silicon wheels using a newer version of cibuildwheel
1 parent feea0d8 commit fde8944

File tree

12 files changed

+64
-64
lines changed

12 files changed

+64
-64
lines changed

.github/codecov.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ignore:
22
- "extern/**/*"
33
- "jkq/**/*"
4+
- "test/**/*"
45

56
coverage:
67
range: 60..90

.github/workflows/ci.yml

+13-16
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
name: CI
22

3-
on:
3+
on:
44
push:
5-
branches: [master]
5+
branches: [ master ]
66
pull_request:
7-
branches: [master]
7+
branches: [ master ]
88
workflow_dispatch:
99

1010
env:
1111
BUILD_TYPE: Release
12+
MAKEFLAGS: "-j2"
13+
14+
defaults:
15+
run:
16+
shell: bash
1217

1318
jobs:
1419
build:
1520
runs-on: ${{ matrix.os }}
1621
strategy:
1722
fail-fast: false
1823
matrix:
19-
os: [ubuntu-latest, macos-latest, windows-latest]
24+
os: [ ubuntu-latest, macos-latest, windows-latest ]
2025

2126
steps:
2227
- uses: actions/checkout@v2
2328
with:
2429
submodules: recursive
2530

2631
- name: Configure CMake
27-
shell: bash
2832
run: |
2933
if [ "$RUNNER_OS" == "Windows" ]; then
3034
cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBINDINGS=ON -T "ClangCl"
@@ -33,8 +37,7 @@ jobs:
3337
fi
3438
3539
- name: Build
36-
shell: bash
37-
run: cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --parallel 8
40+
run: cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE
3841

3942
test:
4043
needs: build
@@ -50,7 +53,6 @@ jobs:
5053
submodules: recursive
5154

5255
- name: Configure CMake
53-
shell: bash
5456
run: |
5557
if [ "$RUNNER_OS" == "Windows" ]; then
5658
cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_QCEC_TESTS=ON -T "ClangCl"
@@ -59,17 +61,15 @@ jobs:
5961
fi
6062
6163
- name: Build
62-
shell: bash
6364
run: |
6465
if [ "$RUNNER_OS" == "Windows" ]; then
65-
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --parallel 8
66+
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE
6667
else
67-
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qcec_test --parallel 8
68+
cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE --target qcec_test
6869
fi
6970
7071
- name: Test
7172
working-directory: ${{github.workspace}}/build/test
72-
shell: bash
7373
run: |
7474
if [ "$RUNNER_OS" == "Windows" ]; then
7575
cd $BUILD_TYPE
@@ -88,16 +88,13 @@ jobs:
8888
submodules: recursive
8989

9090
- name: Configure CMake
91-
shell: bash
9291
run: cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=Debug -DBUILD_QCEC_TESTS=ON -DBINDINGS=ON -DCOVERAGE=1
9392

9493
- name: Build
95-
shell: bash
9694
run: cmake --build "${{github.workspace}}/build" --config Debug --target qcec_test
9795

9896
- name: Test
9997
working-directory: ${{github.workspace}}/build/test
100-
shell: bash
10198
run: ./qcec_test
10299

103100
- name: Upload coverage to Codecov
@@ -113,6 +110,6 @@ jobs:
113110
submodules: recursive
114111
- uses: DoozyX/[email protected]
115112
with:
116-
source: 'include src test jkq/qcec'
113+
source: 'apps include src test jkq/qcec'
117114
extensions: 'h,hpp,c,cpp'
118115
clangFormatVersion: 12

.github/workflows/deploy.yml

+21-22
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@ name: Deploy to PyPI
22

33
on:
44
release:
5-
types: [published]
5+
types: [ published ]
6+
push:
7+
branches: [ master ]
8+
pull_request:
9+
branches: [ master ]
610
workflow_dispatch:
7-
11+
812
env:
913
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
10-
CIBW_BUILD: cp3?-*
11-
CIBW_SKIP: "*-win32 *-manylinux_i686 cp35-*"
12-
CIBW_BUILD_VERBOSITY: 3
13-
CIBW_TEST_COMMAND: "python -c \"from jkq import qcec\""
14-
CIBW_BEFORE_BUILD: "pip install cmake"
14+
CIBW_BUILD: cp3?-*
15+
CIBW_ARCHS_MACOS: "x86_64 arm64"
16+
CIBW_TEST_SKIP: "*_arm64"
17+
CIBW_SKIP: "*-win32 *-manylinux_i686"
18+
CIBW_BUILD_VERBOSITY: 3
19+
CIBW_TEST_COMMAND: "python -c \"from jkq import qcec\""
20+
CIBW_BEFORE_BUILD: "pip install cmake"
1521

1622
jobs:
1723
build_wheels:
@@ -26,19 +32,9 @@ jobs:
2632
- uses: actions/checkout@v2
2733
with:
2834
submodules: recursive
29-
30-
- uses: actions/setup-python@v2
31-
name: Install Python
32-
with:
33-
python-version: '3.8'
34-
35-
- name: Install dependencies
36-
run: |
37-
python -m pip install --upgrade pip setuptools wheel cibuildwheel==1.7.4
38-
35+
- uses: ilammy/msvc-dev-cmd@v1
3936
- name: Build wheels
40-
run: |
41-
python -m cibuildwheel --output-dir wheelhouse
37+
uses: pypa/[email protected]
4238
- uses: actions/upload-artifact@v2
4339
with:
4440
path: ./wheelhouse/*.whl
@@ -54,7 +50,7 @@ jobs:
5450
- uses: actions/setup-python@v2
5551
name: Install Python
5652
with:
57-
python-version: '3.8'
53+
python-version: '3.9'
5854

5955
- name: Install dependencies
6056
run: |
@@ -76,6 +72,7 @@ jobs:
7672
upload_pypi:
7773
needs: [build_wheels, build_sdist]
7874
runs-on: ubuntu-latest
75+
if: github.event_name == 'release' && github.event.action == 'published'
7976
steps:
8077
- uses: actions/download-artifact@v2
8178
with:
@@ -84,5 +81,7 @@ jobs:
8481

8582
- uses: pypa/gh-action-pypi-publish@master
8683
with:
87-
user: __token__
88-
password: ${{ secrets.pypi_password }}
84+
user: __token__
85+
password: ${{ secrets.pypi_password }}
86+
skip_existing: true
87+
verbose: true

CMakeLists.txt

+2-2
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(qcec
44
LANGUAGES CXX
5-
VERSION 1.9.1
5+
VERSION 1.10.0
66
DESCRIPTION "QCEC - A JKQ tool for Quantum Circuit Equivalence Checking"
77
)
88

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Lukas Burgholzer, Robert Wille
3+
Copyright (c) 2021 Lukas Burgholzer, Robert Wille
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

MANIFEST.in

-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ graft jkq/*
66
include extern/qfr/CMakeLists.txt
77
graft extern/qfr/src
88
graft extern/qfr/include
9-
graft extern/qfr/cmake
109
graft extern/qfr/jkq/qfr
1110
include extern/qfr/extern/dd_package/CMakeLists.txt
12-
graft extern/qfr/extern/dd_package/src
1311
graft extern/qfr/extern/dd_package/include
14-
graft extern/qfr/extern/dd_package/cmake
1512
graft extern/qfr/extern/json
1613
graft extern/qfr/extern/pybind11
1714
graft extern/qfr/extern/pybind11_json

README.md

+16-12
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,23 @@ If you have any questions, feel free to contact us via [[email protected]](mail
4444

4545
JKQ QCEC is mainly developed as a C++ library with an easy-to-use Python interface.
4646
- Get the Python package
47-
```bash
48-
pip install jkq.qcec
49-
```
47+
```bash
48+
pip install jkq.qcec
49+
```
50+
In order to make the library as easy to use as possible (without compilation), we provide wheels for most common platforms (64-bit Linux, MacOS, Windows). However, in order to get the best performance out of QCEC, it is recommended to
51+
build it locally from the source distribution via
52+
```bash
53+
pip install --no-binary jkq.qcec
54+
```
55+
This enables platform specific compiler optimizations that cannot be enabled on portable wheels.
5056
- Start using it in Python:
51-
```python
52-
from jkq.qcec import *
53-
54-
config = Configuration()
55-
<...> # set configuration options
56-
results = verify(circ1, circ2, config)
57-
```
57+
```python
58+
from jkq.qcec import *
59+
60+
config = Configuration()
61+
<...> # set configuration options
62+
results = verify(circ1, circ2, config)
63+
```
5864
Both circuits can either be IBM Qiskit `QuantumCircuit` objects or paths to circuit files (in any of the formats listed above).
5965

6066
The verification procedure can be configured with the following settings and options:
@@ -244,5 +250,3 @@ If you use our tool for your research, we will be thankful if you refer to it by
244250
```
245251
246252
</details>
247-
248-

extern/qfr

Submodule qfr updated from a75d600 to 1d5e9a3

include/EquivalenceCheckingResults.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,13 @@ namespace ec {
9292
static void to_json(nlohmann::json& j, const dd::CVec& stateVector) {
9393
j = nlohmann::json::array();
9494
for (const auto& amp: stateVector) {
95-
j.emplace_back(amp);
95+
j.emplace_back(std::pair{amp.real(), amp.imag()});
9696
}
9797
}
9898
static void from_json(const nlohmann::json& j, dd::CVec& stateVector) {
9999
for (std::size_t i = 0; i < j.size(); ++i) {
100-
stateVector[i] = j.at(i).get<std::pair<dd::fp, dd::fp>>();
100+
const auto& c = j.at(i).get<std::pair<dd::fp, dd::fp>>();
101+
stateVector[i] = std::complex<dd::fp>(c.first, c.second);
101102
}
102103
}
103104
[[nodiscard]] nlohmann::json produceJSON() const;

jkq/qcec/bindings.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
*/
55

66
#include "CompilationFlowEquivalenceChecker.hpp"
7-
#include "QiskitImport.hpp"
87
#include "SimulationBasedEquivalenceChecker.hpp"
98
#include "pybind11/pybind11.h"
109
#include "pybind11/stl.h"
1110
#include "pybind11_json/pybind11_json.hpp"
11+
#include "qiskit/QuantumCircuit.hpp"
1212

1313
namespace py = pybind11;
1414
namespace nl = nlohmann;
@@ -25,7 +25,7 @@ ec::EquivalenceCheckingResults verify(const py::object& circ1,
2525
auto&& file1 = circ1.cast<std::string>();
2626
qc1.import(file1);
2727
} else {
28-
import(qc1, circ1);
28+
qc::qiskit::QuantumCircuit::import(qc1, circ1);
2929
}
3030
} catch (std::exception const& e) {
3131
py::print("Could not import first circuit: ", e.what());
@@ -38,7 +38,7 @@ ec::EquivalenceCheckingResults verify(const py::object& circ1,
3838
auto&& file2 = circ2.cast<std::string>();
3939
qc2.import(file2);
4040
} else {
41-
import(qc2, circ2);
41+
qc::qiskit::QuantumCircuit::import(qc2, circ2);
4242
}
4343
} catch (std::exception const& e) {
4444
py::print("Could not import second circuit: ", e.what());

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def build_extension(self, ext):
6565

6666
setup(
6767
name='jkq.qcec',
68-
version='1.9.1',
68+
version='1.10.0',
6969
author='Lukas Burgholzer',
7070
author_email='[email protected]',
7171
description='QCEC - A JKQ tool for Quantum Circuit Equivalence Checking',

test/test_general.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ TEST_F(GeneralTest, InvalidStrategy) {
208208
qc_original.emplace_back<qc::StandardOperation>(1, 0, qc::X);
209209

210210
ec::ImprovedDDEquivalenceChecker ec2(qc_original, qc_original);
211-
ec::Configuration config{.strategy = ec::Strategy::CompilationFlow};
211+
ec::Configuration config{};
212+
config.strategy = ec::Strategy::CompilationFlow;
212213
EXPECT_THROW(ec2.check(config), std::invalid_argument);
213214
}
214215

0 commit comments

Comments
 (0)