Skip to content

Commit

Permalink
modify test cases use auto method result may change by this PR
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj committed Nov 8, 2023
1 parent 77d5fa8 commit d6d3aec
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
30 changes: 23 additions & 7 deletions test/terra/backends/aer_simulator/test_auto_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TestSimulationMethod(SimulatorTestCase):
# ---------------------------------------------------------------------

def test_auto_method_clifford_circuits(self):
"""Test statevector method is used for Clifford circuit"""
"""Test stabilizer method is used for Clifford circuit"""
# Test circuits
backend = self.backend()
shots = 100
Expand All @@ -59,7 +59,7 @@ def test_auto_method_clifford_circuits(self):
self.compare_result_metadata(result, circuits, "method", "stabilizer")

def test_auto_method_clifford_circuits_and_reset_noise(self):
"""Test statevector method is used for Clifford circuit"""
"""Test stabilizer method is used for Clifford circuit"""
# Test noise model
noise_circs = [Reset(), IGate()]
noise_probs = [0.5, 0.5]
Expand All @@ -69,31 +69,47 @@ def test_auto_method_clifford_circuits_and_reset_noise(self):
backend = self.backend(noise_model=noise_model)

# Test circuits
shots = 100
shots = 4
circuits = ref_2q_clifford.cz_gate_circuits_deterministic(final_measure=True)
result = backend.run(circuits, shots=shots).result()
success = getattr(result, "success", False)
self.assertTrue(success)
self.compare_result_metadata(result, circuits, "method", "stabilizer")

def test_auto_method_clifford_circuits_and_pauli_noise(self):
"""Test statevector method is used for Clifford circuit"""
"""Test stabilizer method is used for Clifford circuit"""
# Noise Model
error = pauli_error([["XX", 0.5], ["II", 0.5]])
noise_model = NoiseModel()
noise_model.add_all_qubit_quantum_error(error, ["cz", "cx"])
backend = self.backend(noise_model=noise_model)

# Test circuits
shots = 100
shots = 4
circuits = ref_2q_clifford.cz_gate_circuits_deterministic(final_measure=True)
result = backend.run(circuits, shots=shots).result()
success = getattr(result, "success", False)
self.assertTrue(success)
self.compare_result_metadata(result, circuits, "method", "stabilizer")

def test_auto_method_clifford_circuits_and_pauli_noise_with_many_shots(self):
"""Test density_matrix method is used for Clifford circuit"""
# Noise Model
error = pauli_error([["XX", 0.5], ["II", 0.5]])
noise_model = NoiseModel()
noise_model.add_all_qubit_quantum_error(error, ["cz", "cx"])
backend = self.backend(noise_model=noise_model)

# Test circuits
shots = 1000
circuits = ref_2q_clifford.cz_gate_circuits_deterministic(final_measure=True)
result = backend.run(circuits, shots=shots).result()
success = getattr(result, "success", False)
self.assertTrue(success)
self.compare_result_metadata(result, circuits, "method", "density_matrix")

def test_auto_method_clifford_circuits_and_unitary_noise(self):
"""Test statevector method is used for Clifford circuit"""
"""Test density_matrix method is used for Clifford circuit"""
# Noise Model
error = mixed_unitary_error(
[(Pauli("XX").to_matrix(), 0.5), (Pauli("II").to_matrix(), 0.5)]
Expand All @@ -110,7 +126,7 @@ def test_auto_method_clifford_circuits_and_unitary_noise(self):
self.compare_result_metadata(result, circuits, "method", "density_matrix")

def test_auto_method_clifford_circuits_and_kraus_noise(self):
"""Test statevector method is used for Clifford circuit"""
"""Test density_matrix method is used for Clifford circuit"""
# Noise Model
error = amplitude_damping_error(0.5)
noise_model = NoiseModel()
Expand Down
13 changes: 10 additions & 3 deletions test/terra/backends/aer_simulator/test_thread_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ def test_parallel_defaults_single_ideal(self):
def test_parallel_defaults_single_noise(self):
"""Test parallel thread assignment defaults"""
backend = self.backend(
noise_model=self.dummy_noise_model(), **self.backend_options_parallel()
method="statevector",
noise_model=self.dummy_noise_model(),
**self.backend_options_parallel(),
)
max_threads = self.available_threads()

Expand Down Expand Up @@ -209,7 +211,9 @@ def test_parallel_defaults_multi_ideal(self):
def test_parallel_defaults_multi_noise(self):
"""Test parallel thread assignment defaults"""
backend = self.backend(
noise_model=self.dummy_noise_model(), **self.backend_options_parallel()
method="statevector",
noise_model=self.dummy_noise_model(),
**self.backend_options_parallel(),
)
max_threads = self.available_threads()

Expand Down Expand Up @@ -295,7 +299,9 @@ def test_parallel_thread_assignment(self, custom_max_threads):
# Test single circuit, with noise
# Parallel experiments should always be 1
# parallel shots should be greater than 1
backend = self.backend(noise_model=self.dummy_noise_model(), **parallel_opts)
backend = self.backend(
method="statevector", noise_model=self.dummy_noise_model(), **parallel_opts
)
circuits = self.dummy_circuit(1)
result = backend.run(circuits, shots=shots).result()
for threads in self.threads_used(result):
Expand Down Expand Up @@ -531,6 +537,7 @@ def test_parallel_shot_thread_multi_noise(self):

max_threads = self.available_threads()
backend = self.backend(
method="statevector",
noise_model=self.dummy_noise_model(),
**self.backend_options_parallel(shot_threads=max_threads),
)
Expand Down

0 comments on commit d6d3aec

Please sign in to comment.