-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use `SmallVec` in `NeighborTable` for cache locality A reasonable chunk of our time in Sabre is spent reading through the `NeighborTable` to find the candidate swaps for a given layout. Most coupling maps that we care about have a relatively low number of edges between qubits, yet we needed to redirect to the heap for each individual physical-qubit lookup currently. This switches from using a `Vec` (which is always a fat pointer to heap memory) to `SmallVec` with an inline buffer space of four qubits. With the qubit type being `u32`, the `SmallVec` now takes up the same stack size as a `Vec` but can store (usually) all the swaps directly inline in the outer `Vec` of qubits. This means that most lookups of the available swaps are looking in the same (up to relatively small offsets) in memory, which makes the access patterns much easier for prefetching to optimise for. * Pickle via `PyList` instead of duplicate conversion `SmallVec` doesn't have implementations of the PyO3 conversion trait, so it needs to be done manually. The previous state used to convert to a Rust-space `Vec` that then needed to have its data moved from the Python heap to the Rust heap. This instead changes the conversions to interact directly with Python lists, rather than using intermediary structures.
- Loading branch information
1 parent
838bb38
commit 180f19a
Showing
3 changed files
with
46 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters