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 DeviceJacobianProducts jacobian product calculator #4637

Merged
merged 77 commits into from
Oct 19, 2023

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Oct 2, 2023

This PR is a follow on to #4527 . [sc-44325]

It adds DeviceJacobianProducts that can bind device provided jvps and vjps to the execution pipeline.

albi3ro and others added 30 commits August 2, 2023 16:11
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Copy link
Contributor

@dwierichs dwierichs 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 to me, thanks for the added test.
It's probably a matter of taste, but I suggested a sentence for the DeviceJacobianProducts docstring that makes the difference to DeviceDerivatives explicit.

pennylane/interfaces/jacobian_products.py Show resolved Hide resolved
@mudit2812 mudit2812 added this to the v0.33 milestone Oct 17, 2023
Base automatically changed from jpc-devices to master October 19, 2023 17:47
albi3ro added a commit that referenced this pull request Oct 19, 2023
This PR follows on from #4435 , and adds a child class that can handle
device-provided derivatives.

It has two private caches, `_results_cache` and `_jacs_cache`. This
handles storing the jacobian between the forward pass and the backward
pass. The caches will also store results and jacobians between
successive calls to the same instance.

The class can handle both device interfaces, `qml.Device` and
`qml.devices.Device`.

Name for the class is still up in the air. This class takes the full
jacobian from the device and then performs the dot product. The class in
#4637 takes the jacobian product itself from the device.

---------

Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Copy link
Contributor

@timmysilv timmysilv left a comment

Choose a reason for hiding this comment

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

🎉

@albi3ro albi3ro enabled auto-merge (squash) October 19, 2023 18:38
@mudit2812 mudit2812 added the merge-ready ✔️ All tests pass and the PR is ready to be merged. label Oct 19, 2023
@albi3ro albi3ro merged commit 8adc6ab into master Oct 19, 2023
33 checks passed
@albi3ro albi3ro deleted the native-jpc-devices branch October 19, 2023 20:24
mudit2812 added a commit that referenced this pull request Oct 20, 2023
This PR follows on from #4435 , and adds a child class that can handle
device-provided derivatives.

It has two private caches, `_results_cache` and `_jacs_cache`. This
handles storing the jacobian between the forward pass and the backward
pass. The caches will also store results and jacobians between
successive calls to the same instance.

The class can handle both device interfaces, `qml.Device` and
`qml.devices.Device`.

Name for the class is still up in the air. This class takes the full
jacobian from the device and then performs the dot product. The class in
#4637 takes the jacobian product itself from the device.

---------

Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
mudit2812 pushed a commit that referenced this pull request Oct 20, 2023
This PR is a follow on to #4527 . [sc-44325]

It adds `DeviceJacobianProducts` that can bind device provided jvps and
vjps to the execution pipeline.

---------

Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
albi3ro added a commit that referenced this pull request Nov 7, 2023
This PR follows on from #4527 and #4637 .

Since we still need to make performance improvements to
`DefaultQubit.compute_vjp`, I added an opt-in keyword argument
`use_device_jacobian_product` to `qml.execute`. This allows us to easily
compare between using the device jacobian product and not.

Fixes #3217

---------

Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-ready ✔️ All tests pass and the PR is ready to be merged. review-ready 👌 PRs which are ready for review by someone from the core team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants