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 StateVectorLQubitManaged CTOR #811

Merged
merged 22 commits into from
Jul 24, 2024
Merged

Optimize StateVectorLQubitManaged CTOR #811

merged 22 commits into from
Jul 24, 2024

Conversation

vincentmr
Copy link
Contributor

@vincentmr vincentmr commented Jul 24, 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:
Profiling a simple script similar to

from pennylane_lightning.lightning_qubit_ops import StateVectorC128
import time

for nq in range(2, 32, 2):
    t0 = time.time()
    dt = 0.0
    niter = 0
    while niter < 5 or dt < 1.0:
        niter += 1
        sv = StateVectorC128(nq)
        dt = time.time() - t0
    print(f"{nq}, {dt / niter:1.3e}")

it appears some time is wasted in a duplicate memset call when invoking the StateVectorC128 constructor.

Description of the Change:
Directly set the 0th element to 1.0.

Benefits:
Faster StateVectorC128 initialization.
speedup_ctor

Possible Drawbacks:

Related GitHub Issues:
[sc-69660]

Copy link

codecov bot commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.32%. Comparing base (de7beb7) to head (9dc37ff).
Report is 91 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (de7beb7) and HEAD (9dc37ff). Click for more details.

HEAD has 5 uploads less than BASE
Flag BASE (de7beb7) HEAD (9dc37ff)
12 7
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #811      +/-   ##
==========================================
- Coverage   98.60%   92.32%   -6.28%     
==========================================
  Files         114       73      -41     
  Lines       17658    11172    -6486     
==========================================
- Hits        17412    10315    -7097     
- Misses        246      857     +611     

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

@vincentmr vincentmr marked this pull request as ready for review July 24, 2024 14:52
@vincentmr vincentmr requested a review from a team July 24, 2024 14:53
Base automatically changed from sample_wires to master July 24, 2024 14:58
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.

🚀

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.

Nice Job. brief change with good results

@vincentmr vincentmr merged commit 11bf9dc into master Jul 24, 2024
67 of 68 checks passed
@vincentmr vincentmr deleted the optim_init_sv branch July 24, 2024 17:01
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