Skip to content

Commit

Permalink
fix qasm_simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj committed Aug 9, 2024
1 parent 5141dc3 commit b60220f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 32 deletions.
2 changes: 1 addition & 1 deletion qiskit_aer/backends/qasm_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def configuration(self):
"""
config = self._configuration.copy()
for key, val in self._options_configuration.items():
setattr(config, key, val)
config[key] = val
# Update basis gates based on custom options, config, method,
# and noise model
config["custom_instructions"] = self._custom_instructions()
Expand Down
13 changes: 10 additions & 3 deletions qiskit_aer/noise/errors/quantum_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,16 @@ def to_dict(self):
for circ in self._circs:
circ_inst = []
for inst in circ.data:
qobj_inst = inst.operation.assemble()
qobj_inst.qubits = [circ.find_bit(q).index for q in inst.qubits]
circ_inst.append(qobj_inst.to_dict())
inst_dict = {}
inst_dict["name"] = inst.operation.name
inst_dict["qubits"] = [circ.find_bit(q).index for q in inst.qubits]
if inst.operation.params:
inst_dict["params"] = inst.operation.params
if inst.operation.label:
inst_dict["label"] = inst.operation.label
if inst.operation.condition:
inst_dict["condition"] = inst.operation.condition
circ_inst.append(inst_dict)
instructions.append(circ_inst)
# Construct error dict
error = {
Expand Down
23 changes: 0 additions & 23 deletions test/terra/backends/aer_simulator/test_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,29 +193,6 @@ def test_metadata_protected(self):

deepcopy(job.result())

def test_run_qobj(self):
"""Test qobj run"""

qubits = QuantumRegister(3)
clbits = ClassicalRegister(3)

circuit = QuantumCircuit(qubits, clbits)
circuit.h(qubits[0])
circuit.cx(qubits[0], qubits[1])
circuit.cx(qubits[0], qubits[2])

for q, c in zip(qubits, clbits):
circuit.measure(q, c)

backend = self.backend()

shots = 1000
with self.assertWarns(DeprecationWarning):
result = backend.run(assemble(circuit), shots=shots).result()

self.assertSuccess(result)
self.compare_counts(result, [circuit], [{"0x0": 500, "0x7": 500}], delta=0.05 * shots)

def test_numpy_integer_shots(self):
"""Test implicit cast of shot option from np.int_ to int."""

Expand Down
7 changes: 2 additions & 5 deletions test/terra/backends/aer_simulator/test_truncate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
import qiskit
from qiskit import transpile, QuantumCircuit

if qiskit.__version__.startswith("0."):
from qiskit.providers.fake_provider import FakeQuito as Fake5QV1
else:
from qiskit.providers.fake_provider import Fake5QV1
from qiskit.providers.fake_provider import GenericBackendV2

from qiskit_aer.noise import NoiseModel
from test.terra.backends.simulator_test_case import SimulatorTestCase, supported_methods
Expand Down Expand Up @@ -53,7 +50,7 @@ def create_circuit_for_truncate(self):
return circuit

def device_backend(self):
return Fake5QV1()
return GenericBackendV2(num_qubits=5)

def test_truncate_ideal_sparse_circuit(self):
"""Test qubit truncation for large circuit with unused qubits."""
Expand Down

0 comments on commit b60220f

Please sign in to comment.