Skip to content

Commit

Permalink
Optimise SparsePauliOp.from_operator
Browse files Browse the repository at this point in the history
This rewrites the `from_operator` handling (again!) from the initial
Rust implementation of the recursive matrix-addition form into an
iterative approach that re-uses the same scratch memory all the way
down.  This is significantly faster, and allocates far less often,
although in practice the peak heap memory usage will be not dissimilar.

The algorithm is rewritten to be a manual stack-based iteration, rather
than a functional recursion.  The size of a single stack entry in the
iteration is one `usize`, which is drastically smaller than whatever
per-function-call stack will have been used before.
  • Loading branch information
jakelishman committed Sep 20, 2024
1 parent 9a896d3 commit 9ad36a3
Show file tree
Hide file tree
Showing 2 changed files with 462 additions and 154 deletions.
Loading

0 comments on commit 9ad36a3

Please sign in to comment.