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

make compatible with new return types spec #427

Merged
merged 8 commits into from
Apr 11, 2023
Merged

make compatible with new return types spec #427

merged 8 commits into from
Apr 11, 2023

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Apr 5, 2023

Context:

With Pennylane PR #3957: PennyLaneAI/pennylane#3957 , the new return types system is enabled by default.

To make sure lightning works with pennylane master, we need to change the return shape from adjoint_jacobian. The return shape from execute in handled inside QubitDevice.

Description of the Change:

The changes to the source code are:

  • Change the output of adjoint_jacobian to match the new nested tuples specification
  • Change use of tape.get_parameters to eliminate deprecation warning
  • Remove reshape in vjp as it is no longer necessary
  • Wrap the vjp in a tuple if it is not already a tuple and reduction="extend" is requested.

The changes to the tests are:

  • change expected shape in a couple places
  • switch finite_diff to param_shift, as finite diff was causing errors with float32
  • Cast output to a numpy array from a tuple when using autograd, as autograd cannot differentiate a tuple

Benefits:
It works with PennyLane master.

Possible Drawbacks:
None

Related GitHub Issues:
None

@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2023

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.

@albi3ro
Copy link
Contributor Author

albi3ro commented Apr 5, 2023

[sc-35004]

@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Merging #427 (d412bca) into master (1668103) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #427   +/-   ##
=======================================
  Coverage   99.82%   99.82%           
=======================================
  Files          50       50           
  Lines        4624     4634   +10     
=======================================
+ Hits         4616     4626   +10     
  Misses          8        8           
Impacted Files Coverage Δ
pennylane_lightning/_version.py 100.00% <100.00%> (ø)
pennylane_lightning/lightning_qubit.py 99.13% <100.00%> (+0.02%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@AmintorDusko AmintorDusko 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, @albi3ro.
Nice job here!

@AmintorDusko AmintorDusko requested a review from a team April 6, 2023 12:31
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.

Thanks @albi3ro
Some brief comments. I think the changelog also needs to be updated to reflect the breaking changes with the new interface.

pennylane_lightning/lightning_qubit.py Show resolved Hide resolved
tests/test_adjoint_jacobian.py Show resolved Hide resolved
tests/test_adjoint_jacobian.py Show resolved Hide resolved
@albi3ro albi3ro requested a review from mlxd April 6, 2023 16:12
.github/CHANGELOG.md Outdated Show resolved Hide resolved
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.

Thanks @albi3ro
No other concerns from me. Once the other conversations are resolved we can merge this in.

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
@mlxd
Copy link
Member

mlxd commented Apr 6, 2023

Just a note, the broken MacOS builds are being worked on in #428 and I will notify here once complete and ready for review.

@mlxd
Copy link
Member

mlxd commented Apr 10, 2023

Note, once the PR #428 is approved, we can merge onto this PR and then go to master

* Allow brew clang version to be set through env var

* Fix format

* Auto update version

* retry the clang 15 pin

* Again

* Remove whitespace

* Fix llvm path

* Install correct OMP version

* Reorder libomp install for MacOS

* Attempt to upgrade all clang & libomp pins for MacOS

* Keep clang15 from brew and pull libomp version explicitly into CMake

* Add missing comma

* Explicitly add setuptools as it is not found on MacOS builds

* Adapt to use fun instead of check_output

* Retry to find OpenMP

* Fallback to MacOS native compiler and libomp@16 from brew

* Update MacOS runner to access newer compiler version

* Update MacOS runner to access newer compiler version for entire workload

* Use in-built compiler and brew libomp for all MacOS

* Remove redundant install

* Remove ARM libomp

* Update setup.py

Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>

* Remove ARM libomp

* Ensure libomp brew check is guarded

* Move OpenMP checks to better suit where they are found

* Explicitly disable OpenMP for M1 macs in respective section

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
@mlxd mlxd merged commit 75471a8 into master Apr 11, 2023
@mlxd mlxd deleted the fix-return-types branch April 11, 2023 19:18
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