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

Update logic for enabling grad_on_execution in lightning_*.py devices #1016

Merged
merged 13 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

### Improvements

* Update the logic for enabling `grad_on_execution` during device execution.
[(#1016)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1016)

* Reverse Lightning Qubit generators vector insertion order.
[(#1009)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1009)

Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.40.0-dev26"
__version__ = "0.40.0-dev27"
6 changes: 5 additions & 1 deletion pennylane_lightning/lightning_gpu/lightning_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@
updated_values["gradient_method"] = "adjoint"
if config.use_device_gradient is None:
updated_values["use_device_gradient"] = config.gradient_method in ("best", "adjoint")
if config.grad_on_execution is None:
if (

Check warning on line 302 in pennylane_lightning/lightning_gpu/lightning_gpu.py

View check run for this annotation

Codecov / codecov/patch

pennylane_lightning/lightning_gpu/lightning_gpu.py#L302

Added line #L302 was not covered by tests
config.use_device_gradient
or updated_values.get("use_device_gradient", False)
and config.grad_on_execution is None
):
updated_values["grad_on_execution"] = True

new_device_options = dict(config.device_options)
Expand Down
6 changes: 5 additions & 1 deletion pennylane_lightning/lightning_kokkos/lightning_kokkos.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@
updated_values["gradient_method"] = "adjoint"
if config.use_device_gradient is None:
updated_values["use_device_gradient"] = config.gradient_method in ("best", "adjoint")
if config.grad_on_execution is None:
if (

Check warning on line 274 in pennylane_lightning/lightning_kokkos/lightning_kokkos.py

View check run for this annotation

Codecov / codecov/patch

pennylane_lightning/lightning_kokkos/lightning_kokkos.py#L274

Added line #L274 was not covered by tests
config.use_device_gradient
or updated_values.get("use_device_gradient", False)
and config.grad_on_execution is None
):
updated_values["grad_on_execution"] = True

new_device_options = dict(config.device_options)
Expand Down
6 changes: 5 additions & 1 deletion pennylane_lightning/lightning_qubit/lightning_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@
updated_values["gradient_method"] = "adjoint"
if config.use_device_gradient is None:
updated_values["use_device_gradient"] = config.gradient_method in ("best", "adjoint")
if config.grad_on_execution is None:
if (

Check warning on line 313 in pennylane_lightning/lightning_qubit/lightning_qubit.py

View check run for this annotation

Codecov / codecov/patch

pennylane_lightning/lightning_qubit/lightning_qubit.py#L313

Added line #L313 was not covered by tests
config.use_device_gradient
or updated_values.get("use_device_gradient", False)
and config.grad_on_execution is None
):
updated_values["grad_on_execution"] = True

new_device_options = dict(config.device_options)
Expand Down
Loading