Skip to content

Commit

Permalink
Migration from QasmSimulator to qiskit_aer's AerSimulator
Browse files Browse the repository at this point in the history
  • Loading branch information
robotAstray committed Aug 8, 2023
1 parent 51760ca commit 147bf94
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/qiskit_qec/analysis/faultenumerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
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 import execute
from qiskit_aer import Aer

from qiskit_qec.analysis.extensions import C_FAULT_ENUMERATOR

Expand Down
3 changes: 2 additions & 1 deletion src/qiskit_qec/analysis/faultsampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
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 import execute
from qiskit_aer import Aer

from qiskit_qec.utils.dag import node_name_label

Expand Down
8 changes: 4 additions & 4 deletions src/qiskit_qec/circuits/repetition_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister, transpile
from qiskit.circuit.library import XGate, RZGate
from qiskit.transpiler import PassManager, InstructionDurations
from qiskit.transpiler.passes import DynamicalDecoupling
from qiskit.transpiler.passes import ALAPScheduleAnalysis, PadDynamicalDecoupling

from qiskit_qec.circuits.code_circuit import CodeCircuit
from qiskit_qec.utils import DecodingGraphNode, DecodingGraphEdge
Expand Down Expand Up @@ -1268,7 +1268,6 @@ def check_nodes(self, nodes, ignore_extra_boundary=False, minimal=False):
# if neutral for maximal, it's neutral
# otherwise, it is whatever it is for the minimal
for c in cs:

neutral = base_neutral
num_errors = num_nodes[c]
flipped_logicals = flipped_logicals_all[c]
Expand Down Expand Up @@ -1381,9 +1380,10 @@ def transpile(self, backend, echo=("X", "X"), echo_num=(2, 0)):
qubits = None
pm = PassManager(
[
DynamicalDecoupling(
ALAPScheduleAnalysis(durations),
PadDynamicalDecoupling(
durations, dd_sequence, qubits=qubits, spacing=spacings[j]
)
),
]
)
circuits = pm.run(circuits)
Expand Down
7 changes: 4 additions & 3 deletions test/code_circuits/test_rep_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
import itertools
from random import choices

from qiskit import Aer, QuantumCircuit, execute
from qiskit import QuantumCircuit, execute
from qiskit.providers.fake_provider import FakeJakarta
from qiskit_aer import Aer, AerSimulator
from qiskit_aer.noise import NoiseModel
from qiskit_aer.noise.errors import depolarizing_error
from qiskit_qec.circuits.repetition_code import RepetitionCodeCircuit as RepetitionCode
Expand Down Expand Up @@ -352,7 +353,7 @@ def test_single_error_202s(self):
else:
error_qc.x(code.link_qubit[code.link_index[q]])
error_qc.append(gate)
counts = Aer.get_backend("qasm_simulator").run(error_qc).result().get_counts()
counts = AerSimulator().run(error_qc).result().get_counts()
for string in counts:
# look at only bulk non-conjugate nodes
nodes = [
Expand Down Expand Up @@ -391,7 +392,7 @@ def test_feedforward(self):
for gate in qc:
test_qc.append(gate)
test_qcs.append(test_qc)
result = Aer.get_backend("qasm_simulator").run(test_qcs).result()
result = AerSimulator().run(test_qcs).result()
# check result strings are correct
for j in range(2):
counts = result.get_counts(j)
Expand Down
3 changes: 2 additions & 1 deletion test/heavy_hex_codes/test_heavy_hex_decoder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Test a heavy-hexagon code decoder"""
import unittest

from qiskit import execute, Aer
from qiskit import execute
from qiskit_aer import Aer

from qiskit_qec.codes.hhc import HHC
from qiskit_qec.circuits.hhc_circuit import HHCCircuit
Expand Down
3 changes: 2 additions & 1 deletion 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 execute, 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
3 changes: 2 additions & 1 deletion test/matching/test_repetitionmatcher.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, Aer
from qiskit import execute
from qiskit_aer import Aer

from qiskit_qec.analysis.faultenumerator import FaultEnumerator
from qiskit_qec.decoders.circuit_matching_decoder import temp_syndrome
Expand Down

0 comments on commit 147bf94

Please sign in to comment.