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
Speed up the HEOM RHS construct #2128
Speed up the HEOM RHS construct #2128
Conversation
@nwlambert Would you mind giving this a try with some bigger realistic HEOM examples you have lying around? Eric's recent improvements to CSR @Ericgig Would you mind giving your thoughts on the Cython interface both from a "is this good from a technical point of view" and from a "do we want this point of view". I guess we could also name it |
It doesn't look robust enough to be user facing as it is, but as a private function, if you get a 3.5x, I'd say we want it. Technically, just give a type to |
I'll rename it to
Thanks! Adding the type to |
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.
Seems fine.
This fixes the used data type to CSR
and this should be documented.
I think you want csr.zeros
instead of csr.empty
.
… matrices do not yet have valid row_index entries.
It is documented in the docstring for |
@Ericgig Thank you for the review. Would you mind having a last look? I made quite a few small changes. |
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.
Better with zeros
.
I would document in HEOMSolver
say there that the Hamiltonian and bath operator will be coerced to csr
.
Description
Adds a
_from_csr_blocks
constructor to speed up the construction of the HEOM RHS by a factor of ~4x.What allows
from_csr_blocks
to be fast is that we can order the blocks in a way that makes it possible to write the rows of the output one after the other without a lot of work, and we never have to add a new non-zero element into a row or make a copy of the big output matrix.The implementation in Python was slow just because there is a lot of Python looping and arithmetic when the number of operators being combined becomes large.
_from_csr_blocks
is a private constructor for now. If use cases emerge we can consider making something similar part of the public interface later.Related issues or PRs