Skip to content

Commit

Permalink
Simplify UnitarySynthesis pass test test_qv_natural (#9359)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
mtreinish and jakelishman authored Jan 11, 2023
1 parent 67a8937 commit 6fa7ae2
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions test/python/transpiler/test_unitary_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
ConsolidateBlocks,
Optimize1qGates,
SabreLayout,
Depth,
FixedPoint,
Unroll3qOrMore,
CheckMap,
BarrierBeforeFinalMeasurements,
Expand Down Expand Up @@ -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()
Expand All @@ -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),
Expand All @@ -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]])
Expand Down

0 comments on commit 6fa7ae2

Please sign in to comment.