pennylane
pennylane copied to clipboard
Remove dtype promotion in pauli rep of scalar products with tensorflow
fix for https://github.com/PennyLaneAI/pennylane/issues/5245
[sc-57300]
Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md
with:
- A one-to-two sentence description of the change. You may include a small working example for new features.
- A link back to this PR.
- Your name (or GitHub username) in the contributors section.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.67%. Comparing base (
d2568ad
) to head (49d9553
). Report is 1 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #5246 +/- ##
==========================================
- Coverage 99.68% 99.67% -0.01%
==========================================
Files 399 399
Lines 36871 36583 -288
==========================================
- Hits 36754 36465 -289
- Misses 117 118 +1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@Jaybsoni do you remember why this was added in the first place? You first made a change here, then I had some issue so I just explicitly set it to complex128. if there's no hidden issue with this removal, then lgtm! just wanna make sure with the experts here.
To gather some context:
- this is the conversation regarding why I changed it to be explicit
- #4249 fixed a related issue in the past. TF is delicate, but I assume we have the appropriate tests already in place, so the green CI is easing my mind a bit
I also thought this was done deliberately to fix errors rising due to tensorflow conversion issues. But tests seem to be passing so I guess we're ok?
I think hitting a problem with dtypes such as
import tensorflow as tf
qml.operation.enable_new_opmath()
a = tf.constant(0.5)
b = tf.constant(0.5j)
x = qml.s_prod(a, X(0))
y = qml.s_prod(b, Y(0))
res = x @ y
TypeError: Cannot convert 1j to EagerTensor of dtype float
when using tensorflow is a user error because with tf one needs to set the correct dtypes to start with:
import tensorflow as tf
qml.operation.enable_new_opmath()
a = tf.constant(0.5, dtype=tf.complex128)
b = tf.constant(0.5j)
x = qml.s_prod(a, X(0))
y = qml.s_prod(b, Y(0))
res = x @ y
(this was the only test I had to change to make this fix work)
In general, we shouldnt force the dtype promotion wherever possible I'd say
Can I merge to master right now or should I wait for decoupling the release candidate branch?