-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Avoid routing 2q barriers in SabreSwap #11295
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
Conversation
This commit fixes an oversight in the sabre swap pass where a 2 qubit barrier would have been treated like a 2 qubit gate and swaps could potentially be inserted if the sabre algorithm thought it didn't have connectivity for the qargs to the barrier. However as barrier is just a compiler directive it is valid on all qubit pairs so this swap insertion was unnecessary, it was still valid but just not an optimal output. This commit fixes it by adding context to the sabre dag around whether a given node is a directive (and valid on all qubits) or not.
One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 6962479250
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you also need to update extended set population to ignore directives:
if required_predecessors[successor_index] == 0 {
if !dag.dag[node].directive && !dag.node_blocks.contains_key(&successor_index) {
if let [a, b] = dag.dag[successor_node].qubits[..] {
extended_set.push([a.to_phys(layout), b.to_phys(layout)]);
}
}
to_visit.push(successor_node);
}
Otherwise, this looks good!
Co-authored-by: Kevin Hartman <kevin@hart.mn>
Done in: 89da56e |
This commit updates a layout in the: `TestSabreLayout.test_layout_many_search_trials` test case which was recently changed in Qiskit#10323. The change in test ouput caused by Qiskit#10323 is what triggered the investigation into this bugfix and now that barriers are being treated correctly by sabre the layout doesn't change in the test case anymore and this is reverting the test assertion to use the original layout before Qiskit#10323 was merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the updates!
* Avoid routing 2q barriers in SabreSwap This commit fixes an oversight in the sabre swap pass where a 2 qubit barrier would have been treated like a 2 qubit gate and swaps could potentially be inserted if the sabre algorithm thought it didn't have connectivity for the qargs to the barrier. However as barrier is just a compiler directive it is valid on all qubit pairs so this swap insertion was unnecessary, it was still valid but just not an optimal output. This commit fixes it by adding context to the sabre dag around whether a given node is a directive (and valid on all qubits) or not. * Update rust tests too * Skip directives in extended set generation too Co-authored-by: Kevin Hartman <kevin@hart.mn> * Add release note * Update test layout in test_layout_many_search_trials This commit updates a layout in the: `TestSabreLayout.test_layout_many_search_trials` test case which was recently changed in Qiskit#10323. The change in test ouput caused by Qiskit#10323 is what triggered the investigation into this bugfix and now that barriers are being treated correctly by sabre the layout doesn't change in the test case anymore and this is reverting the test assertion to use the original layout before Qiskit#10323 was merged. --------- Co-authored-by: Kevin Hartman <kevin@hart.mn>
* Avoid routing 2q barriers in SabreSwap This commit fixes an oversight in the sabre swap pass where a 2 qubit barrier would have been treated like a 2 qubit gate and swaps could potentially be inserted if the sabre algorithm thought it didn't have connectivity for the qargs to the barrier. However as barrier is just a compiler directive it is valid on all qubit pairs so this swap insertion was unnecessary, it was still valid but just not an optimal output. This commit fixes it by adding context to the sabre dag around whether a given node is a directive (and valid on all qubits) or not. * Update rust tests too * Skip directives in extended set generation too Co-authored-by: Kevin Hartman <kevin@hart.mn> * Add release note * Update test layout in test_layout_many_search_trials This commit updates a layout in the: `TestSabreLayout.test_layout_many_search_trials` test case which was recently changed in Qiskit#10323. The change in test ouput caused by Qiskit#10323 is what triggered the investigation into this bugfix and now that barriers are being treated correctly by sabre the layout doesn't change in the test case anymore and this is reverting the test assertion to use the original layout before Qiskit#10323 was merged. --------- Co-authored-by: Kevin Hartman <kevin@hart.mn>
Summary
This commit fixes an oversight in the sabre swap pass where a 2 qubit barrier would have been treated like a 2 qubit gate and swaps could potentially be inserted if the sabre algorithm thought it didn't have connectivity for the qargs to the barrier. However as barrier is just a compiler directive it is valid on all qubit pairs so this swap insertion was unnecessary, it was still valid but just not an optimal output. This commit fixes it by adding context to the sabre dag around whether a given node is a directive (and valid on all qubits) or not.
Details and comments