mirror of https://github.com/Qiskit/qiskit-aer.git
Fix basis gates of Aer backends (#1976)
* move reset and switch_case ops to custom istr * Fix reset in AerStatevector * add test case * format * fix installing built Aer in some test cases
This commit is contained in:
parent
85831ee1bf
commit
314c1ff251
|
@ -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:
|
||||
|
|
|
@ -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",
|
||||
]
|
||||
),
|
||||
}
|
||||
|
|
|
@ -109,8 +109,6 @@ BASIS_GATES = {
|
|||
"pauli",
|
||||
"mcx_gray",
|
||||
"ecr",
|
||||
"reset",
|
||||
"switch_case",
|
||||
]
|
||||
),
|
||||
"density_matrix": sorted(
|
||||
|
@ -151,8 +149,6 @@ BASIS_GATES = {
|
|||
"delay",
|
||||
"pauli",
|
||||
"ecr",
|
||||
"reset",
|
||||
"switch_case",
|
||||
]
|
||||
),
|
||||
"matrix_product_state": sorted(
|
||||
|
@ -195,8 +191,6 @@ BASIS_GATES = {
|
|||
"cswap",
|
||||
"diagonal",
|
||||
"initialize",
|
||||
"reset",
|
||||
"switch_case",
|
||||
]
|
||||
),
|
||||
"stabilizer": sorted(
|
||||
|
@ -216,12 +210,10 @@ BASIS_GATES = {
|
|||
"swap",
|
||||
"delay",
|
||||
"pauli",
|
||||
"reset",
|
||||
"ecr",
|
||||
"rx",
|
||||
"ry",
|
||||
"rz",
|
||||
"switch_case",
|
||||
]
|
||||
),
|
||||
"extended_stabilizer": sorted(
|
||||
|
@ -247,7 +239,6 @@ BASIS_GATES = {
|
|||
"ccz",
|
||||
"delay",
|
||||
"pauli",
|
||||
"reset",
|
||||
]
|
||||
),
|
||||
"unitary": sorted(
|
||||
|
@ -309,7 +300,6 @@ BASIS_GATES = {
|
|||
"delay",
|
||||
"pauli",
|
||||
"ecr",
|
||||
"reset",
|
||||
]
|
||||
),
|
||||
"superop": sorted(
|
||||
|
@ -349,7 +339,6 @@ BASIS_GATES = {
|
|||
"diagonal",
|
||||
"delay",
|
||||
"pauli",
|
||||
"reset",
|
||||
]
|
||||
),
|
||||
"tensor_network": sorted(
|
||||
|
@ -412,7 +401,6 @@ BASIS_GATES = {
|
|||
"delay",
|
||||
"pauli",
|
||||
"mcx_gray",
|
||||
"reset",
|
||||
]
|
||||
),
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
@ -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": [],
|
||||
|
|
|
@ -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": [],
|
||||
}
|
||||
|
||||
|
|
|
@ -258,10 +258,10 @@ class AerStatevector(Statevector):
|
|||
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":
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixed basis gates sets of Aer backend, moved `reset` and `switch_case`
|
||||
to custom instructions.
|
|
@ -15,6 +15,7 @@ AerSimulator Integration Tests
|
|||
|
||||
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 @@ class TestNoise(SimulatorTestCase):
|
|||
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."""
|
||||
|
|
Loading…
Reference in New Issue