Open WrathfulSpatula opened 4 months ago
Thank you for the feedback!
I agree the assertions are somewhat redundant, although I think removing the explicit shots parameter from the api functions would it make the api slighter more complicated. Somewhere (that is not code) we would have to document how to obtain the number of shots from the data buffer size, which are not necessarily identical. For samples
for example the total number of produced elements in the buffer will be n_wires * n_shots
. For counts
the data buffers are of size 2 ** n_wires
.
Issue description
As a general suggestion on your (C++ device back end) API, in
Catalyst::Runtime::QuantumDevice
, as someone implementing a simulator device back end over at pennylane-qrack, I notice that you require a "shots" parameter in certain methods that is redundant with the dimension required forDataView
instances. Immediately at the top of such methods, you make sure thatshots
is exactly the same as the size of theDataView
instance, and you raise exception if the two do not match.Given that the
DataView
must already have the same size as theshots
integer, why not remove theshots
parameter and simply consider it implied by the size of theDataView
? This way, there's never a case where it's necessary to reject on input validation.Source code and tracebacks
For example,
Instead, the signature could simply be like this: