You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[DOC]: cuda.core docs/type hints understate option params since dict is accepted at runtime but not documented #2248
Is this for new documentation, or an update to existing docs?
Update
Describe the incorrect/future/missing documentation
Several cuda.core public APIs document their options/config parameter as accepting only a dataclass (or None), but at runtime these parameters also accept a plain dict since the argument is normalized by check_or_create_options, converting a dict into the dataclass via cls(**options).
As a result, the documented signatures and the shipped .pyi type stubs are narrower than the actual accepted types.
This also seems inconsistent with PinnedMemoryResource.__init__, which already annotates its parameter as PinnedMemoryResourceOptions | dict[str, object] | None, so the convention for accepting a dict already seems to exist in the codebase.
If this is a correction, please provide a link to the incorrect documentation. If this is a new documentation request, please link to where you have looked.
changed the title [-][DOC]:[/-][+][DOC]: cuda.core docs/type hints understate option params since dict is accepted at runtime but not documented[/+]on Jun 25, 2026
@leofang thanks for the comment! In nvmath we recently added hints for dict because the docstrings explicitly state a dict is accepted. My rationale for this: if the docstrings say that but the syntax/signature does not show it, it could seem to a user as if the developers forgot to update either one. Since here in cuda core the docstrings do not explicitly mention a dict, your comment "I really want users to build and pass an option instance," makes sense.
This being said, PinnedMemoryResource.__init__ accepts a hint so maybe that could be removed too?
Activity
[-][DOC]:[/-][+][DOC]: cuda.core docs/type hints understate option params since dict is accepted at runtime but not documented[/+]leofang commentedon Jun 27, 2026
Isn't this just a side effect of options being dataclasses (by design)? I see we also do the same thing in nvmath-python? 😉
https://github.com/NVIDIA/nvmath-python/blob/48f5b643c8b7c04f8be1745b9b700eae17af7319/nvmath/fft/fft.py#L2813
TBH accepting dict is a convenient feature but I really want users to build and pass an option instance, so documenting that dict is also accepted not only makes it noisy but also defeats the purpose.
fnrizzi commentedon Jun 29, 2026
@leofang thanks for the comment! In nvmath we recently added hints for dict because the docstrings explicitly state a dict is accepted. My rationale for this: if the docstrings say that but the syntax/signature does not show it, it could seem to a user as if the developers forgot to update either one. Since here in cuda core the docstrings do not explicitly mention a dict, your comment "I really want users to build and pass an option instance," makes sense.
This being said,
PinnedMemoryResource.__init__accepts a hint so maybe that could be removed too?leofang commentedon Jun 30, 2026
Might be a good idea to align with nvmath-python. I will raise this in our team sync.
Yeah depending on our decision we should either remove it or apply what you suggested to other option classes.