-
Notifications
You must be signed in to change notification settings - Fork 1
Upgrade to Pennylane ^0.41.x #174
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Melvin Strobl <[email protected]>
Signed-off-by: Melvin Strobl <[email protected]>
Signed-off-by: Melvin Strobl <[email protected]>
Signed-off-by: Melvin Strobl <[email protected]>
Brief update; RZ/CRZ implementation validated; the error happens around the following lines inside
Because |
After some further digging; adjusting this part of the code in such a way that it works for our case will most likely break other stuff as it's a quite fundamental part of the code.
This will treat RZ/CRZ as standard gates und uses their matrix representation instead of going via eigenvalues. Minimal (failing) example for unpatched version: import pennylane as qml
@qml.qnode(device=qml.device("default.mixed", wires=1))
def circuit(theta):
qml.RZ(theta, wires=0)
return qml.density_matrix(wires=[0])
circuit(np.array([1,2])) with the expected result being
(2x zero state). Thanks @majafranz for confirming this! |
See corresponding Pennylane Issue for further updates.. Note that while the patch suggested resolves the RZ/CRZ problematic, one still has to apply the changes suggested in this PR as well! |
Issue resolved by Pennylane. Let's wait for the next release |
PR on the journey of upgrading Pennylane (thus resolving #171 as well); Apparently there were some changes with the RZ and CRZ gates from 0.40 to 0.42 (0.41 affected as well). I extended the test
model/test_ batching
such that all ansatzes are being checked now.The with ansatzes featuring RZ or CRZ gates, an error similar to
cannot reshape array of size X into shape (Y,)
occurs.When changing qml.RZ to e.g. qml.RY and CRZ to CRY in our Gates class, everything runs smoothly (except of course all the other tests that actually check on the output of the model).
I tried the following already in the RZ gates class:
and
in
compute_matrix
andcompute_eigvals
respectively, but without success.Comparing to a RX or RY gate did not show any major differences, so I suspect that the reason for the different behavior is somewhere deeper.