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

Better kernel dispatch and add custom _asarray #245

Closed
wants to merge 116 commits into from

Conversation

chaeyeunpark
Copy link
Contributor

@chaeyeunpark chaeyeunpark commented Mar 2, 2022

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: Currently, we have two different gate implementations (kernels) and some more to be added. As it is possible that one kernel outperforms another kernel only for some number of qubits, it is desirable to have a kernel dispatcher mechanism that takes this information into account. In addition, as with AVX kernels, it is necessary to have an array whose memory is managed by lightning with a proper alignment.

Description of the Change: Lightning now has the KernelMap class which returns the kernels to use for a given number of qubits. The statevector classes now manage their own kernel information accordingly. Moreover, _asarray is implemented.

Benefits: Not huge right now, but with AVX and OpenMP kernels, we should have some advantages.

Possible Drawbacks: Slightly slower dispatch time (1 or 2 more std::unoreder_map accesses), and constructing a statevector becomes slower as it needs to obtain the best kernels for each operation.

Related GitHub Issues:

Still need to fix/add documents.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2022

Hello. You may have forgotten to update the changelog!
Please edit .github/CHANGELOG.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2022

Test Report (C++) on Ubuntu

           1 files  ±    0             1 suites  ±0   0s ⏱️ ±0s
       761 tests  -     3         761 ✔️  -     3  0 💤 ±0  0 ±0 
228 963 runs  +395  228 963 ✔️ +395  0 💤 ±0  0 ±0 

Results for commit 0eced01. ± Comparison against base commit fab55ea.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Mar 2, 2022

Codecov Report

Merging #245 (9528481) into master (fab55ea) will decrease coverage by 3.64%.
The diff coverage is 92.86%.

❗ Current head 9528481 differs from pull request most recent head 6e35950. Consider uploading reports for the commit 6e35950 to get more accurate results

@@            Coverage Diff             @@
##           master     #245      +/-   ##
==========================================
- Coverage   99.19%   95.55%   -3.65%     
==========================================
  Files          28       34       +6     
  Lines        3105     2699     -406     
==========================================
- Hits         3080     2579     -501     
- Misses         25      120      +95     
Impacted Files Coverage Δ
...ennylane_lightning/src/gates/OpToMemberFuncPtr.hpp 100.00% <ø> (ø)
...lightning/src/gates/cpu_kernels/PauliGenerator.hpp 100.00% <ø> (ø)
pennylane_lightning/src/util/ConstantUtil.hpp 92.30% <ø> (-7.70%) ⬇️
pennylane_lightning/src/util/LinearAlgebra.hpp 80.59% <ø> (-16.90%) ⬇️
pennylane_lightning/src/util/Memory.hpp 63.63% <63.63%> (ø)
...nnylane_lightning/src/simulator/CPUMemoryModel.hpp 66.66% <66.66%> (ø)
...lane_lightning/src/simulator/DynamicDispatcher.hpp 78.94% <75.00%> (ø)
...nylane_lightning/src/simulator/StateVectorBase.hpp 84.61% <78.37%> (-15.39%) ⬇️
pennylane_lightning/src/simulator/DispatchKeys.hpp 85.71% <85.71%> (ø)
pennylane_lightning/src/simulator/KernelMap.hpp 90.27% <90.27%> (ø)
... and 43 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fab55ea...6e35950. Read the comment docs.

chaeyeunpark and others added 27 commits March 16, 2022 09:58
…ennylane-lightning into pre_better_kernel_dispatch
@chaeyeunpark
Copy link
Contributor Author

Continue at #291

@chaeyeunpark chaeyeunpark deleted the better_kernel_dispatch branch August 10, 2022 03:05
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.

1 participant