Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve efficiency of CouplingMap.make_symmetric
Right now the CouplingMap.make_symmetric has a quadratic overhead. It was iterating over a list of each edgess' endpoints in the graph and for each edge it was iterating over the same list again to check whether the reverse edge is present or not. The overhead for this for large coupling maps can be quite large, for example with a 10497 qubit heavy hex coupling map the time it took to run this method as part of SabreLayout's initialization was 10x slower than actually running the pass (a equally sized Bernstein-Vazirani circuit). Instead of doing an O(n) contains check inside the loop this commit updates it to use a set which will be an O(1) lookup. This should address the performance issue with this method. In the future we should leverage the native rustworkx method to do this, which is being added in: Qiskit/rustworkx#814
- Loading branch information