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] Confusing behavior with the wires
argument of qml.probs
#3741
Comments
Hi @bdoolittle, thanks for opening this issue! @timmysilv will take a look at it. |
EDIT: I've changed the wire labels to be letters to make this clearer Hi @bdoolittle, I actually had the same confusion very recently! First, the device is created with Then, when
lmk if I can clarify any of those details! |
sat with this issue a bit, chatted with @josh146, and we agree that it is in fact a bug. Now that I've spelled it out, I can say that the problem is with the first "thought": |
Hi @bdoolittle - my linked PR auto-closed this, and should have fixed |
Hey @bdoolittle! I was wondering if you could pass on some feedback as to how you encountered this edge case? E.g., was there a workflow where you needed non-consecutive ordered device wires? This will help in understanding how to improve how PL works with non-ordered wires (@trbromley) |
Hey @josh146 , I've built a pennylane extension that takes a description of a quantum networking system and builds a quantum circuit (see https://github.com/ChitambarLab/qNetVO). On the output, it is often desirable to incorporate post processing maps. The wires in the network ansatz circuit are not always in a convenient ordering for applying the postprocessing maps. Ideally, you'd want to permute the wires such that when you measure the probabilities, the postprocessing maps can easily be combined as a tensor product and applied to the output probabilities. There are plenty of work arounds for the problem, but the point is that when I ask pennylane to give me probabilities in a particular wiring order, that pennylane ought to deliver me that ordering. |
Expected behavior
Consider a case where where a device's wires are ordered as
[2,0,1]
and we'd like to get the probabilities associated with these wires in the order[0,1,2]
. That is, if aqml.PauliX(wires=[0])
operation is applied, I would expectqml.probs(wires=[0,1,2])
to return the probabilities[0,0,0,0,1,0,0,0]
because0
is the ordered as the most significant bit in the wire ordering.In the two following code snippets, I expect the
[0,0,0,0,1,0,0,0]
probability vector to be returned whenqml.PauliX
is applied to wire[0]
.dev.wires
:I believe that this expectation should hold because I specify that the
qml.PauliX
operates upon the[0]
wire and thatqml.probs(wires=[0,1,2])
should return the probabilities ordered with the[0]
wire being the most significant bit.Actual behavior
Case 1.
Returns:
Case 2:
Returns:
Problem
In both cases, it appears that the
qml.PauliX
operation is applied to wire[2]
instead of wire[0]
like I intended.Additional information
No response
Source code
No response
Tracebacks
No response
System information
Existing GitHub issues
The text was updated successfully, but these errors were encountered: