Closed austingmhuang closed 4 months ago
[sc-62867]
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
5e11e3a
) to head (4ba38c2
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
With use_primitives being removed as a keyword and the device upgrading to PrimitivesV2 as a whole, this PR will likely be significantly affected by those changes. I am going to leave this PR open for now but this will be blocked until we remove all the non-Qiskit 1.0/V2Primitives functionality.
Closing this since the changes are now in #539
To explain this change, some context behind the bug is necessary. We were seeing a difference between running qml.sample() when use_primitives was set to True vs False. When use_primitives was set to True, we were getting a shape of (1, 1024) instead of the correct shape of (1024, ). At first glance it seems like this problem should be resolved in
execute
-> you can simply check the len of the result that's returned there and if it's 1, take the 0th element instead. Although obvious, surprisingly, doing this does not fix the bug.The root of the problem is actually in this
split_execution_types
function.When running
use_primitives = False
, you skipsplit_execution_types
, and therefore do not run this line of code. However, supposeresult = [1]
. Whenuse_primitives = True
andlen(result) == 1
, you will be going from[1] -> (1,)
, which is bad since pennylane devices will return1
instead. This is the source of the bug and it only occurs when a user sets use_primitives to false and has a circuit that only returns 1 measurement. (In other words, if the user had a circuit that returned multiple measurements, this bug would not occur).