From c8301855b505c16344565060a6c7091d0ba5a12f Mon Sep 17 00:00:00 2001 From: zhao-yilun-zyl Date: Wed, 5 Jun 2024 16:26:11 +0800 Subject: [PATCH 1/3] fix: SimFinalResult mode for pyqcis_quantumsim backend seems to be broken --- src/qututor/bell/test_bell.py | 2 +- src/qututor/classical_tools/test_utils.py | 2 +- src/qututor/ghz/test_ghz.py | 2 +- src/qututor/grover/test_grover.py | 2 +- src/qututor/qft/test_qft_bb.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qututor/bell/test_bell.py b/src/qututor/bell/test_bell.py index 162533e..e3a6c51 100644 --- a/src/qututor/bell/test_bell.py +++ b/src/qututor/bell/test_bell.py @@ -11,7 +11,7 @@ class Test_Bell: def test_bell(self): task = Quingo_task(qu_file, circ_name) num_shots = 10 - cfg = ExeConfig(ExeMode.SimFinalResult, num_shots) + cfg = ExeConfig(ExeMode.SimShots, num_shots) res = call(task, (), BackendType.QUANTUM_SIM, cfg) assert len(res[0]) == 2 assert len(res[1]) == num_shots diff --git a/src/qututor/classical_tools/test_utils.py b/src/qututor/classical_tools/test_utils.py index 932794a..a3bba58 100644 --- a/src/qututor/classical_tools/test_utils.py +++ b/src/qututor/classical_tools/test_utils.py @@ -11,7 +11,7 @@ class Test_Utils: def test_individual(self): circ_name = "get_bin" task = Quingo_task(kernel_file, circ_name, qisa=Qisa.QCIS) - cfg = ExeConfig(ExeMode.SimFinalResult, 1) + cfg = ExeConfig(ExeMode.SimShots, 1) for i in range(7): res = call( task, diff --git a/src/qututor/ghz/test_ghz.py b/src/qututor/ghz/test_ghz.py index 3c4acb9..482cff7 100644 --- a/src/qututor/ghz/test_ghz.py +++ b/src/qututor/ghz/test_ghz.py @@ -10,7 +10,7 @@ class Test_GHZ: num_qubits = 3 num_shots = 10 task = Quingo_task(qu_file, circ_name) - cfg = ExeConfig(ExeMode.SimFinalResult, num_shots) + cfg = ExeConfig(ExeMode.SimShots, num_shots) res = call(task, (num_qubits,), BackendType.TEQUILA, cfg) assert len(res[0]) == num_qubits assert len(res[1]) == num_shots diff --git a/src/qututor/grover/test_grover.py b/src/qututor/grover/test_grover.py index 27d4a57..28fb8e7 100644 --- a/src/qututor/grover/test_grover.py +++ b/src/qututor/grover/test_grover.py @@ -11,7 +11,7 @@ class Test_Grover: def test_grover(self): task = Quingo_task(qu_file, circ_name) num_shots = 1 - cfg = ExeConfig(ExeMode.SimFinalResult, num_shots) + cfg = ExeConfig(ExeMode.SimShots, num_shots) res = call(task, (), BackendType.QUANTUM_SIM, cfg) assert len(res[0]) == 2 assert len(res[1]) == num_shots diff --git a/src/qututor/qft/test_qft_bb.py b/src/qututor/qft/test_qft_bb.py index eeea3ec..963fd73 100644 --- a/src/qututor/qft/test_qft_bb.py +++ b/src/qututor/qft/test_qft_bb.py @@ -37,7 +37,7 @@ def get_first_non_zero_res(qcis_result): return to_int(msmt_count[0]) -cfg = ExeConfig(ExeMode.SimFinalResult, 1) +cfg = ExeConfig(ExeMode.SimShots, 1) class Test_QFT_BB: -- Gitee From 9a607ba9ef8ca5a9b34b601113e5066498b55cc1 Mon Sep 17 00:00:00 2001 From: zhao-yilun-zyl Date: Thu, 6 Jun 2024 17:34:44 +0800 Subject: [PATCH 2/3] fix: no field named 'quantum' in res --- src/qututor/H2_VQE/host.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qututor/H2_VQE/host.py b/src/qututor/H2_VQE/host.py index 639d67c..5dcc9d7 100644 --- a/src/qututor/H2_VQE/host.py +++ b/src/qututor/H2_VQE/host.py @@ -129,7 +129,7 @@ def get_ansatz(circ_name, theta): task = Quingo_task(qu_file, circ_name) qasm_file = compile(task, (theta,), config_file=cfg_file) res = execute(qasm_file, BackendType.QUANTUM_SIM, ExeConfig(ExeMode.SimStateVector)) - return [i for i in res["quantum"][1]] + return res[1] def get_real(c): -- Gitee From b0025eb6e4d3fc8c229ebc8251f644c2bd8b1b50 Mon Sep 17 00:00:00 2001 From: zhao-yilun-zyl Date: Fri, 14 Jun 2024 14:26:42 +0800 Subject: [PATCH 3/3] chore: add comments for using quiets --- src/qututor/qft/test_qft_bb.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qututor/qft/test_qft_bb.py b/src/qututor/qft/test_qft_bb.py index 963fd73..bb2e1c5 100644 --- a/src/qututor/qft/test_qft_bb.py +++ b/src/qututor/qft/test_qft_bb.py @@ -48,13 +48,18 @@ class Test_QFT_BB: blist = [int(b) for b in str_bin] print("input :", str_bin) blist.reverse() + # Specifying ISA as QUIET-S by + # task = Quingo_task(qu_file, "test_qft_bb", qisa=Qisa.QUIET) task = Quingo_task(qu_file, "test_qft_bb", qisa=Qisa.QCIS) res = call( task, (blist,), + # To simulate QUIET-S assembly, use QualeSim backend + # BackendType.QUALESIM_QUANTUMSIM, BackendType.QUANTUM_SIM, cfg, ) + print(res) k = get_first_non_zero_res(res) assert k == i -- Gitee