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

Finalize the LM kernel #212

Merged
merged 88 commits into from
Feb 12, 2022
Merged

Finalize the LM kernel #212

merged 88 commits into from
Feb 12, 2022

Conversation

chaeyeunpark
Copy link
Contributor

@chaeyeunpark chaeyeunpark commented Jan 26, 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: This is the second part of adding a new gate implementation

Description of the Change:

  • Add most of the gates in the LM kernel (including IsingXX, IsingYY, IsingZZ, as well as MultiRZ gates); still three-qubit gates are missing.
  • Adjoint method now applies generators with DynamicDispatcher.
  • Added tests for added gates and generators.
  • Automated most of the tests for gates.
  • Raise compile-time errors when the constants are not defined consistently.

Benefits: Adjoint method works for all gates.

Possible Drawbacks:

Related GitHub Issues:

As most of the +lines are from the test files (auto-generated using default.qubit), I hope that it will not make you fear...

@github-actions
Copy link
Contributor

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.

@chaeyeunpark chaeyeunpark changed the title Finalize lm kernel [WIP]Finalize lm kernel Jan 26, 2022
@chaeyeunpark
Copy link
Contributor Author

Hi all, the benchmark of gate operations between kernels can be found here: https://github.com/PennyLaneAI/pennylane-lightning-compare-kernels. Even though the result is not that impressive for some gates, I see dramatic speed-up when parallelizing the new kernel gate operations (with OpenMP + loop unrolling). I will make a document on this when this PR is merged.

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 on this 🥇 Do we know when it is likely to be merged?

@chaeyeunpark chaeyeunpark requested a review from mlxd February 10, 2022 17:39
@chaeyeunpark
Copy link
Contributor Author

Hi @maliasadi, I want to merge this when @mlxd also approves this. I also thank you for reviewing this huge PR. As most of the components I wanted are settled, I will not make a vast PR anymore (at least for a while 😉 ).

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.

Amazing PR @chaeyeunpark !
Very happy to see this merged in. Though, for the record, is it possible to have a before and after comparison plot in the PR comments (Comparing v0.21 and this PR)?

Note, I expect this may also impact the external package work, but I think the sooner the better for this.

pennylane_lightning/src/CMakeLists.txt Outdated Show resolved Hide resolved
pennylane_lightning/src/bindings/Bindings.cpp Show resolved Hide resolved
};

const std::vector<size_t> wires = {0, 1, 2, 3};
std::vector<ComplexPrecisionT> matrix{
Copy link
Member

Choose a reason for hiding this comment

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

This is a big one!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I generated a test example using python. Still, if we are able to use constexpr JSON parser, it would be possible to define all test cases in a JSON file. That would be the best.

tests/test_adjoint_jacobian.py Show resolved Hide resolved
@chaeyeunpark
Copy link
Contributor Author

Bench1
This is the result from benchmark suite 1. Not as impressive as before, but still faster. More speed-up will come with OpenMP and SIMD kernels (that I am working on right now 😉).

@chaeyeunpark chaeyeunpark merged commit 2cb2727 into master Feb 12, 2022
@chaeyeunpark chaeyeunpark deleted the finalize_lm_kernel branch February 12, 2022 15:19
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