Skip to content

cuda.core: public API class naming audit (PEP 8 and consistency) #1950

@mdboom

Description

@mdboom

@mdboom's commentary: This all seems pretty low stakes, but now is the time to address any inconsistencies before 1.0.0.

Summary

An audit of all public class names in cuda.core found three categories of naming inconsistency: a terminology mismatch ("Config" vs "Options"), one unusual abbreviation, and several PEP 8 acronym-capitalization violations in the cuda.core.system submodule.

Original prompt

Can you please look at all classes exposed in the public API of cuda_core. I want you to look just at the names of the classes, not any members or methods. Please make sure they are all PEP8 compliant and that the same words are used for the same concepts.


Findings

1. "Config" vs "Options" inconsistency

LaunchConfig is the only class that uses "Config" for a configuration/options object. Every other such class uses "Options":

Pattern-breaker Consistent peers
LaunchConfig EventOptions, LinkerOptions, StreamOptions, ProgramOptions, DeviceMemoryResourceOptions, ManagedMemoryResourceOptions, PinnedMemoryResourceOptions, VirtualMemoryResourceOptions, TensorMapDescriptorOptions, GraphAllocOptions, GraphCompleteOptions, GraphDebugPrintOptions

Suggestion: LaunchConfigLaunchOptions

2. GraphDef abbreviation

GraphDef abbreviates "Definition" while the rest of the API spells words out (e.g. TensorMapDescriptor, not TensorMapDesc; ConditionalNode, not CondNode). The AllocNode / GraphAllocOptions abbreviations are defensible since "alloc/free" are standard CUDA/C terms, but GraphDef is less conventional.

Suggestion: GraphDefGraphDefinition

3. Acronym capitalization (PEP 8 violation in cuda.core.system)

PEP 8 says: "When using abbreviations in CapWords, capitalize all the letters of the abbreviation. Thus HTTPServerError is better than HttpServerError."

The system module is internally inconsistent — P2P and BAR1 are correctly all-caps, while other acronyms are treated as regular CamelCase words:

Current name PEP 8 name Acronym
GpuDynamicPstatesInfo GPUDynamicPStatesInfo GPU, PStates
GpuDynamicPstatesUtilization GPUDynamicPStatesUtilization GPU, PStates
GpuP2PCapsIndex GPUP2PCapsIndex GPU
GpuP2PStatus GPUP2PStatus GPU
GpuTopologyLevel GPUTopologyLevel GPU
Pstates PStates PStates
PcieUtilCounter PCIeUtilCounter PCIe
PciInfo PCIInfo PCI
GpuIsLostError GPUIsLostError GPU
GpuNotFoundError GPUNotFoundError GPU
VgpuEccNotSupportedError VGPUECCNotSupportedError VGPU, ECC
IrqIssueError IRQIssueError IRQ
LibRmVersionMismatchError LibRMVersionMismatchError RM

Note: BAR1MemoryInfo, GpuP2PCapsIndex (the P2P part), and GpuP2PStatus (the P2P part) already correctly capitalize their acronyms, making the inconsistency with Gpu, Pci, etc. more visible.


What already looks good

  • All class names use CamelCase (PEP 8 compliant).
  • The *MemoryResource / *MemoryResourceOptions family is consistently named.
  • The *Node subclasses in cuda.core.graph are consistently named.
  • The *Error exception classes consistently use the Error suffix.
  • Event/EventOptions, Stream/StreamOptions, Program/ProgramOptions, Linker/LinkerOptions all follow the same pairing pattern.

Recommended changes by priority

  1. LaunchConfigLaunchOptions — terminology inconsistency with the rest of the API
  2. GraphDefGraphDefinition — unusual abbreviation
  3. Acronym capitalization in cuda.core.system — 13 classes violate PEP 8's explicit acronym rule and are internally inconsistent with P2P/BAR1 in the same module

Metadata

Metadata

Assignees

No one assigned

    Labels

    cuda.coreEverything related to the cuda.core moduleenhancementAny code-related improvements

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions