Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cuda_core/cuda/core/_program.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class ProgramOptions:
----------
name : str, optional
Name of the program. If the compilation succeeds, the name is passed down to the generated :class:`ObjectCode`.
When set to `None`, ``"default_program"`` is used.
arch : str, optional
Pass the SM architecture value, such as ``sm_<CC>`` (for generating CUBIN) or
``compute_<CC>`` (for generating PTX). If not provided, the current device's architecture
Expand Down
4 changes: 4 additions & 0 deletions cuda_core/cuda/core/_program.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ class ProgramOptions:
----------
name : str, optional
Name of the program. If the compilation succeeds, the name is passed down to the generated :class:`ObjectCode`.
When set to `None`, ``"default_program"`` is used.
arch : str, optional
Pass the SM architecture value, such as ``sm_<CC>`` (for generating CUBIN) or
``compute_<CC>`` (for generating PTX). If not provided, the current device's architecture
Expand Down Expand Up @@ -523,6 +524,9 @@ class ProgramOptions:
numba_debug: bool | None = None # Custom option for Numba debugging

def __post_init__(self) -> None:
# Set name to default if not provided
if self.name is None:
self.name = "default_program"
self._name = self.name.encode()
# Set arch to default if not provided
if self.arch is None:
Expand Down
6 changes: 6 additions & 0 deletions cuda_core/docs/source/release/1.2.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ Fixes and enhancements
closes `#2408 <https://github.com/NVIDIA/cuda-python/issues/2408>`__)
>>>>>>> origin/main

- :class:`ProgramOptions` now accepts ``name=None`` and falls back to the
documented default ``"default_program"``. Previously the annotated and
documented ``None`` raised ``AttributeError`` during construction.
(`#2517 <https://github.com/NVIDIA/cuda-python/pull/2517>`__,
closes `#2516 <https://github.com/NVIDIA/cuda-python/issues/2516>`__)

Deprecation Notices
-------------------

Expand Down
10 changes: 10 additions & 0 deletions cuda_core/tests/test_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,16 @@ def test_program_init_invalid_code_format():
Program(code, "c++")


# arch is passed explicitly so the current device is not queried.
@pytest.mark.agent_authored(model="claude-opus-5")
@pytest.mark.parametrize("name", [None, "my_program"])
def test_program_options_name_accepts_none(name):
options = ProgramOptions(name=name, arch="sm_90")
expected = "default_program" if name is None else name
assert options.name == expected
assert options._name == expected.encode()


# This is tested against the current device's arch
def test_program_compile_valid_target_type(init_cuda):
code = 'extern "C" __global__ void my_kernel() {}'
Expand Down
Loading