Fix controlled gate decomposition test on certain machines #7112
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.
When decomposing
CCCCCX
and such large multi-controlled gates, intermediateMatrixGates
get created (notably not controlledMatrixGates
, which would be problematic; just top-levelMatrixGates
as part of the decomposition). These then get further decomposed to a different set of gates.On some systems, due to rounding error, they get decomposed to a different set of gates that usual, which are equivalent but have different global phase than the standard decomposition. Again, these are top-level
MatrixGates
, not controlled ones, so its "okay" that their decompositions have different global phase. However, the test tested fornp.allclose
, and this test would fail on such systems. This PR changes the test tocirq.equal_up_to_global_phase
, which should fix the tests on those systems.xref #7071 (comment)
Also adding back some test parameters I'd removed earlier because they were failing on Windows, and I'd assumed it was due to general rounding error; it didn't occur to me that it could be a phase difference. Let's see if the change allows them to pass.