Skip to content

Commit

Permalink
Add test to test we skip after layout
Browse files Browse the repository at this point in the history
  • Loading branch information
mtreinish committed May 1, 2024
1 parent e270aa8 commit f5b6778
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions test/python/transpiler/test_elide_permutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,27 @@ class TestElidePermutationsInTranspileFlow(QiskitTestCase):
as to preserve unitary equivalence.
"""

# ToDo: update the tests when ElidePermutations is merged into transpiler flow.
def test_not_run_after_layout(self):
"""Test ElidePermutations doesn't do anything after layout."""
qc = QuantumCircuit(3)
qc.h(0)
qc.swap(0, 2)
qc.cx(0, 1)
qc.swap(1, 0)
qc.h(1)

spm = generate_preset_pass_manager(
optimization_level=3, initial_layout=list(range(2, -1, -1)), seed_transpiler=42
)
spm.layout += ElidePermutations()
spm.post_optimization = PassManager([FinalizeLayouts()])
res = spm.run(qc)
self.assertTrue(Operator.from_circuit(res).equiv(Operator(qc)))
self.assertIn("swap", res.count_ops())
self.assertTrue(res.layout.final_index_layout(), [0, 1, 2])

def test_unitary_equivalence(self):
"""Test unitary equivalence of the original and transpiled circuits."""

qc = QuantumCircuit(3)
qc.h(0)
qc.swap(0, 2)
Expand Down

0 comments on commit f5b6778

Please sign in to comment.