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

Add controlled gate support to lightning.tensor #880

Merged
merged 35 commits into from
Sep 6, 2024

Conversation

multiphaseCFD
Copy link
Member

@multiphaseCFD multiphaseCFD commented Aug 29, 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:

Add controlled gate support to lightning.tensor. This could improve the performance of lightning.tensor by avoiding full gate matrix build for controlled gates. However, as of v24.08, cutensornet only supports controlled gates with only 1 wire target. [SC-72522]

Description of the Change:

Benefits:

Possible Drawbacks:

Related GitHub Issues:

@multiphaseCFD multiphaseCFD marked this pull request as ready for review September 4, 2024 14:11
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.50%. Comparing base (4bb34b7) to head (dd0ff41).
Report is 79 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (4bb34b7) and HEAD (dd0ff41). Click for more details.

HEAD has 55 uploads less than BASE
Flag BASE (4bb34b7) HEAD (dd0ff41)
64 9
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #880      +/-   ##
==========================================
- Coverage   96.54%   87.50%   -9.05%     
==========================================
  Files         208       62     -146     
  Lines       28740     5560   -23180     
==========================================
- Hits        27748     4865   -22883     
+ Misses        992      695     -297     

☔ 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.

Looks good @multiphaseCFD . Could you run these tests with Lightning-Tensor though?

.github/CHANGELOG.md Outdated Show resolved Hide resolved
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.

Everything looks super good. I do not have any comment. Thank you @multiphaseCFD

multiphaseCFD and others added 3 commits September 5, 2024 11:05
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
…a/TNCudaBase.hpp

Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
@multiphaseCFD
Copy link
Member Author

Looks good @multiphaseCFD . Could you run these tests with Lightning-Tensor though?

Good point @vincentmr . Unfortunately not with current cutensornet API. As mentioned in the changelog, as of cutensornet v24.08, controlled gates API only support 1-wire target.

@vincentmr
Copy link
Contributor

Unfortunately not with current cutensornet API. As mentioned in the changelog, as of cutensornet v24.08, controlled gates API only support 1-wire target.

Could you add a pytest.skip here when num_wires > 1?

@multiphaseCFD
Copy link
Member Author

Unfortunately not with current cutensornet API. As mentioned in the changelog, as of cutensornet v24.08, controlled gates API only support 1-wire target.

Could you add a pytest.skip here when num_wires > 1?

Sure, done!

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.

LGTM, nice @multiphaseCFD .

.github/CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Ali Asadi <10773383+maliasadi@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.

Nice work! Thanks @multiphaseCFD 🚀

@multiphaseCFD multiphaseCFD merged commit c676ced into master Sep 6, 2024
81 of 90 checks passed
@multiphaseCFD multiphaseCFD deleted the add_controlled_gate_ltensor branch September 6, 2024 15:54
multiphaseCFD added a commit that referenced this pull request Sep 8, 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`](../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`.

- [x] Add a new entry to the `.github/CHANGELOG.md` file, summarizing
the
      change, and including a link back to the PR.

- [x] 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:**

Add controlled gate support to `lightning.tensor`. This could improve
the performance of `lightning.tensor` by avoiding full gate matrix build
for controlled gates. However, as of v24.08, cutensornet only supports
controlled gates with only 1 wire target. [SC-72522]

**Description of the Change:**

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**

---------

Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>
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.

5 participants