Correctly handle target with global 1q or 3q gates in Sabre#14715
Conversation
The recently merged Qiskit#14317 the sabre passes were updated to build a coupling graph from a target in Rust as part of moving all the passes' logic into rust. There was a small oversight in the construction of the coupling graph when handling targets that contain globally defined operations. Previously, the constructed connectivity graph would treat the presence of any globally defined operation in the target as meaning the target had all to all connectivity which isn't always the case. If the globally defined gate is a 1q operation there could still be a connectivity graph. Similarly in the presence of > 2q gates in the target the python version didn't invalidate the construction of a connectivity graph unless there were no 2q operations. Instead the connectivity graph was ignoring the multiqubit operations. This commit updates the logic to match what is done in the Python space `Target.build_coupling_map()`.
|
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 16972786837Details
💛 - Coveralls |
jakelishman
left a comment
There was a problem hiding this comment.
Is there a path to testing the multi-q handling, whatever we choose to do with it?
We can very easily add a test that has a toffoli in the target on a circuit that needs swaps. That'll validate whatever we need. I didn't have any tests because I viewed this as restoring the previous behavior and not really changing anything. The multi-q gate in the target case is sufficiently uncommon and poorly supported I wasn't as worried about it as much as the 1q global case which was blocking my testing from C. |
jakelishman
left a comment
There was a problem hiding this comment.
Thanks - I'm fine with this, but just to check: does the new form, with Sabre still rejecting the MultiQ case, still satisfy everything you were after?
Feel free to add to the queue if so.
|
All I really cared about in this PR was fixing the global gates thing because it's blocking #14711 . I think this is technically a breaking api change though now that you mention it. For example with 2.1.x if you did: transpiled to: You'd get: but with sabre on main it would error right? |
|
Yeah, I suppose in this particular case with concrete I think we could merge this (and #14605) as-is now, and later add additional logic to Sabre such that |
|
Yeah that sounds like a fair plan as long as we remember to do the last piece, I'll open an issue from your comment and track it as a bugfix for 2.2.0 |
…4715) * Correctly handle target with global 1q or 3q gates in Sabre The recently merged Qiskit#14317 the sabre passes were updated to build a coupling graph from a target in Rust as part of moving all the passes' logic into rust. There was a small oversight in the construction of the coupling graph when handling targets that contain globally defined operations. Previously, the constructed connectivity graph would treat the presence of any globally defined operation in the target as meaning the target had all to all connectivity which isn't always the case. If the globally defined gate is a 1q operation there could still be a connectivity graph. Similarly in the presence of > 2q gates in the target the python version didn't invalidate the construction of a connectivity graph unless there were no 2q operations. Instead the connectivity graph was ignoring the multiqubit operations. This commit updates the logic to match what is done in the Python space `Target.build_coupling_map()`. * Store graph of 2q target component in MultiQ error
…4715) * Correctly handle target with global 1q or 3q gates in Sabre The recently merged Qiskit#14317 the sabre passes were updated to build a coupling graph from a target in Rust as part of moving all the passes' logic into rust. There was a small oversight in the construction of the coupling graph when handling targets that contain globally defined operations. Previously, the constructed connectivity graph would treat the presence of any globally defined operation in the target as meaning the target had all to all connectivity which isn't always the case. If the globally defined gate is a 1q operation there could still be a connectivity graph. Similarly in the presence of > 2q gates in the target the python version didn't invalidate the construction of a connectivity graph unless there were no 2q operations. Instead the connectivity graph was ignoring the multiqubit operations. This commit updates the logic to match what is done in the Python space `Target.build_coupling_map()`. * Store graph of 2q target component in MultiQ error
Summary
The recently merged #14317 the sabre passes were updated to build a coupling graph from a target in Rust as part of moving all the passes' logic into rust. There was a small oversight in the construction of the coupling graph when handling targets that contain globally defined operations. Previously, the constructed connectivity graph would treat the presence of any globally defined operation in the target as meaning the target had all to all connectivity which isn't always the case. If the globally defined gate is a 1q operation there could still be a connectivity graph. Similarly in the presence of > 2q gates in the target the python version didn't invalidate the construction of a connectivity graph unless there were no 2q operations. Instead the connectivity graph was ignoring the multiqubit operations. This commit updates the logic to match what is done in the Python space
Target.build_coupling_map().Details and comments