-
Notifications
You must be signed in to change notification settings - Fork 615
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
Fix wires
object handling in Sum.terms
method
#6750
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6750 +/- ##
=======================================
Coverage 99.60% 99.60%
=======================================
Files 476 476
Lines 45210 45210
=======================================
Hits 45033 45033
Misses 177 177 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a small test that makes use of the wire info of Identity? I feel that without an explicit example people would always wonder 'why do we need the wires of an Identity'.
Hmm, this might have some hidden side-effects that aren't being caught in the test suite. import pennylane as qml
time, n, order = (4.2, 10, 4)
time = qml.numpy.array(time)
hamiltonian = qml.dot(
[1, 1], [qml.I([0,1]), qml.PauliX(0)]
)
coeffs, ops = hamiltonian.terms()
@qml.qnode(qml.device("default.qubit"), diff_method="backprop")
def circ_bp(coeffs, time):
with qml.queuing.QueuingManager.stop_recording():
hamiltonian = qml.dot(coeffs, ops)
qml.TrotterProduct(hamiltonian, time, n, order)
return qml.probs()
>>> qml.jacobian(circ_bp)(coeffs, time)
[-0.85459891 0. 0.85459891 0. ]
# [-0.85459891 0.85459891] on master branch |
@andrijapau I actually think that the new behaviour is correct. The hamiltonian you created acts on 2 wires, so the output of |
So the wire info of Identity ops grant us the ability to extend the range of other local ops? |
What do you mean by this? |
Oh nm I'm just thinking that previous results are only showing the non-Identity operators' scope but the new ones reflect a larger scope extended by the Identity, which is actually logically correct here |
Context:
Prior to this PR, the
wires
information forIdentity
was not being retained correctly,Description of the Change:
The origin of the bug is that
wire_order
inPauliWord.operation
was not being updated by the operators currentwires
set. This is strictly relevant to theIdentity
operator as it makes use of the argument.Benefits:
Identity.wires
are now properly tracked when usingSum.terms
.Possible Drawbacks: None
[sc-81355]