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 support for multi-controlled zyz #6042

Merged
merged 24 commits into from
Aug 21, 2024
Merged

Add support for multi-controlled zyz #6042

merged 24 commits into from
Aug 21, 2024

Conversation

maliasadi
Copy link
Member

@maliasadi maliasadi commented Jul 26, 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
    test 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 doc/releases/changelog-dev.md file, summarizing the
    change, and including a link back to the PR.

  • The PennyLane source code conforms to
    PEP8 standards.
    We check all of our code against Pylint.
    To lint modified files, simply pip install pylint, and then
    run pylint pennylane/path/to/file.py.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Context:
This PR implements the decomposition of zyz for special unitaries with multiple control wires defined in Lemma 7.9 of https://arxiv.org/pdf/quant-ph/9503016.

Benefits:
Support decomposition of zyz for special unitaries.

Possible Drawbacks:

Related GitHub Issues:
[sc-68471]

Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.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.

Copy link

codecov bot commented Jul 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.65%. Comparing base (1f55c88) to head (e8fe649).
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6042      +/-   ##
==========================================
- Coverage   99.67%   99.65%   -0.02%     
==========================================
  Files         432      432              
  Lines       41839    41704     -135     
==========================================
- Hits        41702    41562     -140     
- Misses        137      142       +5     

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

Copy link
Contributor

@EmilianoG-byte EmilianoG-byte left a comment

Choose a reason for hiding this comment

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

Thank you for this addition! Just left a couple of comments. I would say the most important one is regarding the warning when decomposing Global phase with more than one control wire. In any case, great work 🤩

tests/ops/op_math/test_controlled_decompositions.py Outdated Show resolved Hide resolved
tests/ops/op_math/test_controlled.py Outdated Show resolved Hide resolved
tests/ops/op_math/test_controlled.py Outdated Show resolved Hide resolved
pennylane/ops/op_math/controlled_decompositions.py Outdated Show resolved Hide resolved
Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

My main concern right now is the correctness for non-special unitary ops. If we are expecting qml.PauliZ(0) and qml.S(0) to decompose like special unitary ops, but they aren't actually special unitary, are we providing incorrect decompositions?

maliasadi and others added 4 commits August 8, 2024 13:57
Co-authored-by: Cristian Emiliano Godinez Ramirez <57567043+EmilianoG-byte@users.noreply.github.com>
@maliasadi maliasadi added this to the v0.38 milestone Aug 20, 2024
Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

Sorry about not getting back to this for so long. 👍 Looks good to me :)

Copy link
Contributor

@EmilianoG-byte EmilianoG-byte left a comment

Choose a reason for hiding this comment

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

Just one minor correction on the tests! Sorry for being so nitpicky 🙏

tests/ops/op_math/test_controlled_decompositions.py Outdated Show resolved Hide resolved
Copy link
Contributor

@EmilianoG-byte EmilianoG-byte left a comment

Choose a reason for hiding this comment

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

Thank you for the changes! Nice to have this new decomposition 🥳

@maliasadi maliasadi merged commit 8001350 into master Aug 21, 2024
40 checks passed
@maliasadi maliasadi deleted the multicontrolled-zyz branch August 21, 2024 18:37
maliasadi added a commit to PennyLaneAI/pennylane-lightning that referenced this pull request Aug 22, 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`.

- [x] 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:**
PR PennyLaneAI/pennylane#6042 adds support for
multi-controlled zyz.
For Lightning, this means that custom decompositions to special zyz with
multiple controlled wires will be supported.
 
**Description of the Change:**
- Add tests for adjoint jacobian of the controlled gate with multiple
controlled_wires.

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**
[sc-67711]

---------

Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
multiphaseCFD pushed a commit to PennyLaneAI/pennylane-lightning 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`.

- [x] 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:**
PR PennyLaneAI/pennylane#6042 adds support for
multi-controlled zyz.
For Lightning, this means that custom decompositions to special zyz with
multiple controlled wires will be supported.
 
**Description of the Change:**
- Add tests for adjoint jacobian of the controlled gate with multiple
controlled_wires.

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**
[sc-67711]

---------

Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
mudit2812 pushed a commit that referenced this pull request Sep 10, 2024
### Before submitting

Please complete the following checklist when submitting a PR:

- [x] 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
      test directory!

- [x] 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`.

- [x] Ensure that the test suite passes, by running `make test`.

- [x] Add a new entry to the `doc/releases/changelog-dev.md` file,
summarizing the
      change, and including a link back to the PR.

- [x] The PennyLane source code conforms to
      [PEP8 standards](https://www.python.org/dev/peps/pep-0008/).
We check all of our code against [Pylint](https://www.pylint.org/).
      To lint modified files, simply `pip install pylint`, and then
      run `pylint pennylane/path/to/file.py`.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


------------------------------------------------------------------------------------------------------------

**Context:**
This PR implements the decomposition of zyz for special unitaries with
multiple control wires defined in Lemma 7.9 of
https://arxiv.org/pdf/quant-ph/9503016.

**Benefits:**
Support decomposition of zyz for special unitaries.

**Possible Drawbacks:**

**Related GitHub Issues:**
[sc-68471]

---------

Co-authored-by: albi3ro <chrissie.c.l@gmail.com>
Co-authored-by: Cristian Emiliano Godinez Ramirez <57567043+EmilianoG-byte@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.

4 participants