Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #6848
Summary
Tames an overly active warning which is triggered during synthesis-based 1Q simplification.
Details and comments
In #6553, we added a warning in
Optimize1qGatesDecomposition.__call__
which was meant to check that gate sequences emitted by an operator-based 1Q synthesis routine were always more efficient (i.e., shorter) than the sequence used to form the input. The idea was that this would warn us if a synthesis routine were ever to emit a sequence which is not maximally efficient.We made a mistake in the definition of 'maximally efficient'. In general, a synthesis routine promises to emit gates whose types form a subset of some larger set of native gates, and it cannot make guarantees (nor be expected to make guarantees) about optimality of its circuits within the larger set, but only within the smaller set. For instance, PSX decomposition emits
p(pi/2) ; sx ; p(pi/2)
as a circuit embodyingh
. Its output["p", "sx"]
conforms to the set of native gates["p", "sx", "h"]
and the emitted circuit is depth-optimal within["p", "sx"]
, but it is not depth-optimal within the larger set — a loneh
is shorter.I don't believe it's possible to reason about optimality over unions of synthesis targets. So, instead, this PR modifies the predicate which guards the warning about increased depth, specializing it to each synthesis routine. In order to do this specialization, we have to remember which routines target which sets of output, and this is the primary source of diff size. (In retrospect, it might have been preferable to use the
.basis
slot, rather than retaining the information locally...)(This isn't exactly a bug — a gnat, at worst — so I've elected not to mention it in the change log.)