-
-
Notifications
You must be signed in to change notification settings - Fork 271
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
Network innerconnect #1071
Network innerconnect #1071
Conversation
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, thank you!
I would keep the previous code in comment for pedagogy, as it's generally simpler to understand how a for-loop works than directly its vectorized version.
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
Co-authored-by: Julien Hillairet <julien.hillairet@gmail.com>
ok to be merged? |
Yes, I consider it finished. |
This PR aims to improve the performance of
innerconnect_s
method during Network connection. And solved the issue that the circuit calculation slows down when using auto_reduce=True for small-scale circuits in #1069. Related to #574 #1069This PR is to achieve acceleration by avoiding repeated matrix calculations and caching intermediate calculation results. In my benchmark, the
innerconnect_s
method has a 5~6 times performance improvement in MKL/OpenBLAS backend.Your feedback and suggestions on this optimization are welcome!
Benchmark Code
Benchmark in MKL Backend:
![MKL_Benchmark](https://private-user-images.githubusercontent.com/50561614/329897841-6158c3b3-7cdb-4b3e-abe4-90160b7cf309.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAwMzQ4NzEsIm5iZiI6MTcyMDAzNDU3MSwicGF0aCI6Ii81MDU2MTYxNC8zMjk4OTc4NDEtNjE1OGMzYjMtN2NkYi00YjNlLWFiZTQtOTAxNjBiN2NmMzA5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDMlMkZ1cy1lYXN0LT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U8e5CcdgujtFrianw2eRLIxA-uaU6imrM-zmn0)
Benchmark in OpenBLAS Backend: