-
Notifications
You must be signed in to change notification settings - Fork 184
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
spin_op performance enhancement #115
Conversation
fb0e33c
to
158b813
Compare
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 added a few preliminary comments.
Could you provide a comparison between this enhancement and the current implementation?
Do you know why changing using std::unordered_map
provides better performance ?
spin_op
's public API currently relies (or leaks) the fact that its current underlying implementation behaves like a vector, e.g., operator[] (size_t index)
and spin_op::slice
. If we use a std::unordered_map
as the underlying data structure to store terms, these methods don't make much sense and will likely cause various bugs.
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.
The code and performance improvements look great! Most comments are related to either nits in the tests or replacing certain member functions with properties.
Great points to bring up. The current implementation was never tested for performance / speed as the number of terms / qubits grew (everything was fine for the small applications we'd run up to this point). My early tests show that the same benchmark as above is a factor of 100 slower than this The benefits of the As for this public API, you are correct that this changes how downstream programmers can / should reason about the underlying terms. I should remove the Open to more comments / feedback here in an effort to make this even better. Maybe I've missed something? |
799158d
to
0c3b4f1
Compare
@boschmitt Latest commit removes |
687d2de
to
0b015bb
Compare
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
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
Update
spin_op
to use aunordered_map<vector<bool>, complex<double>>
as the primary container for pauli terms.Below are results for a large (15 qubit) random spin_op addition + multiplication operations over a range of term numbers.