From d171a24764c31d22aff2925597f4c3fa48990747 Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Wed, 14 Aug 2024 17:23:48 +0900 Subject: [PATCH] remove transpile when unitary gates are in circuits --- test/terra/backends/aer_simulator/test_unitary_gate.py | 6 +----- .../aer_simulator/test_wrapper_statevector_simulator.py | 7 ------- .../aer_simulator/test_wrapper_unitary_simulator.py | 3 --- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/test/terra/backends/aer_simulator/test_unitary_gate.py b/test/terra/backends/aer_simulator/test_unitary_gate.py index 9e92410ae4..4e67b8d470 100644 --- a/test/terra/backends/aer_simulator/test_unitary_gate.py +++ b/test/terra/backends/aer_simulator/test_unitary_gate.py @@ -47,7 +47,6 @@ def test_unitary_gate(self, method, device): shots = 100 circuits = ref_unitary_gate.unitary_gate_circuits_deterministic(final_measure=True) targets = ref_unitary_gate.unitary_gate_counts_deterministic(shots) - circuits = transpile(circuits, backend) result = backend.run(circuits, shots=shots).result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0) @@ -61,7 +60,6 @@ def test_random_unitary_gate(self, method, device): final_measure=True ) targets = ref_unitary_gate.unitary_random_gate_counts_nondeterministic(shots) - circuits = transpile(circuits, backend) result = backend.run(circuits, shots=shots).result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots) @@ -78,8 +76,7 @@ def test_random_unitary_gate_with_permutations(self, method, device, perm): circuit.unitary(unitary_matrix, perm) circuit.barrier(range(n)) circuit.measure(range(n), range(n)) - circuits = transpile(circuit, backend) - result = backend.run(circuits, shots=shots).result() + result = backend.run(circuit, shots=shots).result() state = Statevector.from_label(n * "0").evolve(unitary_matrix, perm) state.seed(11111) @@ -99,7 +96,6 @@ def test_diagonal_gate(self, method, device): shots = 100 circuits = ref_diagonal_gate.diagonal_gate_circuits_deterministic(final_measure=True) targets = ref_diagonal_gate.diagonal_gate_counts_deterministic(shots) - circuits = transpile(circuits, backend) result = backend.run(circuits, shots=shots).result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0) diff --git a/test/terra/backends/aer_simulator/test_wrapper_statevector_simulator.py b/test/terra/backends/aer_simulator/test_wrapper_statevector_simulator.py index 48f6eb29ef..c3f60d50ab 100644 --- a/test/terra/backends/aer_simulator/test_wrapper_statevector_simulator.py +++ b/test/terra/backends/aer_simulator/test_wrapper_statevector_simulator.py @@ -123,7 +123,6 @@ def test_conditional_unitary_1bit(self, device): circuits = ref_conditionals.conditional_circuits_1bit( final_measure=False, conditional_type="unitary" ) - circuits = transpile(circuits, backend, optimization_level=1) result = backend.run(circuits, shots=1).result() targets = ref_conditionals.conditional_statevector_1bit() self.assertSuccess(result) @@ -147,7 +146,6 @@ def test_conditional_unitary_2bit(self, device): circuits = ref_conditionals.conditional_circuits_2bit( final_measure=False, conditional_type="unitary" ) - circuits = transpile(circuits, backend, optimization_level=1) result = backend.run(circuits, shots=1).result() targets = ref_conditionals.conditional_statevector_2bit() self.assertSuccess(result) @@ -175,7 +173,6 @@ def test_conditional_unitary_64bit(self, device): circuits = ref_conditionals.conditional_circuits_nbit( 64, cases, final_measure=False, conditional_type="unitary" ) - circuits = transpile(circuits, backend, optimization_level=1) result = backend.run(circuits, shots=1).result() targets = ref_conditionals.conditional_statevector_nbit(cases) self.assertSuccess(result) @@ -203,7 +200,6 @@ def test_conditional_unitary_132bit(self, device): circuits = ref_conditionals.conditional_circuits_nbit( 132, cases, final_measure=False, conditional_type="unitary" ) - circuits = transpile(circuits, backend, optimization_level=1) result = backend.run(circuits, shots=1).result() targets = ref_conditionals.conditional_statevector_nbit(cases) self.assertSuccess(result) @@ -217,7 +213,6 @@ def test_unitary_gate(self, device): """Test simulation with unitary gate circuit instructions.""" backend = self.backend(device=device) circuits = ref_unitary_gate.unitary_gate_circuits_deterministic(final_measure=False) - circuits = transpile(circuits, backend, optimization_level=1) result = backend.run(circuits, shots=1).result() targets = ref_unitary_gate.unitary_gate_statevector_deterministic() self.assertSuccess(result) @@ -228,7 +223,6 @@ def test_unitary_gate_circuit_run(self, device): """Test simulation with unitary gate circuit instructions.""" backend = self.backend(device=device) circuits = ref_unitary_gate.unitary_gate_circuits_deterministic(final_measure=False) - circuits = transpile(circuits, backend, optimization_level=1) result = backend.run(circuits, shots=1).result() targets = ref_unitary_gate.unitary_gate_statevector_deterministic() self.assertSuccess(result) @@ -239,7 +233,6 @@ def test_diagonal_gate(self, device): """Test simulation with diagonal gate circuit instructions.""" backend = self.backend(device=device) circuits = ref_diagonal_gate.diagonal_gate_circuits_deterministic(final_measure=False) - circuits = transpile(circuits, backend, optimization_level=1) result = backend.run(circuits, shots=1).result() targets = ref_diagonal_gate.diagonal_gate_statevector_deterministic() self.assertSuccess(result) diff --git a/test/terra/backends/aer_simulator/test_wrapper_unitary_simulator.py b/test/terra/backends/aer_simulator/test_wrapper_unitary_simulator.py index c3100d45b8..6a2f8bac7b 100644 --- a/test/terra/backends/aer_simulator/test_wrapper_unitary_simulator.py +++ b/test/terra/backends/aer_simulator/test_wrapper_unitary_simulator.py @@ -39,7 +39,6 @@ def test_unitary_gate(self, device): """Test simulation with unitary gate circuit instructions.""" backend = self.backend(device=device) circuits = ref_unitary_gate.unitary_gate_circuits_deterministic(final_measure=False) - circuits = transpile(circuits, backend, optimization_level=1) result = backend.run(circuits, shots=1).result() targets = ref_unitary_gate.unitary_gate_unitary_deterministic() self.assertSuccess(result) @@ -50,7 +49,6 @@ def test_unitary_gate_circuit_run(self, device): """Test simulation with unitary gate circuit instructions.""" backend = self.backend(device=device) circuits = ref_unitary_gate.unitary_gate_circuits_deterministic(final_measure=False) - circuits = transpile(circuits, backend, optimization_level=1) result = backend.run(circuits, shots=1).result() targets = ref_unitary_gate.unitary_gate_unitary_deterministic() self.assertSuccess(result) @@ -61,7 +59,6 @@ def test_diagonal_gate(self, device): """Test simulation with diagonal gate circuit instructions.""" backend = self.backend(device=device) circuits = ref_diagonal_gate.diagonal_gate_circuits_deterministic(final_measure=False) - circuits = transpile(circuits, backend, optimization_level=1) result = backend.run(circuits, shots=1).result() targets = ref_diagonal_gate.diagonal_gate_unitary_deterministic() self.assertSuccess(result)