Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try improving the compiler error messages when calling cudaq::sample with incorrect kernel arguments #827

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

1tnguyen
Copy link
Collaborator

Description

Although C++ concept generates much better error messages, it seems to be not as user-friendly as we want.
e.g., see https://gist.github.com/anthony-santana/d394888ad14853fe5825a59bd4d518f5

This PR attempted to address that:

  • Provide a 'catching' match (when the expected ValidArgumentsPassed failed) in order to customize the error message (via a static_assert message).

  • Construct the error message via compile-time (constexpr) code.

The error message will look like static assertion failed due to requirement 'InvalidArgs<cudaq::Msg<25>{"requires <double>, got <>"}>'.

…with incorrect kernel arguments

Although C++ concept much better error messages, it seems to be not as user-friendly as we want.

e.g., see https://gist.github.com/anthony-santana/d394888ad14853fe5825a59bd4d518f5

This PR attempted to address that:

- Provide a 'catching' match (when the expected `ValidArgumentsPassed` failed) in order to customize the error message (via static_assert message).

- Construct the error message via compile-time (constexpr) code.
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Oct 27, 2023
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Oct 27, 2023
@schweitzpgi
Copy link
Collaborator

I wonder if we can't use the concept framework, perhaps with some more descriptive names, to our advantage here.

Copy link

github-actions bot commented Nov 1, 2023

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 1, 2023
@1tnguyen
Copy link
Collaborator Author

1tnguyen commented Nov 1, 2023

I wonder if we can't use the concept framework, perhaps with some more descriptive names, to our advantage here.

I think we adopted concept in these sample and observe calls from the beginning to take advantage of better error messages like you said.

For example, the compiler error message shown in the snippet did refer to the concept SampleCallValid: e.g., ... does not satisfy 'SampleCallValid'.

Until a new C++ feature similar to this one becomes available, I think we'd need to do something like this PR to further customize the compiler error messages.

Copy link

github-actions bot commented Nov 2, 2023

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 2, 2023
Copy link

github-actions bot commented Nov 3, 2023

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants