Repository navigation
cuda.core: public API class naming audit (PEP 8 and consistency) #1950
Description
@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: LaunchConfig → LaunchOptions
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: GraphDef → GraphDefinition
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/*MemoryResourceOptionsfamily is consistently named. - The
*Nodesubclasses incuda.core.graphare consistently named. - The
*Errorexception classes consistently use theErrorsuffix. Event/EventOptions,Stream/StreamOptions,Program/ProgramOptions,Linker/LinkerOptionsall follow the same pairing pattern.
Recommended changes by priority
LaunchConfig→LaunchOptions— terminology inconsistency with the rest of the APIGraphDef→GraphDefinition— unusual abbreviation- Acronym capitalization in
cuda.core.system— 13 classes violate PEP 8's explicit acronym rule and are internally inconsistent withP2P/BAR1in the same module
Activity
mdboom commentedon Apr 20, 2026
Since many of the names in #3 come from the automatically-generated names in
cuda.bindings, fixing them would also require changes to the generator. We know automatic capitalization is a hard problem. I think it's not worth the trouble for those.leofang commentedon Apr 24, 2026
Hmmm, fixing cuda.core is all manuał work right? It's probably a good idea to do a sweep.
For cuda.bindings, well the ship has sailed and we can't break it for now. (If we want to break, though, I suppose we could use the escape hatch, by adding
GPUto the preprocess step ofcamel_to_snake?)leofang commentedon Apr 24, 2026
I like this. Need Andy's input.
I strongly prefer to not change. This is one of the few places where staying closer to the C counterpart (
CUlaunchConfig) is good.launchhas a special status anyway -- it's probably the only free function that we have in cuda.core?mdboom commentedon Apr 24, 2026
Most of these in #3 are enums in cuda_bindings that are just re-exported by cuda_core. We can re-export them under a different name, but it makes docs and
repra bit funny.leofang commentedon Apr 27, 2026
Spoke to @Andy-Jost about this. He's thinking to mark a few GraphDef APIs experimental. He can handle the renaming when he gets to this work.
Andy-Jost commentedon Apr 28, 2026
No concerns renaming
GraphDefRename GraphDef -> GraphDefinition and Condition -> GraphCondition (#…