Avoiding Kronecker products using method similar Celio's #74 #80
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a bit of a mess and should not be merged unless cleaned up and thoroughly tested. It essentially copies CelioHamiltonian and Hamiltonian into a class
Hamiltonian2
and keeps all interaction matrices small, constructing the full hamiltonian only when its about to be diagonalized. Its based on #79 and uses dense matrices everywhere.The system
Takes ~14 seconds (4 of which are the construction of the hamiltonian). Using dense matrices alone it takes around 9 seconds.
Goes from using 800Mb down to 500 (from 2.1Gb without the method and just using dense), and from 298 seconds down to 60. The performance can likely be further improved using parallelised C++ for constructing the Hamiltonian. Most of the memory usage saving is actually due to commenting out the construction of
self._single_spinops
in experiment.py. This should only be used if necessary as the matrices are all large. Perhaps this should just be left as sparse for the time being?The linbladian would still need something similar - only constructing the full matrix just before its used.
The branch itself is referenced here: https://github.com/muon-spectroscopy-computational-project/Developer-notes/blob/main/muspinsim/improving_sparse_matrices.md