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

Fast overlap and fast add of sparse matrices #10

Merged
merged 4 commits into from
Oct 12, 2023

Conversation

GiggleLiu
Copy link
Member

@GiggleLiu GiggleLiu commented Oct 7, 2023

Nice package. I profiled the transverse field ising model example program and noticed some performance issues in this package.
This is a patch to improve the performance of sparse operations. Please review this PR carefully in case I made some stupid mistake.

Benchmark

Before this patch, the time to run the example on my machine is

89.098484 seconds

After this patch, it could be reduced to

15.646890 seconds

@GiggleLiu GiggleLiu requested a review from jlbosse October 7, 2023 02:29
@codecov
Copy link

codecov bot commented Oct 7, 2023

Codecov Report

All modified lines are covered by tests ✅

Files Coverage Δ
src/FLOYao.jl 100.00% <ø> (ø)
src/apply_composite.jl 100.00% <100.00%> (ø)
src/auto_diff.jl 100.00% <100.00%> (ø)
src/utils.jl 92.57% <100.00%> (+4.47%) ⬆️

📢 Thoughts on this report? Let us know!.

Copy link
Collaborator

@jlbosse jlbosse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this PR, I was actually wondering myself why the computation of the gradients was so slow compared to the expectation values!

I left two comments in the code and would generally move fast_add() and fast_overlap() to a separate "Fast sparse matrix operators" section in utils.jl instead of having them interspersed with auto diff and operator conversion code.

Otherwise this looks good and can be merged after these changes.

src/auto_diff.jl Outdated Show resolved Hide resolved
src/auto_diff.jl Show resolved Hide resolved
@GiggleLiu
Copy link
Member Author

Yeah, it makes sense. I just resolved these issues.

@jlbosse
Copy link
Collaborator

jlbosse commented Oct 12, 2023

Looks great, thanks again for the PR

@jlbosse jlbosse merged commit 3e677e5 into master Oct 12, 2023
8 checks passed
@jlbosse jlbosse deleted the jg/improve-sparsematrix-operations branch October 12, 2023 16:13
@jlbosse jlbosse mentioned this pull request Oct 17, 2023
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