Created
October 19, 2023 19:33
-
-
Save anthony-santana/d394888ad14853fe5825a59bd4d518f5 to your computer and use it in GitHub Desktop.
A10: Better error messages for incorrect argument signature to sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Take the following kernel and sample call | |
``` | |
int main() { | |
auto [kernel, value] = cudaq::make_kernel<float>(); | |
auto q = kernel.qalloc(); | |
kernel.x(q); | |
// Calling sample but not passing along a concrete argument for `value` | |
auto result = cudaq::sample(kernel); | |
result.dump(); | |
} | |
``` | |
Returns the following error (truncated): | |
``` | |
new_test.cpp:20:17: error: no matching function for call to 'sample' | |
auto result = cudaq::sample(kernel); | |
^~~~~~~~~~~~~ | |
/usr/local/cudaq/include/cudaq/algorithms/sample.h:199:15: note: candidate template ignored: constraints not satisfied [with QuantumKernel = std::tuple_element<0, cudaq::kernel_builder<float>>::type &, Args = <>] | |
sample_result sample(QuantumKernel &&kernel, Args &&...args) { | |
^ | |
/usr/local/cudaq/include/cudaq/algorithms/sample.h:198:12: note: because 'cudaq::kernel_builder<float> &' does not satisfy 'SampleCallValid' | |
requires SampleCallValid<QuantumKernel, Args...> | |
... | |
``` | |
I have yet to check the error on observe call, or on non-builder kernels, but I'd expect a message along the lines of "Your kernel accepts {1} arguments but {0} were provided to cudaq::sample" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment