From bd360f832fa8fac4207b60690c6a0cbe48f82809 Mon Sep 17 00:00:00 2001 From: robotAstray Date: Thu, 17 Aug 2023 11:54:45 +0100 Subject: [PATCH 1/7] replace `execute` with `backend.run()` in `test_repetitionmatcher.py` --- test/matching/test_repetitionmatcher.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/matching/test_repetitionmatcher.py b/test/matching/test_repetitionmatcher.py index 0f0642e9..8396158f 100644 --- a/test/matching/test_repetitionmatcher.py +++ b/test/matching/test_repetitionmatcher.py @@ -1,7 +1,7 @@ """Tests for the subsystem CSS circuit-level matching decoder.""" import unittest -from qiskit import execute, Aer +from qiskit_aer import Aer from qiskit_qec.analysis.faultenumerator import FaultEnumerator from qiskit_qec.decoders.circuit_matching_decoder import temp_syndrome @@ -52,14 +52,13 @@ def gint(c): for logical in ["0", "1"]: dec = RepetitionDecoder(self.code_circuit, self.pnm, method, False, logical) qc = self.code_circuit.circuit[logical] - result = execute( - qc, - Aer.get_backend("aer_simulator"), - method="stabilizer", - shots=shots, - optimization_level=0, - seed_simulator=seed, - ).result() + backend = Aer.get_backend("aer_simulator") + options = { + "method": "stabilizer", + "shots": shots, + "seed_simulator": seed + } + result = backend.run(qc, **options).result() counts = result.get_counts(qc) dec.update_edge_weights(self.pnm) failures = 0 From 4c1a8f1d1fb321e9a38b30057c6f5cc940c3b30e Mon Sep 17 00:00:00 2001 From: robotAstray Date: Thu, 17 Aug 2023 12:03:28 +0100 Subject: [PATCH 2/7] replace `execute` with `backend.run()` in `test_circuitmatcher.py` --- test/matching/test_circuitmatcher.py | 33 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/test/matching/test_circuitmatcher.py b/test/matching/test_circuitmatcher.py index 61de1252..66385c63 100644 --- a/test/matching/test_circuitmatcher.py +++ b/test/matching/test_circuitmatcher.py @@ -1,7 +1,8 @@ """Tests for the subsystem CSS circuit-level matching decoder.""" import unittest -from qiskit import execute, QuantumCircuit, Aer +from qiskit import QuantumCircuit +from qiskit_aer import Aer from qiskit_qec.analysis.faultenumerator import FaultEnumerator from qiskit_qec.decoders.circuit_matching_decoder import temp_syndrome @@ -82,14 +83,13 @@ def test_no_errors(self): "rustworkx", False, ) - result = execute( - self.qc, - Aer.get_backend("aer_simulator"), - method="stabilizer", - shots=shots, - optimization_level=0, - seed_simulator=seed, - ).result() + backend = Aer.get_backend("aer_simulator") + options = { + "method": "stabilizer", + "shots": shots, + "seed_simulator": seed + } + result = backend.run(self.qc, **options).result() counts = result.get_counts(self.qc) dec.update_edge_weights(self.pnm) failures = 0 @@ -120,14 +120,13 @@ def test_no_errors_pymatching(self): "pymatching", False, ) - result = execute( - self.qc, - Aer.get_backend("aer_simulator"), - method="stabilizer", - shots=shots, - optimization_level=0, - seed_simulator=seed, - ).result() + backend = Aer.get_backend("aer_simulator") + options = { + "method": "stabilizer", + "shots": shots, + "seed_simulator": seed + } + result = backend.run(self.qc, **options).result() counts = result.get_counts(self.qc) dec.update_edge_weights(self.pnm) failures = 0 From 9af3be107982e0127d5e344372ea14eaf2ef9e5f Mon Sep 17 00:00:00 2001 From: robotAstray Date: Thu, 17 Aug 2023 12:05:23 +0100 Subject: [PATCH 3/7] replace `execute` with `backend.run()` in `test_heavy_hex_decoder.py` --- test/heavy_hex_codes/test_heavy_hex_decoder.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/heavy_hex_codes/test_heavy_hex_decoder.py b/test/heavy_hex_codes/test_heavy_hex_decoder.py index 7d7a9da7..69e80f79 100644 --- a/test/heavy_hex_codes/test_heavy_hex_decoder.py +++ b/test/heavy_hex_codes/test_heavy_hex_decoder.py @@ -1,7 +1,7 @@ """Test a heavy-hexagon code decoder""" import unittest -from qiskit import execute, Aer +from qiskit_aer import Aer from qiskit_qec.codes.hhc import HHC from qiskit_qec.circuits.hhc_circuit import HHCCircuit @@ -82,14 +82,13 @@ def no_faults_success(self, code, circ, dec, model, good=0, xbasis=False): """Test for correct behavior without faults.""" shots = 10 seed = 100 - result = execute( - circ, - Aer.get_backend("aer_simulator"), - method="stabilizer", - shots=shots, - optimization_level=0, - seed_simulator=seed, - ).result() + backend = Aer.get_backend("aer_simulator") + options = { + "method": "stabilizer", + "shots": shots, + "seed_simulator": seed + } + result = backend.run(circ, **options).result() counts = result.get_counts(circ) dec.update_edge_weights(model) failures = 0 From 1c383c21058fbaa1807be07a762cb689a17c4d81 Mon Sep 17 00:00:00 2001 From: robotAstray Date: Thu, 17 Aug 2023 12:08:49 +0100 Subject: [PATCH 4/7] replace `execute` with `backend.run()` in `faultsampler.py` --- src/qiskit_qec/analysis/faultsampler.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/qiskit_qec/analysis/faultsampler.py b/src/qiskit_qec/analysis/faultsampler.py index c7db629e..70de4609 100644 --- a/src/qiskit_qec/analysis/faultsampler.py +++ b/src/qiskit_qec/analysis/faultsampler.py @@ -7,7 +7,7 @@ from qiskit.dagcircuit.dagnode import DAGNode from qiskit.converters import circuit_to_dag from qiskit.circuit.library import IGate, XGate, YGate, ZGate -from qiskit import execute, Aer +from qiskit_aer import Aer from qiskit_qec.utils.dag import node_name_label @@ -149,15 +149,13 @@ def gint(c): return int(c) else: return c - - result = execute( - circ, - Aer.get_backend("aer_simulator"), - method="stabilizer", - shots=1, - optimization_level=0, - seed_simulator=self.sim_seed, - ).result() + backend = Aer.get_backend("aer_simulator") + options = { + "method": "stabilizer", + "shots": 1, + "seed_simulator": self.sim_seed + } + result = backend.run(circ, **options).result() outcomes = result.get_counts(circ) raw_outcome = list(outcomes.keys())[0] outcome = list(map(gint, raw_outcome[::-1])) From dc0b6d8a5945125c84e6546bb2e7fcf0aac4d53b Mon Sep 17 00:00:00 2001 From: robotAstray Date: Thu, 17 Aug 2023 12:09:54 +0100 Subject: [PATCH 5/7] replace `execute` with `backend.run()` in `faultenumerator.py` --- src/qiskit_qec/analysis/faultenumerator.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/qiskit_qec/analysis/faultenumerator.py b/src/qiskit_qec/analysis/faultenumerator.py index 4df31677..90a1a3a7 100644 --- a/src/qiskit_qec/analysis/faultenumerator.py +++ b/src/qiskit_qec/analysis/faultenumerator.py @@ -18,7 +18,7 @@ from qiskit import QuantumCircuit from qiskit.converters import circuit_to_dag from qiskit.circuit.library import IGate, XGate, YGate, ZGate -from qiskit import execute, Aer +from qiskit_aer import Aer from qiskit_qec.analysis.extensions import C_FAULT_ENUMERATOR @@ -184,15 +184,13 @@ def gint(c): return int(c) else: return c - - result = execute( - circ, - Aer.get_backend("aer_simulator"), - method="stabilizer", - shots=1, - optimization_level=0, - seed_simulator=self.sim_seed, - ).result() + backend = Aer.get_backend("aer_simulator") + options = { + "method": "stabilizer", + "shots": 1, + "seed_simulator": self.sim_seed + } + result = backend.run(circ, **options).result() outcomes = result.get_counts(circ) raw_outcome = list(outcomes.keys())[0] outcome = list(map(gint, raw_outcome[::-1])) From 8f73751fbb5b9c51a1f4a6b40b3803a0c1b91d97 Mon Sep 17 00:00:00 2001 From: robotAstray Date: Fri, 25 Aug 2023 23:25:46 +0100 Subject: [PATCH 6/7] formatting --- src/qiskit_qec/analysis/faultenumerator.py | 9 +++------ src/qiskit_qec/analysis/faultsampler.py | 9 +++------ test/heavy_hex_codes/test_heavy_hex_decoder.py | 8 ++------ test/matching/test_circuitmatcher.py | 12 ++---------- 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/qiskit_qec/analysis/faultenumerator.py b/src/qiskit_qec/analysis/faultenumerator.py index 90a1a3a7..910ace1e 100644 --- a/src/qiskit_qec/analysis/faultenumerator.py +++ b/src/qiskit_qec/analysis/faultenumerator.py @@ -184,13 +184,10 @@ def gint(c): return int(c) else: return c + backend = Aer.get_backend("aer_simulator") - options = { - "method": "stabilizer", - "shots": 1, - "seed_simulator": self.sim_seed - } - result = backend.run(circ, **options).result() + options = {"method": "stabilizer", "shots": 1, "seed_simulator": self.sim_seed} + result = backend.run(circ, **options).result() outcomes = result.get_counts(circ) raw_outcome = list(outcomes.keys())[0] outcome = list(map(gint, raw_outcome[::-1])) diff --git a/src/qiskit_qec/analysis/faultsampler.py b/src/qiskit_qec/analysis/faultsampler.py index 70de4609..99e7d040 100644 --- a/src/qiskit_qec/analysis/faultsampler.py +++ b/src/qiskit_qec/analysis/faultsampler.py @@ -149,13 +149,10 @@ def gint(c): return int(c) else: return c + backend = Aer.get_backend("aer_simulator") - options = { - "method": "stabilizer", - "shots": 1, - "seed_simulator": self.sim_seed - } - result = backend.run(circ, **options).result() + options = {"method": "stabilizer", "shots": 1, "seed_simulator": self.sim_seed} + result = backend.run(circ, **options).result() outcomes = result.get_counts(circ) raw_outcome = list(outcomes.keys())[0] outcome = list(map(gint, raw_outcome[::-1])) diff --git a/test/heavy_hex_codes/test_heavy_hex_decoder.py b/test/heavy_hex_codes/test_heavy_hex_decoder.py index 69e80f79..a02bebf8 100644 --- a/test/heavy_hex_codes/test_heavy_hex_decoder.py +++ b/test/heavy_hex_codes/test_heavy_hex_decoder.py @@ -83,12 +83,8 @@ def no_faults_success(self, code, circ, dec, model, good=0, xbasis=False): shots = 10 seed = 100 backend = Aer.get_backend("aer_simulator") - options = { - "method": "stabilizer", - "shots": shots, - "seed_simulator": seed - } - result = backend.run(circ, **options).result() + options = {"method": "stabilizer", "shots": shots, "seed_simulator": seed} + result = backend.run(circ, **options).result() counts = result.get_counts(circ) dec.update_edge_weights(model) failures = 0 diff --git a/test/matching/test_circuitmatcher.py b/test/matching/test_circuitmatcher.py index 66385c63..d15c7a8e 100644 --- a/test/matching/test_circuitmatcher.py +++ b/test/matching/test_circuitmatcher.py @@ -84,11 +84,7 @@ def test_no_errors(self): False, ) backend = Aer.get_backend("aer_simulator") - options = { - "method": "stabilizer", - "shots": shots, - "seed_simulator": seed - } + options = {"method": "stabilizer", "shots": shots, "seed_simulator": seed} result = backend.run(self.qc, **options).result() counts = result.get_counts(self.qc) dec.update_edge_weights(self.pnm) @@ -121,11 +117,7 @@ def test_no_errors_pymatching(self): False, ) backend = Aer.get_backend("aer_simulator") - options = { - "method": "stabilizer", - "shots": shots, - "seed_simulator": seed - } + options = {"method": "stabilizer", "shots": shots, "seed_simulator": seed} result = backend.run(self.qc, **options).result() counts = result.get_counts(self.qc) dec.update_edge_weights(self.pnm) From 18543a8acaabb24cc8f7c6776ed60ad86a771a8b Mon Sep 17 00:00:00 2001 From: robotAstray Date: Tue, 19 Sep 2023 17:26:43 +0100 Subject: [PATCH 7/7] re-format test_repetitionmatcher.py --- test/matching/test_repetitionmatcher.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/matching/test_repetitionmatcher.py b/test/matching/test_repetitionmatcher.py index 8396158f..6de89203 100644 --- a/test/matching/test_repetitionmatcher.py +++ b/test/matching/test_repetitionmatcher.py @@ -53,11 +53,7 @@ def gint(c): dec = RepetitionDecoder(self.code_circuit, self.pnm, method, False, logical) qc = self.code_circuit.circuit[logical] backend = Aer.get_backend("aer_simulator") - options = { - "method": "stabilizer", - "shots": shots, - "seed_simulator": seed - } + options = {"method": "stabilizer", "shots": shots, "seed_simulator": seed} result = backend.run(qc, **options).result() counts = result.get_counts(qc) dec.update_edge_weights(self.pnm)