catalyst
catalyst copied to clipboard
Consider eliminating redundant "shots" parameters in device back end API
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 for DataView instances. Immediately at the top of such methods, you make sure that shots is exactly the same as the size of the DataView instance, and you raise exception if the two do not match.
Given that the DataView must already have the same size as the shots integer, why not remove the shots parameter and simply consider it implied by the size of the DataView? This way, there's never a case where it's necessary to reject on input validation.
Source code and tracebacks
For example,
void Sample(DataView<double, 2> &samples, size_t shots) override
{
RT_FAIL_IF(samples.size() != shots, "Invalid size for the pre-allocated samples");
[...]
}
Instead, the signature could simply be like this:
void Sample(DataView<double, 2> &samples) override
{
// "shots" parameter value is implied by just "samples.size()."
[...]
}