-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sabre swap mapper dominated by data copy #5197
Comments
It actually depends on how large you scale things. For ~100 qubits or more it's typically calls to |
Humm BFS should be linear runtime if done right. Also the distance calculation should probably be done only for those qubits which actually need evaluating at some point; most distances are not usually needed and a dense million+ element array is getting a bit hefty. |
IIRC, the bfs_successors one was because of a retworkx limitation right now it computes the entire list of nodes and then returns that as a python list (there is an issue open on this Qiskit/rustworkx#71 but its blocked on the python binding lib) which for modest sized graphs is still an order of magnitude faster, but as the graph grows sufficiently large it can become a bottleneck. Looking at the sabre code: it is designed with an iterator like networkx returns. But, with retworkx it's spending an excessive amount of time waiting for the full list to be generate over many calls to As for the |
Yes, this would be good. Also another reason to avoid going to the faulty qubits model in Qiskit. This should be possible already I think.
The ability to give the parallel cutoff heuristic that you have there is also quite cool. The |
Previously, the CouplingMap.distance() method was checking whether the qubit number was in the coupling graph by searching over a list for the coupling map indices. This search becomes a bottleneck at large qubit numbers because in the worst case it has to traverse the entire list to find a match. This also is unecessary because the coupling map indices are always an ordered range from 0 to n for n qubits. This commit fixes this bottleneck by updating the check to just error if the index is out of bounds for the size of the graph. Related to Qiskit#5197
For and after that commit it becomes: it basically eliminates |
This commit changes the deepcopy usage in the sabreswap pass to a shallow copy. In sabre_swap the deepcopy was run on the DAGCircuit node when remapping it, however this was not necessary because it's not actually used where shared references matter. The output from the remapper is not used directly and instead a copy of the DAGNode object is just used as a container for the required args in apply_operation_back() where a new DAGNode is always created from the op, qargs, etc. The remapping just replaces the qargs parameter with the remapped one. So this commit changes the deepcopy to a shallow copy which won't have the performance overhead. Fixes Qiskit#5197
I pushed up #5316 which is tagged as fixing this issue. I did that because it fixes the copy bottleneck for small numbers of qubits outlined in this issue. But even with that there are still significant bottlenecks with sabre_swap especially as things scale up. I've started to address those in #5294, #5183, Qiskit/rustworkx#185 I'll need to evaluate where things are after all of those are applied and see where things are. But I'll open up a separate issue for that |
This commit changes the deepcopy usage in the sabreswap pass to a shallow copy. In sabre_swap the deepcopy was run on the DAGCircuit node when remapping it, however this was not necessary because it's not actually used where shared references matter. The output from the remapper is not used directly and instead a copy of the DAGNode object is just used as a container for the required args in apply_operation_back() where a new DAGNode is always created from the op, qargs, etc. The remapping just replaces the qargs parameter with the remapped one. So this commit changes the deepcopy to a shallow copy which won't have the performance overhead. Fixes #5197 Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit changes the deepcopy usage in the sabreswap pass to a shallow copy. In sabre_swap the deepcopy was run on the DAGCircuit node when remapping it, however this was not necessary because it's not actually used where shared references matter. The output from the remapper is not used directly and instead a copy of the DAGNode object is just used as a container for the required args in apply_operation_back() where a new DAGNode is always created from the op, qargs, etc. The remapping just replaces the qargs parameter with the remapped one. So this commit changes the deepcopy to a shallow copy which won't have the performance overhead. Fixes #5197 Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit a506ba9)
This commit changes the deepcopy usage in the sabreswap pass to a shallow copy. In sabre_swap the deepcopy was run on the DAGCircuit node when remapping it, however this was not necessary because it's not actually used where shared references matter. The output from the remapper is not used directly and instead a copy of the DAGNode object is just used as a container for the required args in apply_operation_back() where a new DAGNode is always created from the op, qargs, etc. The remapping just replaces the qargs parameter with the remapped one. So this commit changes the deepcopy to a shallow copy which won't have the performance overhead. Fixes #5197 Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit a506ba9) Co-authored-by: Matthew Treinish <[email protected]> Co-authored-by: Luciano Bello <[email protected]>
* Remove list searches in CouplingMap.distance() Previously, the CouplingMap.distance() method was checking whether the qubit number was in the coupling graph by searching over a list for the coupling map indices. This search becomes a bottleneck at large qubit numbers because in the worst case it has to traverse the entire list to find a match. This also is unecessary because the coupling map indices are always an ordered range from 0 to n for n qubits. This commit fixes this bottleneck by updating the check to just error if the index is out of bounds for the size of the graph. Related to #5197 * Cache size instead of calling each time * Fix lint Co-authored-by: Luciano Bello <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Kevin Krsulich <[email protected]>
Information
What is the current behavior?
Running Sabre on a QV circuit over 20 qubits shows that data copying is the current bottleneck:
Abbreviated profile:
Steps to reproduce the problem
What is the expected behavior?
Suggested solutions
The text was updated successfully, but these errors were encountered: