You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix virtual/physical-qubit distinction in Sabre (#10712)
* Fix virtual/physical-qubit distinction in Sabre
`SabreLayout` in particular previously had a very confused notion of
virtual and physical qubits in Rust space; on each iteration, it rewrote
the `SabreDAG` to "apply" a layout. This is not logically what
`SabreDAG` represents, though; that defines the circuit purely in terms
of virtual qubits, which by definition do not change as the mapping of
them to physical qubits changes.
This commit modifies that internal logic so that there is a clear
distinction between the virtual DAG and the changing layout. This
significantly simplies the logic within the Sabre layout Rust component.
This commit is RNG-compatible with its parent.
The Python entry points to the Rust components of both layout and
routing are modified to return a final permutation, rather than a final
layout, as this is what `TranspileLayout.final_layout` actually is.
The application of the Sabre result to a DAG is also updated to reflect
the correct virtual/physical relationship. With the roles of everything
clarified, this now means that in the Sabre layout case, it
automatically does the job of `ApplyLayout` _and_ the subsequent
swap-mapping in one iteration, rather than rewriting the DAG once with
`ApplyLayout` only to rewrite it immediately after with the swap-mapped
form; the initial layout is after all only valid as far as the first
inserted swap.
The Sabre routing inputs are slightly tweaked, so the clone of the
layout that the routing pass mutates to track its state as it progresses
happens internally. _Technically_, there could have been situations
where it was preferable for the caller in Rust-space to give the output
object (if it didn't care about losing the initial layout), but in
practice, we always cloned on entry. The cost of the layout clone is
not high even in the worst case, and this makes the ownership,
mutation and return-value interfaces clearer.
* Fix out-of-date types
Co-authored-by: Matthew Treinish <[email protected]>
Co-authored-by: Kevin Hartman <[email protected]>
* Improve efficiency of interfaces
---------
Co-authored-by: Matthew Treinish <[email protected]>
Co-authored-by: Kevin Hartman <[email protected]>
0 commit comments