Skip to content

Commit

Permalink
Fix test_unitary.py with new simulator API
Browse files Browse the repository at this point in the history
- create C++ version of decomposed_U tests for debugging
- this test is flaky and skipped in CI
- skip also the Python unitary tests in CI
  • Loading branch information
pablolh committed May 22, 2023
1 parent 1c00405 commit 9d15589
Show file tree
Hide file tree
Showing 17 changed files with 1,783 additions and 371 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
if: matrix.os == 'windows-latest'
run: choco install winflexbison3 --version 2.5.18.20190508
- name: Configure
run: cmake . -DCMAKE_BUILD_TYPE=Debug -DOPENQL_BUILD_TESTS=ON -DBUILD_SHARED_LIBS=OFF
run: cmake . -DCMAKE_BUILD_TYPE=Debug -DOPENQL_BUILD_TESTS=ON -DBUILD_SHARED_LIBS=OFF -DWITH_UNITARY_DECOMPOSITION=OFF
- name: Build
run: cmake --build . --parallel 5
- name: Test
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: python -m pip install --upgrade pip setuptools wheel pytest numpy
run: python -m pip install --upgrade pip setuptools wheel pytest numpy qxelarator
- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y swig
Expand Down Expand Up @@ -115,6 +115,12 @@ jobs:
- name: Select build type
if: matrix.os != 'windows-latest'
run: echo "OPENQL_BUILD_TYPE=Debug" >> $GITHUB_ENV
- name: Disable unitary decomposition
if: matrix.os != 'windows-latest'
run: echo "OPENQL_DISABLE_UNITARY=true" >> $GITHUB_ENV
- name: Disable unitary decomposition
if: matrix.os == 'windows-latest'
run: echo "OPENQL_DISABLE_UNITARY=true" >> $env:GITHUB_ENV
- name: Build
env:
NPROCS: 5
Expand Down
2 changes: 2 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)

add_openql_test(test_cc cc/test_cc.cc cc)
add_openql_test(test_unitary cc/test_unitary.cc cc)
target_link_libraries(test_unitary doctest)
add_openql_test(test_mapper test_mapper.cc .)
add_openql_test(test_multi_core test_multi_core.cc .)
add_openql_test(program_test program_test.cc .)
Expand Down
44 changes: 44 additions & 0 deletions tests/cc/debug.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <openql>

int main(int, char **) {
ql::initialize();
ql::utils::logger::set_log_level("LOG_INFO");
ql::set_option("log_level", "LOG_INFO");

ql::set_option("maptiebreak", "random");

ql::set_option("use_default_gates", "no");

ql::set_option("decompose_toffoli", "no");
ql::set_option("scheduler", "ASAP");
ql::set_option("scheduler_heuristic", "random");
ql::set_option("scheduler_uniform", "no");
ql::set_option("scheduler_commute", "yes");
ql::set_option("scheduler_commute_rotations", "yes");
ql::set_option("prescheduler", "yes");
ql::set_option("print_dot_graphs", "no");

ql::set_option("clifford_premapper", "yes");
ql::set_option("clifford_postmapper", "no");
ql::set_option("mapper", "base");
ql::set_option("mapassumezeroinitstate", "yes");
ql::set_option("mapusemoves", "no");
ql::set_option("mapreverseswap", "yes");
ql::set_option("mapmaxalters", "10");
// ql::set_option("mappathselect", "random");
ql::set_option("maplookahead", "noroutingfirst");
ql::set_option("maprecNN2q", "no");
ql::set_option("mapselectmaxlevel", "0");
ql::set_option("mapselectmaxwidth", "min");

ql::set_option("write_qasm_files", "yes");
ql::set_option("write_report_files", "yes");

auto platform = ql::Platform("mctests", "test_multi_core_64x16_full.json");
auto num_qubits = 18;
auto p = ql::Program("qaoa_q1024", platform, num_qubits);
auto k = ql::Kernel("qaoa_q1024", platform, num_qubits);
k.gate("cnot", 0, 17);
p.add_kernel(k);
p.compile();
}
26 changes: 26 additions & 0 deletions tests/cc/test_cfg_none_simple.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"eqasm_compiler" : "none",

"hardware_settings": {
"qubit_number": 17,
"cycle_time" : 20,
"mw_mw_buffer": 0,
"mw_flux_buffer": 0,
"mw_readout_buffer": 0,
"flux_mw_buffer": 0,
"flux_flux_buffer": 0,
"flux_readout_buffer": 0,
"readout_mw_buffer": 0,
"readout_flux_buffer": 0,
"readout_readout_buffer": 0
},

"instructions": {
},

"gate_decomposition": {
},

"resources": {},
"topology": {}
}
279 changes: 279 additions & 0 deletions tests/cc/test_multi_core_64x16_full.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
{
"eqasm_compiler" : "cc_light_compiler",

"hardware_settings": {
"qubit_number": 512,
"cycle_time" : 20,
"mw_mw_buffer": 0,
"mw_flux_buffer": 0,
"mw_readout_buffer": 0,
"flux_mw_buffer": 0,
"flux_flux_buffer": 0,
"flux_readout_buffer": 0,
"readout_mw_buffer": 0,
"readout_flux_buffer": 0,
"readout_readout_buffer": 0
},

"qubit_attributes":
{
"relaxation_times":
{
"0" : [3000, 1500],
"1" : [3000, 1500],
"2" : [3000, 1500],
"3" : [3000, 1500],
"4" : [3000, 1500]
}
},

"topology" :
{
"number_of_cores": 64,
"connectivity": "full",
"form": "irregular",
"comm_qubits_per_core": 16
},

"resources":
{
"qubits":
{
"description": "Each qubit can be used by only one gate at a time. There are 'count' qubits.",
"count": 1024
},
"channels":
{
"description": "Each inter-core gate uses one channel in each core. There are 'count' such channels per core.",
"count": 1
}
},

"instructions": {
"prepx": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "prepx"
},
"prepz": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "prepz"
},
"measx": {
"duration": 340,
"latency": 0,
"type": "readout",
"cc_light_instr": "measx"
},
"measz": {
"duration": 300,
"latency": 0,
"type": "readout",
"cc_light_instr": "measz"
},
"measure": {
"duration": 300,
"latency": 0,
"type": "readout",
"cc_light_instr": "measz"
},
"i": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "i"
},
"x": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "x"
},
"y": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "y"
},
"z": {
"duration": 40,
"latency": 0,
"type": "mw",
"cc_light_instr": "z"
},
"rx": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "rx"
},
"ry": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "ry"
},
"rz": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "rz"
},
"h": {
"duration": 40,
"latency": 0,
"type": "mw",
"cc_light_instr": "h"
},
"s": {
"duration": 60,
"latency": 0,
"type": "mw",
"cc_light_instr": "s"
},
"sdag": {
"duration": 60,
"latency": 0,
"type": "mw",
"cc_light_instr": "sdag"
},
"x90": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "x90"
},
"xm90": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "xm90"
},
"y90": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "y90"
},
"ym90": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "ym90"
},
"t": {
"duration": 60,
"latency": 0,
"type": "mw",
"cc_light_instr": "t"
},
"tdag": {
"duration": 60,
"latency": 0,
"type": "mw",
"cc_light_instr": "tdag"
},
"x45": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "x45"
},
"xm45": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "xm45"
},
"y45": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "y45"
},
"ym45": {
"duration": 20,
"latency": 0,
"type": "mw",
"cc_light_instr": "ym45"
},
"cz": {
"duration": 60,
"latency": 0,
"type": "flux",
"cc_light_instr": "cz"
},
"cnot": {
"duration": 100,
"latency": 0,
"type": "flux",
"cc_light_instr": "cnot"
},
"swap": {
"duration": 260,
"latency": 0,
"type": "flux",
"cc_light_instr": "swap"
},
"move": {
"duration": 180,
"latency": 0,
"type": "flux",
"cc_light_instr": "move"
},
"teleportswap": {
"duration": 1000,
"latency": 0,
"type": "extern",
"cc_light_instr": "teleportswap"
},
"teleportmove": {
"duration": 600,
"latency": 0,
"type": "extern",
"cc_light_instr": "teleportmove"
},
"preswap": {
"duration": 100,
"latency": 0,
"type": "mw",
"cc_light_instr": "preswap"
},
"premove": {
"duration": 100,
"latency": 0,
"type": "mw",
"cc_light_instr": "premove"
},
"postswap": {
"duration": 100,
"latency": 0,
"type": "mw",
"cc_light_instr": "postswap"
},
"postmove": {
"duration": 100,
"latency": 0,
"type": "mw",
"cc_light_instr": "postmove"
}
},

"gate_decomposition": {
"tswap_real %0,%1": ["preswap %0","teleportswap %0,%1","postswap %1"],
"tmove_real %0,%1": ["premove %0","teleportmove %0,%1","postmove %1"],
"rx180 %0" : ["x %0"],
"ry180 %0" : ["y %0"],
"rx90 %0" : ["x90 %0"],
"ry90 %0" : ["y90 %0"],
"mrx90 %0" : ["xm90 %0"],
"mry90 %0" : ["ym90 %0"],
"rx45 %0" : ["x45 %0"],
"ry45 %0" : ["y45 %0"],
"mrx45 %0" : ["xm45 %0"],
"mry45 %0" : ["ym45 %0"]
}
}
Loading

0 comments on commit 9d15589

Please sign in to comment.