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

assignment: add ISWAP functionality and unit tests #749

Closed
wants to merge 3 commits into from

Conversation

luotianwu
Copy link

@luotianwu luotianwu commented Jun 2, 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:

Description of the Change:
Add ISWAP functionality in BasicGateFunctors.hpp
Add ISWAP unit tests in :
StateVectorKokkos::applyMatrix/Param-Operation
StateVectorKokkos::applyISWAP
Passed updated tests in lightning_kokkos_gates_test_runner

Benefits:
New ISWAP feature available and can run on multiple HPC platforms.

Possible Drawbacks:
Python layer testing for this gate was not addressed.
Performance test for this gate was not conducted.

Related GitHub Issues:

Fixes #740.

Copy link

codecov bot commented Jun 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.20%. Comparing base (e24ba31) to head (79f1fd5).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #749      +/-   ##
==========================================
- Coverage   94.57%   91.20%   -3.38%     
==========================================
  Files         122       88      -34     
  Lines       17781    10627    -7154     
==========================================
- Hits        16816     9692    -7124     
+ Misses        965      935      -30     

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

Copy link
Contributor

@vincentmr vincentmr left a comment

Choose a reason for hiding this comment

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

Thanks for initiating this @luotianwu. Could you compare the performance of the ISWAP gate on lightning.kokkos between the SERIAL and OpenMP backends and explain how the ISWAP C++ Kokkos kernel is executed concurrently. Sweeping over target qubits you should see a hardware dependent pattern, can you explain where it comes from?

@luotianwu
Copy link
Author

The ISWAP kernel is launched by Kokkos::parallel_for in applyNC2Functor. The kernel will be executed in parallel over range 0-exp(num_qubits-2)-1. The kernel execution for different indices in the range can be assigned to multiple processing units. The state vector array has size exp(num_qubits), by operating two of the qubits, the state vector indices are grouped by 4 and thus needs to loop over exp(num_qubits-2) groups.
The hardware dependent pattern is passed by template parameter ExecutionSpace. The value passed for it is Kokkos::DefaultExecutionSpace. I think it get value from CMAKE configuration -DKokkos_ENABLE_OPENMP=ON, -DKokkos_ENABLE_CUDA=ON, -DKokkos_ENABLE_SERIAL=ON etc.

I tried to build with -DKokkos_ENABLE_OPENMP=ON and -DKokkos_ENABLE_CUDA=OFF. To see the performance, I added some time collection code in the kernel and also printed out the backend by KokkosExecSpace::name(). But somehow it always show CUDA as the backend. Unfortunately I didn't have more time to figure it out.

@tomlqc tomlqc closed this Jun 14, 2024
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.

ISWAP gate implementation for lightning.kokkos
4 participants