From 6fa7ae29d01f98b0e2198db03b61dac7df58ea9a Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 10 Jan 2023 22:47:01 -0500 Subject: [PATCH] Simplify UnitarySynthesis pass test test_qv_natural (#9359) * Simplify UnitarySynthesis pass test test_qv_natural The test_qv_natural UnitarySynthesis test is designed to test that when the pulse efficient flag is set on the default unitary synthesis plugin for the UnitarySynthesis pass the output from synthesis is only emitting entangling gates in the natural direction implemented on the target. However, when running on Windows with Python 3.11 and numpy 1.24 we're seeing a non-zero failure rate (in CI it's ~5% across all jobs) of this test likely do to fp precision. When this failure occurs it appears as the failure from detailed in issues #5832 and #9177 as the test was creating a pass manager that mirrors the optimization loop used in the preset pass managers. The optimization loop is failing to converge on a fixed depth as the unitary synthesis is oscillating between multiple equivalent outputs. However, in this case the test doesn't need the full complexity of the optimization loop as we're just trying to verify the output of unitary synthesis is equivalent with different options and that the output is valid given different options. This can be done with a single iteration of the loop and doesn't require trying to fully optimize the circuit. This commit reduces the complexity of the test to remove the loop from the optimization stage in the custom pass manager so the test is now just running a single iteration of UnitarySynthesis and comparing the output. This will hopefully make the test stable in CI moving forward avoiding this failure mode. * Retrigger CI Co-authored-by: Jake Lishman --- test/python/transpiler/test_unitary_synthesis.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/test/python/transpiler/test_unitary_synthesis.py b/test/python/transpiler/test_unitary_synthesis.py index 89af400e63cb..a2877ce8d9cb 100644 --- a/test/python/transpiler/test_unitary_synthesis.py +++ b/test/python/transpiler/test_unitary_synthesis.py @@ -40,8 +40,6 @@ ConsolidateBlocks, Optimize1qGates, SabreLayout, - Depth, - FixedPoint, Unroll3qOrMore, CheckMap, BarrierBeforeFinalMeasurements, @@ -478,9 +476,6 @@ def test_qv_natural(self): qv64 = QuantumVolume(5, seed=15) def construct_passmanager(basis_gates, coupling_map, synthesis_fidelity, pulse_optimize): - def _repeat_condition(property_set): - return not property_set["depth_fixed_point"] - seed = 2 _map = [SabreLayout(coupling_map, max_iterations=2, seed=seed)] _unroll3q = Unroll3qOrMore() @@ -489,7 +484,6 @@ def _repeat_condition(property_set): BarrierBeforeFinalMeasurements(), SabreSwap(coupling_map, heuristic="lookahead", seed=seed), ] - _check_depth = [Depth(), FixedPoint("depth")] _optimize = [ Collect2qBlocks(), ConsolidateBlocks(basis_gates=basis_gates), @@ -508,9 +502,7 @@ def _repeat_condition(property_set): pm.append(_unroll3q) pm.append(_swap_check) pm.append(_swap) - pm.append( - _check_depth + _optimize, do_while=_repeat_condition - ) # translate to & optimize over hardware native gates + pm.append(_optimize) return pm coupling_map = CouplingMap([[0, 1], [1, 2], [3, 2], [3, 4], [5, 4]])