Skip to content

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
This commit updates tests which started to fail because of the different
RNG behavior used by the parallel SabreSwap seed trials. For the most
part these are just mechanical changes that either changed the expected
layout with a fixed seed or updating a fixed seed so the output matches
the expected result. The one interesting case was the
TestTranspileLevelsSwap change which was caused by different swaps being
inserted that for optimization level enabled the 2q block optimization
passes to synthesize away the swap as part of its optimization. This was
fixed by changing the seed, but it was a different case than the other
failures.
  • Loading branch information
mtreinish committed Aug 22, 2022
1 parent 21c4c2d commit 90d52cc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion test/python/transpiler/test_mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class TestsSabreSwap(SwapperCommonTestCases, QiskitTestCase):
"""Test SwapperCommonTestCases using SabreSwap."""

pass_class = SabreSwap
additional_args = {"seed": 4242}
additional_args = {"seed": 1242}


if __name__ == "__main__":
Expand Down
30 changes: 15 additions & 15 deletions test/python/transpiler/test_preset_passmanagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,25 +698,25 @@ def test_layout_tokyo_fully_connected_cx(self, level):
}

sabre_layout = {
6: qr[0],
11: qr[1],
10: qr[2],
5: qr[3],
16: qr[4],
11: qr[0],
17: qr[1],
16: qr[2],
6: qr[3],
18: qr[4],
0: ancilla[0],
1: ancilla[1],
2: ancilla[2],
3: ancilla[3],
4: ancilla[4],
7: ancilla[5],
8: ancilla[6],
9: ancilla[7],
12: ancilla[8],
13: ancilla[9],
14: ancilla[10],
15: ancilla[11],
17: ancilla[12],
18: ancilla[13],
5: ancilla[5],
7: ancilla[6],
8: ancilla[7],
9: ancilla[8],
10: ancilla[9],
12: ancilla[10],
13: ancilla[11],
14: ancilla[12],
15: ancilla[13],
19: ancilla[14],
}

Expand Down Expand Up @@ -913,7 +913,7 @@ def test_2(self, level):
optimization_level=level,
basis_gates=basis,
coupling_map=coupling_map,
seed_transpiler=42,
seed_transpiler=42123,
)
self.assertIsInstance(result, QuantumCircuit)
resulting_basis = {node.name for node in circuit_to_dag(result).op_nodes()}
Expand Down
18 changes: 9 additions & 9 deletions test/python/transpiler/test_sabre_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def test_5q_circuit_20q_coupling(self):
pass_.run(dag)

layout = pass_.property_set["layout"]
self.assertEqual(layout[qr[0]], 11)
self.assertEqual(layout[qr[1]], 6)
self.assertEqual(layout[qr[2]], 12)
self.assertEqual(layout[qr[3]], 5)
self.assertEqual(layout[qr[0]], 10)
self.assertEqual(layout[qr[1]], 12)
self.assertEqual(layout[qr[2]], 7)
self.assertEqual(layout[qr[3]], 11)
self.assertEqual(layout[qr[4]], 13)

def test_6q_circuit_20q_coupling(self):
Expand Down Expand Up @@ -92,12 +92,12 @@ def test_6q_circuit_20q_coupling(self):
pass_.run(dag)

layout = pass_.property_set["layout"]
self.assertEqual(layout[qr0[0]], 8)
self.assertEqual(layout[qr0[1]], 2)
self.assertEqual(layout[qr0[0]], 2)
self.assertEqual(layout[qr0[1]], 3)
self.assertEqual(layout[qr0[2]], 10)
self.assertEqual(layout[qr1[0]], 3)
self.assertEqual(layout[qr1[1]], 12)
self.assertEqual(layout[qr1[2]], 11)
self.assertEqual(layout[qr1[0]], 1)
self.assertEqual(layout[qr1[1]], 7)
self.assertEqual(layout[qr1[2]], 5)


if __name__ == "__main__":
Expand Down

0 comments on commit 90d52cc

Please sign in to comment.