Skip to content
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

[WIP] Improve generation performance in manybody.jl #121

Merged
merged 2 commits into from
Jul 16, 2023

Conversation

aryavorskiy
Copy link
Contributor

@aryavorskiy aryavorskiy commented Jul 15, 2023

Performance optimizations:

  • Setting an sparse matrix like mat[i, j] = k is extremely slow and unoptimal when done in a loop. It can be avoided by creating three separate lists for values and indices and calling sparse(is, js, vs, size1, size2) in the end.
  • Allocating new arrays or copying existing ones causes significant slowdown. The new coefficient function does not allocate new arrays (or copy old ones) and accepts any iterable as indices - even single number values (they are iterable, too!).

Combined together this yields a 300x performance boost (23s -> 75ms for a full boson basis with 2 particles on 36 modes) for the manybodyoperator function.

Still, this is nearly not enough for large systems (for example, when there are 3 particles, manybodypoerator runs for 12 seconds), so we have to do something better. My simplest proposal is making the occupations vectors sparse to make finding the coefficients easier, but probably there is an even better idea somewhere.

@aryavorskiy aryavorskiy changed the title Improve generation performance in manybody.jl [WIP] Improve generation performance in manybody.jl Jul 16, 2023
@codecov
Copy link

codecov bot commented Jul 16, 2023

Codecov Report

Merging #121 (76ec302) into master (1d4ad57) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #121   +/-   ##
=======================================
  Coverage   93.61%   93.62%           
=======================================
  Files          25       25           
  Lines        3072     3076    +4     
=======================================
+ Hits         2876     2880    +4     
  Misses        196      196           
Impacted Files Coverage Δ
src/manybody.jl 99.65% <100.00%> (+<0.01%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Krastanov
Copy link
Collaborator

CI passes, everything is completely covered by pre-existing tests, and the code itself seems fine on review. I am merging this and making a new release so that it is publicly available. Thank you for the improvements, the difference is quite noticeable.

If you have the bandwidth, I would be happy to review any future improvements along the lines of what you described.

@Krastanov Krastanov merged commit 8f16def into qojulia:master Jul 16, 2023
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants