Open WrathfulSpatula opened 4 weeks ago
Hi @WrathfulSpatula , I've looked into this and found a couple of reasons why this is not working.
dynamic_one_shot
, to store the executable tape in a dense format, we only give one tape to the device, and it is the device's responsibility to loop over the number of shots if it sees "one-shot". We should've documented this better, and will include that as part of the fix that is needed on our side. But, the key takeaway is that the pennylane.qrack
backend needs to implement the ability to loop over the number of shots if one-shot
is being used. You can find a reference here for how we implement this in PennyLane. simulate_one_shot_native_mcm
is the function used for single-shot execution.dynamic_one_shot
only transforms the original circuit if it has at least one mid-circuit measurement and doesn't transform the circuit if that's not the case. This was an optimization we added as until now, mid-circuit measurements have been the only use-case for us where single-shot execution was useful. We need to update this on our end so that any circuit can be transformed with dynamic_one_shot
.
Expected behavior
(I develop the
pennylane-qrack
custom back end.) When we run the ZNE tutorial being developed by Unitary Fund and Catalyst, asmcm_mode="one-shot"
is used (for "weak simulation condition," for noise simulation), we expect that if we request 1,000 shots, then PennyLane should iterate the process 1,000 times of running the original circuit on the back end and requesting 1 measurement shot output at a time.Actual behavior
If I run the tutorial with the correct setting and this branch that prints the number of shots received by the back end per request for measurement samples, then the extra
print()
statement shows that PennyLane is requesting 1,000 shots at once for a single execution of the original circuit on the back end, despitemcm_mode="one-shot"
.Additional information
It's important that the circuit is run top-to-bottom for every single individual shot, because Qrack introduces physically-realistic noise via stochastic Pauli noise, such that the circuit actually ends up with hidden gates inserted stochastically by the back end on every single separate shot, modeling physical noise, whereas requesting 1,000 shots from the back end at once gives every single shot the exact same (random) bit-flip and phase-flip errors, which is not the intent or a physically-accurate noise model.
Source code
Tracebacks
No response
System information
Existing GitHub issues