Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #247 - Replace execute with backend.run() in qiskit-qec #381

13 changes: 4 additions & 9 deletions src/qiskit_qec/analysis/faultenumerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -185,14 +185,9 @@ def gint(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]))
Expand Down
13 changes: 4 additions & 9 deletions src/qiskit_qec/analysis/faultsampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -150,14 +150,9 @@ def gint(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]))
Expand Down
13 changes: 4 additions & 9 deletions test/heavy_hex_codes/test_heavy_hex_decoder.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -82,14 +82,9 @@ 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
Expand Down
25 changes: 8 additions & 17 deletions test/matching/test_circuitmatcher.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -82,14 +83,9 @@ 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
Expand Down Expand Up @@ -120,14 +116,9 @@ 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
Expand Down
13 changes: 4 additions & 9 deletions test/matching/test_repetitionmatcher.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -52,14 +52,9 @@ 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
Expand Down
Loading