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

Optimize LQ::probs for large number of targets #807

Merged
merged 4 commits into from
Jul 19, 2024
Merged

Conversation

vincentmr
Copy link
Contributor

@vincentmr vincentmr commented Jul 18, 2024

Before submitting

Please complete the following checklist when submitting a PR:

  • All new features must include a unit test.
    If you've fixed a bug or added code that should be tested, add a test to the
    tests directory!

  • All new functions and code must be clearly commented and documented.
    If you do make documentation changes, make sure that the docs build and
    render correctly by running make docs.

  • Ensure that the test suite passes, by running make test.

  • Add a new entry to the .github/CHANGELOG.md file, summarizing the
    change, and including a link back to the PR.

  • Ensure that code is properly formatted by running make format.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Context:
The parallel performance of probs is terrible when the input has many targets. For instance with 16 OpenMP threads:

tgt=8,qubits=20,probs,t_avg=5.50773,t_ratio=1/1000
tgt=9,qubits=20,probs,t_avg=8.44628,t_ratio=1/1000
tgt=10,qubits=20,probs,t_avg=17.0945,t_ratio=1/1000
tgt=11,qubits=20,probs,t_avg=43.9831,t_ratio=1/1000
tgt=12,qubits=20,probs,t_avg=135.431,t_ratio=1/1000
tgt=13,qubits=20,probs,t_avg=354.502,t_ratio=1/1000
tgt=14,qubits=20,probs,t_avg=1099.4,t_ratio=1/1000
tgt=15,qubits=20,probs,t_avg=3680.11,t_ratio=1/1000
tgt=16,qubits=20,probs,t_avg=10363.3,t_ratio=1/1000
tgt=17,qubits=20,probs,t_avg=35061.4,t_ratio=1/1000

Description of the Change:
Parallelize the double loop over the loop on probs only.

Benefits:
Faster execution for any number of targets on "normal" processor (< 129 cores). I won't show a proper sweep over the number of targets because the current version is too slow to do so.

tgt=8,qubits=20,probs,t_avg=2.93886,t_ratio=1/1000
tgt=9,qubits=20,probs,t_avg=3.17052,t_ratio=1/1000
tgt=10,qubits=20,probs,t_avg=2.86489,t_ratio=1/1000
tgt=11,qubits=20,probs,t_avg=2.61477,t_ratio=1/1000
tgt=12,qubits=20,probs,t_avg=2.40587,t_ratio=1/1000
tgt=13,qubits=20,probs,t_avg=2.23169,t_ratio=1/1000
tgt=14,qubits=20,probs,t_avg=2.08594,t_ratio=1/1000
tgt=15,qubits=20,probs,t_avg=1.97252,t_ratio=1/1000
tgt=16,qubits=20,probs,t_avg=2.30553,t_ratio=1/1000
tgt=17,qubits=20,probs,t_avg=2.44993,t_ratio=1/1000

Possible Drawbacks:
"Abnormal" processors (i.e. 1024 cores) could benefit from a different parallelization strategy in certain edge cases.

Related GitHub Issues:
[sc-69165]

Copy link

codecov bot commented Jul 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.32%. Comparing base (356bdce) to head (78fc12f).
Report is 91 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #807      +/-   ##
==========================================
- Coverage   94.25%   92.32%   -1.93%     
==========================================
  Files         131       73      -58     
  Lines       19792    11172    -8620     
==========================================
- Hits        18655    10315    -8340     
+ Misses       1137      857     -280     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vincentmr vincentmr changed the title Early exit LQ::probs({}) and optimize parallel loop. Optimize LQ::probs for large number of targets Jul 18, 2024
@vincentmr vincentmr marked this pull request as ready for review July 18, 2024 18:23
@vincentmr vincentmr requested a review from a team July 18, 2024 18:27
Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

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

Thanks @vincentmr!

@vincentmr vincentmr requested a review from a team July 18, 2024 18:45
@LuisAlfredoNu LuisAlfredoNu self-requested a review July 19, 2024 20:26
Copy link
Contributor

@LuisAlfredoNu LuisAlfredoNu left a comment

Choose a reason for hiding this comment

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

Good improvement with OPENMP

@vincentmr vincentmr merged commit 9a83ff4 into master Jul 19, 2024
66 of 68 checks passed
@vincentmr vincentmr deleted the probs_omp_collapse branch July 19, 2024 20:50
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.

4 participants