-
Notifications
You must be signed in to change notification settings - Fork 586
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
[BUG] Some templates not properly differentiated with parameter shift on the legacy device #5802
Comments
This is a result of finite differences. |
…tudeAmplification`, and `Qubitization`. (#5806) **Context:** Templates that are not actually supported by `parameter_shift` should have `grad_method=None` so that they are decomposed by `_expand_transform_param_shift` **Description of the Change:** 1. Adds the `data` of components of the templates to the `data` of the templates such that trainable parameters are tracked 2. Adds `grad_method=None` for `ControlledSequence`, `Reflection`, `AmplitudeAmplification`, and `Qubitization`. **Related GitHub Issues:** Fixes #5802 [sc-64967]
Expected behavior
ControlledSequence
,Reflection
,Qubitization
, andAmplitudeAmplification
can be differentiated with bothdefault.qubit
anddefault.qubit.legacy
.Actual behavior
Consider the following circuit:
With
default.qubit
, it produces the expected results when taking the gradient:But with
default.qubit.legacy
,This error can be fixed quite easily by adding
to the end of
ControlledSequence.__init__()
, but when shots are added:We get non-sensible results. This issue also appears for
Reflection
,Qubitization
, andAmplitudeAmplification
Additional information
The issue is due to
default.qubit
has apreprocess
that happens before the ml boundary, decomposing the templates to lower level gates, but withdefault.qubit.legacy
, expansion happens ininner_execute
, which means that the ml boundary is dealing with the template operation itself, and they themselves are not properly differentiable.This bug is blocking #5791
Source code
No response
Tracebacks
No response
System information
Name: PennyLane Version: 0.37.0.dev0 Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network. Home-page: https://github.com/PennyLaneAI/pennylane Author: Author-email: License: Apache License 2.0 Location: /Users/astral.cai/Workspace/pennylane/venv/lib/python3.9/site-packages Editable project location: /Users/astral.cai/Workspace/pennylane Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions Required-by: PennyLane_Lightning Platform info: macOS-14.5-arm64-arm-64bit Python version: 3.9.19 Numpy version: 1.26.4 Scipy version: 1.11.4 Installed devices: - default.clifford (PennyLane-0.37.0.dev0) - default.gaussian (PennyLane-0.37.0.dev0) - default.mixed (PennyLane-0.37.0.dev0) - default.qubit (PennyLane-0.37.0.dev0) - default.qubit.autograd (PennyLane-0.37.0.dev0) - default.qubit.jax (PennyLane-0.37.0.dev0) - default.qubit.legacy (PennyLane-0.37.0.dev0) - default.qubit.tf (PennyLane-0.37.0.dev0) - default.qubit.torch (PennyLane-0.37.0.dev0) - default.qutrit (PennyLane-0.37.0.dev0) - default.qutrit.mixed (PennyLane-0.37.0.dev0) - null.qubit (PennyLane-0.37.0.dev0) - lightning.qubit (PennyLane-Lightning-0.36.0)
Existing GitHub issues
The text was updated successfully, but these errors were encountered: