Skip to content

Reject opt_level=None when the kernel is defined - #115

Open
0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:opt-level-reject-none
Open

0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:opt-level-reject-none

Conversation

@0z5a

@0z5a 0z5a commented Nov 3, 2026

Copy link
Copy Markdown

Description

ct.kernel(opt_level=None) (or ct.ByTarget(sm_90=None) for opt_level) passes validation, since _validate_opt_level skips None and the kernel signature lists it, but opt_level_for_target asserts an int. The kernel is accepted and then fails with a bare AssertionError the first time the cubin is compiled.

This PR requires an integer in [0, 3] at definition time (also for ByTarget values and defaults) and drops None from the signature.

Checked on GH200 (CUDA 13.2):

  • main: both forms are accepted and the launch fails with AssertionError().
  • this branch: both forms raise ValueError: opt_level should be an integer in [0, 3], got None at definition.

The new test cases (None, -1, 4, ByTarget(sm_100=None), ByTarget(default=None)) pass against the built extension. I couldn't run the whole of test_compiler_options.py because no GPU was free.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

_validate_opt_level let None through (also inside ByTarget), and the
kernel signature advertised None, but opt_level_for_target asserts an
int. So ct.kernel(opt_level=None) or ByTarget(sm_90=None) was accepted
and then failed with a bare AssertionError when the cubin was compiled.
Require an integer in [0, 3] and drop None from the signature.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
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.

1 participant