Skip to content

cuda.core: add docstrings to Host properties and public StrEnum types#2134

Open
aryanputta wants to merge 3 commits into
NVIDIA:mainfrom
aryanputta:docs/typing-strenum-docstrings
Open

cuda.core: add docstrings to Host properties and public StrEnum types#2134
aryanputta wants to merge 3 commits into
NVIDIA:mainfrom
aryanputta:docs/typing-strenum-docstrings

Conversation

@aryanputta
Copy link
Copy Markdown
Contributor

@aryanputta aryanputta commented May 22, 2026

Summary

Contributes to the doc-finalization step of #2131.

Two doc-only changes to cuda.core, touching no logic:

cuda/core/_host.py — Host property docstrings

Host is a new 1.1.0 API (release notes: #2131 checklist item "Finalize the doc update"). The class-level docstring is already complete, but numa_id and is_numa_current had no docstrings, leaving them blank in generated API docs and help():

@property
def numa_id(self) -> int | None:
    """NUMA node ID, or ``None`` if not pinned to a specific NUMA node."""

@property
def is_numa_current(self) -> bool:
    """``True`` if this ``Host`` represents the calling thread's NUMA node (constructed via :meth:`numa_current`)."""

cuda/core/typing.py — StrEnum class docstrings

All 12 public StrEnum subclasses (SourceCodeType, ObjectCodeFormatType, CompilerBackendType, PCHStatusType, GraphConditionalType, GraphMemoryType, ManagedMemoryLocationType, VirtualMemoryHandleType, VirtualMemoryLocationType, VirtualMemoryGranularityType, VirtualMemoryAccessType, VirtualMemoryAllocationType) previously had zero class-level docstrings. Each now has a short description and a one-liner per member so help() and Sphinx show meaningful output.

Checklist

  • cuda.core only — no cuda.bindings files touched
  • No logic changes — docstrings only
  • Consistent with existing single-line property docstring style (Host.numa_current, ManagedBuffer methods)

Each StrEnum class in cuda.core.typing now has a class-level docstring
that states its purpose and briefly describes every member value.
Sphinx and help() now show meaningful descriptions for CompilerBackendType,
GraphConditionalType, GraphMemoryType, ManagedMemoryLocationType,
ObjectCodeFormatType, PCHStatusType, SourceCodeType, VirtualMemory*.

No logic changes.
…urrent

Host is a new 1.1.0 API. The class-level docstring is complete but the two
public properties had no docstrings, leaving them blank in generated API docs
and in help().
@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot Bot commented May 22, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label May 22, 2026
@aryanputta
Copy link
Copy Markdown
Contributor Author

@leofang @rwgk — flagging this for your awareness in the context of #2131.

This is a doc-only contribution to cuda.core (no cuda.bindings files touched — I know external contributions there aren't permitted). Both changes are pure docstring additions, zero logic:

  • _host.py: Host.numa_id and Host.is_numa_current were undocumented. Since Host is new in 1.1.0 and explicitly in the release notes, having blank property docs felt like the most directly useful thing I could help with for the doc-finalization step.
  • typing.py: added class-level docstrings to all 11 public StrEnum types so help() and Sphinx show something meaningful.

Happy to split into two PRs if that's easier to review, or adjust wording on any of the docstrings.

@leofang leofang added documentation Improvements or additions to documentation P1 Medium priority - Should do labels May 29, 2026
@leofang leofang added this to the cuda.core v1.1.0 milestone May 29, 2026
@leofang leofang requested a review from Andy-Jost May 29, 2026 15:11
@aryanputta
Copy link
Copy Markdown
Contributor Author

aryanputta commented May 29, 2026

@Andy-Jost — one style question before this is review-ready.

For the StrEnum classes, I went with per-member descriptions inside the class docstring body, e.g.:

class ObjectCodeFormatType(StrEnum):
    """Output format produced by :meth:`~cuda.core.Program.compile`.

    ``PTX`` — PTX assembly text.
    ``CUBIN`` — device-native CUDA binary.
    ``LTOIR`` — LTO (link-time optimization) IR for later linking.
    ``FATBIN`` — fat binary bundling multiple device images.
    ``OBJECT`` — relocatable device object.
    ``LIBRARY`` — device code library.
    """

The question is whether that level of detail is right for members that are fairly self-explanatory from their name and string value (PTX = "ptx" probably doesn't need "PTX assembly text"). Two options I see:

A) Keep per-member descriptions i tried to keep it consistent across all 11 types, useful in help() output, and makes Sphinx more readable without needing to cross-reference the CUDA driver docs.

B) Class-level summary only, drop the member list for this i led to a shorter approach which avoids redundancy for obvious members. Something like:

class ObjectCodeFormatType(StrEnum):
    """Output format produced by :meth:`~cuda.core.Program.compile`.

    Accepted values: ``PTX``, ``CUBIN``, ``LTOIR``, ``FATBIN``, ``OBJECT``, ``LIBRARY``.
    """

Happy to go either way — just want to match the preferred convention here before this gets reviewed.

- is_numa_current: lead with return type (``True`` if ...) to match
  bool-property docstring convention; keep :meth:`numa_current` cross-ref
- WIN32_KMT: drop "D3DKMT" (DirectX-specific); CU_MEM_HANDLE_TYPE_WIN32_KMT
  maps to a general WDDM kernel-mode handle, not a D3D handle
@aryanputta aryanputta force-pushed the docs/typing-strenum-docstrings branch from 8d2960a to 88e5576 Compare May 29, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module documentation Improvements or additions to documentation P1 Medium priority - Should do

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants