-
Notifications
You must be signed in to change notification settings - Fork 604
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] Unable to calculate depth of circuit with same operation used twice #4406
Comments
I'm playing around with Pennylane and thought I could try to tackle the issue as a part of the learning process if you don't mind. So far upon investigation it seems that the problem occurs because the operators passed to the For example if you do something like this then you would get back the expected result:
There are quite a few things that seem to be going wrong in the code when the same object is used:
I can see a few possible solutions and this is where I would need some feedback:
|
Thanks for the excellent analysis @che-burashco .
Queuing, how we capture the contents of a quantum function, still requires operator to be a unique instance, but we're pushing to loosen that restriction in internal code. We just haven't loosened the restriction in Option 1 (copying duplicate operators) would solve the problem, but we would end up doing a bunch of additional work (copying things) we don't necessarily want to do. I definitely favour Option 2, and that was exactly what I was thinking to solve the problem whenever I had time. Instead of having each operator be a node, in the |
Thanks for a quick reply @albi3ro. I can take a stab at implementing the second approach this week if there are no objections |
No objections. That'd be great :) We might actually be able to just store the Just a general heads up that we are going to be changing the definitions for |
This issue has come up again, in the example of:
We may finally need to address this issue. |
Expected behavior
I expect the below code to output 2.
Actual behavior
sort encounters a cycle. Traceback below.
Additional information
PR #4398 does not fix the problem.
Source code
op = qml.PauliX(0) tape = qml.tape.QuantumScript([op, op], [qml.expval(qml.PauliZ(0))]) tape.graph.get_depth()
Tracebacks
System information
Existing GitHub issues
The text was updated successfully, but these errors were encountered: