swap_cancellation pass#5902
Conversation
kdk
left a comment
There was a problem hiding this comment.
Is it possible to instead generalize the CXCancellation pass to handle other self-inverse gates? Ideally, this could be stored as a property of the Gate classes in the standard library, but even for the short term, the pass could hold a hard-coded list of self-inverse gates. What do you think?
| Returns: | ||
| DAGCircuit: Transformed DAG. | ||
| """ | ||
| swap_runs = dag.collect_runs(["swap"]) |
There was a problem hiding this comment.
Does this actually work as expected? The collect_runs method was mostly for 1q gates I don't think we have any tests of using it with >1q gates. Looking at the rustworkx code for the function (https://github.com/Qiskit/rustworkx/blob/main/src/dag_algo/mod.rs#L460-L506 ) it should work I think, but having a testing with partially overlapping swaps (eg, swap(0,1) -> swap(1, 2) -> swap (2, 0)) to make sure the behavior is sound
|
I believe this PR is superseded by the extra work in |
As part of preserving unitary during transpilation, some swap gates are inserted with #5280.
These swaps might be adjacent to swap gates introduced by the routing passes. Pairs of swaps can be cancelled as pairs of cnots.
This pass is a copy of the
cx_cancellationpass, but for swap gates.