Skip to content

Commit

Permalink
remove transpile when unitary gates are in circuits
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj committed Aug 14, 2024
1 parent a571487 commit d171a24
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 15 deletions.
6 changes: 1 addition & 5 deletions test/terra/backends/aer_simulator/test_unitary_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit d171a24

Please sign in to comment.