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

Splitting matrix operations, refactor dispatcher, add a benchmark suite for all gates/generators/matrices #274

Merged
merged 132 commits into from
May 6, 2022

Conversation

chaeyeunpark
Copy link
Contributor

@chaeyeunpark chaeyeunpark commented Mar 24, 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: While working with kernels (two existing and AVX kernels to be added), it is found that implementing the general applyMatrix method that works for all different numbers of wires is rather difficult/impractical. Thus this PR splits this method into three (applySingleQubitOp/applyTwoQubitOp/applyMultiQubitOp). In addition, a dispatching procedure is refactored to separate a module for selecting the best kernel (which is now only done in StateVector) and calling a kernel function (completely done in the DynamicDispatcher class). Benchmark suites are updated accordingly.

Description of the Change:

Benefits: Faster applyMatrix for general single-qubit and two-qubit gates. Easy to add a mechanism to choose the best-performing kernel for the given number of qubits (one of the following PRs). Easy to benchmark all gate/generator/matrix operations.

Possible Drawbacks:

Related GitHub Issues:

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.

Great work @chaeyeunpark! I have a few questions, but no blocking concerns and happy to approve afterwards.

Copy link
Member

@mlxd mlxd left a comment

Choose a reason for hiding this comment

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

Hey @chaeyeunpark as mentioned, amazing work putting this together.

Though, I do think due to the complexity here and change in architecture that we need to add supporting documentation and guides for this. I think many of us may need to relearn how everything works here to be able to contribute further to Lightning. What are your thoughts?

pennylane_lightning/src/benchmarks/AllOperations.hpp Outdated Show resolved Hide resolved
pennylane_lightning/src/benchmarks/README.md Show resolved Hide resolved
pennylane_lightning/src/bindings/Bindings.hpp Show resolved Hide resolved
pennylane_lightning/src/gates/DynamicDispatcher.cpp Outdated Show resolved Hide resolved
chaeyeunpark and others added 2 commits May 3, 2022 17:19
Co-authored-by: Lee James O'Riordan <mlxd@users.noreply.github.com>
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.

Great work @chaeyeunpark! I don't have anything else to add. Happy to approve 🎉

@chaeyeunpark
Copy link
Contributor Author

Hi @mlxd, I updated some documents (https://pennylane-lightning--274.org.readthedocs.build/en/274/benchmark.html and https://pennylane-lightning--274.org.readthedocs.build/en/274/add_kernel.html). As subsequent PRs will add more changes in dispatch mechanisms, I think it is better to add more details to the documents in those PRs.

@mlxd mlxd self-requested a review May 6, 2022 19:34
Copy link
Member

@mlxd mlxd left a comment

Choose a reason for hiding this comment

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

💯

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.

3 participants