diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5f25e8ea0c..aa7b3903d5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -176,7 +176,7 @@ jobs: run: | set -e python -I -m build --wheel --config-setting=--build-option=-- --config-setting=--build-option=-DTEST_JSON=1 - pip install --find-links=dist qiskit-aer + pip install -U dist/*.whl - name: Run Tests run: | set -e @@ -267,7 +267,7 @@ jobs: run: | set -e python -I -m build --wheel - pip install --find-links=dist qiskit-aer + pip install -U dist/*.whl shell: bash - name: Run Tests env: diff --git a/qiskit_aer/backends/aer_simulator.py b/qiskit_aer/backends/aer_simulator.py index 0f6e3758b0..2ede8e3bbb 100644 --- a/qiskit_aer/backends/aer_simulator.py +++ b/qiskit_aer/backends/aer_simulator.py @@ -516,6 +516,8 @@ class AerSimulator(AerBackend): "while_loop", "break_loop", "continue_loop", + "reset", + "switch_case", ] ), "density_matrix": sorted( @@ -538,6 +540,8 @@ class AerSimulator(AerBackend): "while_loop", "break_loop", "continue_loop", + "reset", + "switch_case", ] ), "matrix_product_state": sorted( @@ -562,6 +566,8 @@ class AerSimulator(AerBackend): "while_loop", "break_loop", "continue_loop", + "reset", + "switch_case", ] ), "stabilizer": sorted( @@ -583,6 +589,8 @@ class AerSimulator(AerBackend): "while_loop", "break_loop", "continue_loop", + "reset", + "switch_case", ] ), "extended_stabilizer": sorted( @@ -591,6 +599,7 @@ class AerSimulator(AerBackend): "qerror_loc", "roerror", "save_statevector", + "reset", ] ), "unitary": sorted( @@ -598,6 +607,7 @@ class AerSimulator(AerBackend): "save_state", "save_unitary", "set_unitary", + "reset", ] ), "superop": sorted( @@ -609,6 +619,7 @@ class AerSimulator(AerBackend): "save_state", "save_superop", "set_superop", + "reset", ] ), "tensor_network": sorted( @@ -630,6 +641,8 @@ class AerSimulator(AerBackend): "save_statevector_dict", "set_statevector", "set_density_matrix", + "reset", + "switch_case", ] ), } diff --git a/qiskit_aer/backends/backend_utils.py b/qiskit_aer/backends/backend_utils.py index d7b3e92c0b..d472b924f4 100644 --- a/qiskit_aer/backends/backend_utils.py +++ b/qiskit_aer/backends/backend_utils.py @@ -109,8 +109,6 @@ "pauli", "mcx_gray", "ecr", - "reset", - "switch_case", ] ), "density_matrix": sorted( @@ -151,8 +149,6 @@ "delay", "pauli", "ecr", - "reset", - "switch_case", ] ), "matrix_product_state": sorted( @@ -195,8 +191,6 @@ "cswap", "diagonal", "initialize", - "reset", - "switch_case", ] ), "stabilizer": sorted( @@ -216,12 +210,10 @@ "swap", "delay", "pauli", - "reset", "ecr", "rx", "ry", "rz", - "switch_case", ] ), "extended_stabilizer": sorted( @@ -247,7 +239,6 @@ "ccz", "delay", "pauli", - "reset", ] ), "unitary": sorted( @@ -309,7 +300,6 @@ "delay", "pauli", "ecr", - "reset", ] ), "superop": sorted( @@ -349,7 +339,6 @@ "diagonal", "delay", "pauli", - "reset", ] ), "tensor_network": sorted( @@ -412,7 +401,6 @@ "delay", "pauli", "mcx_gray", - "reset", ] ), } diff --git a/qiskit_aer/backends/qasm_simulator.py b/qiskit_aer/backends/qasm_simulator.py index 9e0bc8a7c9..d73938a6b9 100644 --- a/qiskit_aer/backends/qasm_simulator.py +++ b/qiskit_aer/backends/qasm_simulator.py @@ -365,7 +365,6 @@ class QasmSimulator(AerBackend): "pauli", "mcx_gray", "ecr", - "reset", ] ) @@ -389,6 +388,7 @@ class QasmSimulator(AerBackend): "set_statevector", "set_density_matrix", "set_stabilizer", + "reset", ] ) diff --git a/qiskit_aer/backends/statevector_simulator.py b/qiskit_aer/backends/statevector_simulator.py index bd288084ce..342997c49f 100644 --- a/qiskit_aer/backends/statevector_simulator.py +++ b/qiskit_aer/backends/statevector_simulator.py @@ -213,7 +213,6 @@ class StatevectorSimulator(AerBackend): "initialize", "delay", "pauli", - "reset", ] ), "custom_instructions": sorted( @@ -231,6 +230,7 @@ class StatevectorSimulator(AerBackend): "save_amplitudes_sq", "save_state", "set_statevector", + "reset", ] ), "gates": [], diff --git a/qiskit_aer/backends/unitary_simulator.py b/qiskit_aer/backends/unitary_simulator.py index 069704cfd2..ca28204a9a 100644 --- a/qiskit_aer/backends/unitary_simulator.py +++ b/qiskit_aer/backends/unitary_simulator.py @@ -216,10 +216,9 @@ class UnitarySimulator(AerBackend): "multiplexer", "delay", "pauli", - "reset", ] ), - "custom_instructions": sorted(["save_unitary", "save_state", "set_unitary"]), + "custom_instructions": sorted(["save_unitary", "save_state", "set_unitary", "reset"]), "gates": [], } diff --git a/qiskit_aer/quantum_info/states/aer_statevector.py b/qiskit_aer/quantum_info/states/aer_statevector.py index 350d95bb5e..eac02af221 100644 --- a/qiskit_aer/quantum_info/states/aer_statevector.py +++ b/qiskit_aer/quantum_info/states/aer_statevector.py @@ -258,10 +258,10 @@ def _aer_evolve_instruction(aer_state, inst, qubits, basis_gates=None): aer_state.apply_mcz(qubits[0 : len(qubits) - 1], qubits[len(qubits) - 1]) elif inst.name == "id": pass - elif inst.name == "reset": - aer_state.apply_reset(qubits) else: applied = False + elif inst.name == "reset": + aer_state.apply_reset(qubits) elif inst.name == "kraus": aer_state.apply_kraus(qubits, inst.params) elif inst.name == "barrier": diff --git a/releasenotes/notes/fix_basis_gates-5edf9708e3eec097.yaml b/releasenotes/notes/fix_basis_gates-5edf9708e3eec097.yaml new file mode 100644 index 0000000000..6fa974b2e8 --- /dev/null +++ b/releasenotes/notes/fix_basis_gates-5edf9708e3eec097.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixed basis gates sets of Aer backend, moved `reset` and `switch_case` + to custom instructions. diff --git a/test/terra/backends/aer_simulator/test_noise.py b/test/terra/backends/aer_simulator/test_noise.py index 9255bc8868..5e4a4c579c 100644 --- a/test/terra/backends/aer_simulator/test_noise.py +++ b/test/terra/backends/aer_simulator/test_noise.py @@ -15,6 +15,7 @@ from ddt import ddt from qiskit_aer import noise +import numpy as np import qiskit.quantum_info as qi from qiskit import transpile @@ -69,6 +70,20 @@ def test_readout_noise(self, method, device): self.assertSuccess(result) self.compare_counts(result, [circuit], [target], delta=0.05 * shots) + @supported_methods(ALL_METHODS) + def test_readout_noise_without_basis_gates(self, method, device): + """Test simulation with classical readout error noise model w/o basis gates.""" + backend = self.backend(method=method, device=device) + noise_model = noise.NoiseModel() + noise_model.add_readout_error(np.array([[0.9, 0.1], [0.1, 0.9]]), [0]) + backend.set_options(noise_model=noise_model) + circ = QuantumCircuit(1, 1) + circ.reset(0) + circ.measure(0, 0) + circ = transpile(circ, backend) + result = backend.run(circ, shots=1).result() + self.assertSuccess(result) + @supported_methods(ALL_METHODS) def test_pauli_gate_noise(self, method, device): """Test simulation with Pauli gate error noise model."""