Repository navigation
cuda.core: method/member/property naming audit #1945
Description
Summary
This is an audit of method/member/property naming in the cuda_core API. (A subset of the larger audit work in #1919).
This is a bot-generated list, some of it good, some of it nonsense, and some of it requires some judgement calls.
Instructions for readers of this issue:
- Let's discuss in the comments below
- Once things have consensus, I will mark them with a ✔️ or ❌. I have taken the liberty of applying my own judgement as a first pass
- When the change has been merged, the checkbox will get checked
Based on this prompt:
I want to audit the naming of all members of every public class in cuda_core. You can ignore the private classes, I only care about properties and methods exposed through the public API.
- Check for PEP8 compliance
- Properties should be nouns
- Methods should be verbs
- Identify methods that could be properties (i.e. take no arguments and do minimal calculation)
- Check for any naming inconsistencies, such as when different english words or abbreviation forms are used for the same concept or datatype
- Make sure conceptual method pairs are matching, e.g. add/remove, get/set, create/delete
Methods that could be properties
These take no arguments and return a value. Converting to properties would match existing patterns.
- ✔️
Buffer.get_ipc_descriptor()→ propertyipc_descriptorCc: @Andy-Jost - ✔️
Event.get_ipc_descriptor()→ propertyipc_descriptorCc: @Andy-Jost - ✔️
DeviceMemoryResource.get_allocation_handle()→ propertyallocation_handleCc: @leofang - ✔️
PinnedMemoryResource.get_allocation_handle()→ propertyallocation_handleCc: @leofang - ❌
Linker.get_error_log()→ propertyerror_log - ❌
Linker.get_info_log()→ propertyinfo_log - ❌
GraphDef.nodes()→ propertynodesCc: @Andy-Jost - ❌
GraphDef.edges()→ propertyedgesCc: @Andy-Jost
system subpackage — no-arg methods that could be properties
- ✔️
system.Device.get_auto_boosted_clocks_enabled()→ property - ✔️
system.Device.get_current_clock_event_reasons()→ property - ✔️
system.Device.get_supported_clock_event_reasons()→ property - ❌
system.Device.get_supported_event_types()→ property - ✔️
system.Device.get_supported_pstates()→ property - ✔️
system.PciInfo.get_pcie_replay_counter()→ property - ✔️
system.PciInfo.get_max_pcie_link_generation()→ property - ✔️
system.PciInfo.get_gpu_max_pcie_link_generation()→ property - ✔️
system.PciInfo.get_max_pcie_link_width()→ property - ✔️
system.PciInfo.get_current_pcie_link_generation()→ property - ✔️
system.PciInfo.get_current_pcie_link_width()→ property
Noun-based methods (should be verb-phrased)
Methods named as nouns rather than verbs, making them look like properties.
cuda.core
Cc: @Andy-Jost
(See comment for KernelAttributes changes)
- ✔️
KernelAttributes.max_threads_per_block(device_id)— noun phrase (takes param so can't be property; considerget_prefix) - ✔️
KernelAttributes.shared_size_bytes(device_id)— same - ✔️
KernelAttributes.const_size_bytes(device_id)— same - ✔️
KernelAttributes.local_size_bytes(device_id)— same - ✔️
KernelAttributes.num_regs(device_id)— same - ✔️
KernelAttributes.ptx_version(device_id)— same - ✔️
KernelAttributes.binary_version(device_id)— same - ✔️
KernelAttributes.cache_mode_ca(device_id)— same - ✔️
KernelAttributes.max_dynamic_shared_size_bytes(device_id)— same - ✔️
KernelAttributes.preferred_shared_memory_carveout(device_id)— same - ✔️
KernelAttributes.cluster_size_must_be_set(device_id)— same - ✔️
KernelAttributes.required_cluster_width(device_id)— same - ✔️
KernelAttributes.required_cluster_height(device_id)— same - ✔️
KernelAttributes.required_cluster_depth(device_id)— same - ✔️
KernelAttributes.non_portable_cluster_size_allowed(device_id)— same - ✔️
KernelAttributes.cluster_scheduling_policy_preference(device_id)— same - ❌
KernelOccupancy.max_active_blocks_per_multiprocessor()— noun phrase - ❌
KernelOccupancy.max_potential_block_size()— noun phrase - ❌
KernelOccupancy.available_dynamic_shared_memory_per_block()— noun phrase - ❌
KernelOccupancy.max_potential_cluster_size()— noun phrase - ❌
KernelOccupancy.max_active_clusters()— noun phrase - ❌
GraphDef.empty()/GraphNode.empty()— adjective, not verb; considercreate_empty_node()oradd_empty()
cuda.core.system
- ✔️
system.Device.clock(clock_type)— noun; considerget_clock_info() - ✔️
system.Device.fan(fan)— noun; considerget_fan_info() - ✔️
system.Temperature.sensor(sensor)— noun; considerget_sensor_reading() - ✔️
system.Temperature.threshold(type)— noun; considerget_threshold() - ✔️
system.Temperature.thermal_settings(idx)— noun phrase; considerget_thermal_settings()
PEP 8 / abbreviation violations
- ❌
Stream.is_nonblocking→is_non_blocking(PEP 8 snake_case word boundary) - ❌
GraphNode.pred/GraphNode.succ→predecessors/successors - ❌
AllocNode.dptr/FreeNode.dptr/MemsetNode.dptr→device_pointerorpointer - ❌
AllocNode.bytesize→byte_sizeorsize - ❌
ConditionalNode.cond_type→condition_type - ✔️
HostCallbackNode.callback_fn→callback - ❌
LaunchConfig.shmem_size→shared_memory_size - ❌
GraphBuilder.if_cond()/GraphDef.if_cond()/GraphNode.if_cond()→if_condition() - ❌
GpuDynamicPstatesUtilization.inc_threshold/dec_threshold→increase_threshold/decrease_threshold - ❌
FanInfo.speed_rpm→speed_in_rpm(match "units in name" pattern) - ❌
InforomInfo.bbx_flush_time→blackbox_flush_time
Naming inconsistencies across the API
close() vs destroy()
Every class uses close() for resource cleanup (Buffer, Stream, Event, Program, Linker, Graph, GraphBuilder, GraphicsResource, etc.) except:
- ❌
GraphNode.destroy()— sole exception; should beclose()for consistency
allocate()/deallocate() vs alloc()/free()
MemoryResource, Device, _MemPool, GraphMemoryResource all use allocate()/deallocate(), but:
Cc: @Andy-Jost
- ✔️
GraphDef.alloc()→allocate()for consistency - ✔️
GraphDef.free()→deallocate()for consistency - ✔️
GraphNode.alloc()→allocate()for consistency - ✔️
GraphNode.free()→deallocate()for consistency
as_ vs to_ conversion prefix
- ❌
StridedMemoryView.as_tensor_map()usesas_whileDevice.to_system_device()/system.Device.to_cuda_device()useto_— pick one convention
Shared memory naming inconsistency
Three different naming patterns for the same concept:
- ❌
LaunchConfig.shmem_sizevsKernelAttributes.shared_size_bytes/max_dynamic_shared_size_bytesvsDeviceProperties.max_shared_memory_per_block— unify naming
if_cond abbreviation vs full words elsewhere
Cc: @Andy-Jost
(See comment for details)
- ✔️
GraphBuilder.create_conditional_handle()(full) alongsideGraphBuilder.if_cond()(abbreviated) — inconsistent - ✔️
GraphDef.create_condition()(full) alongsideGraphDef.if_cond()(abbreviated) — inconsistent
add_child() vs embed()
Cc: @Andy-Jost
- ✔️
GraphBuilder.add_child()vsGraphDef.embed()— same concept (embed a child graph) with different names across the two graph-building interfaces (embed)
record_event()/wait_event() vs record()/wait()
Cc: @Andy-Jost
- ✔️
GraphDef.record_event()/GraphDef.wait_event()include type name "event", whileStream.record()/Stream.wait()drop it — inconsistent (record/wait)
FanInfo.set_default_fan_speed()
- ✔️ Redundant "fan" — already on a
FanInfoobject; considerreset_speed()orset_default_speed()
Mismatched conceptual pairs
- ❌
get_ipc_descriptor()/from_ipc_descriptor()—get_doesn't pair withfrom_; considerexport_ipc()/from_ipc()or make getter a property - ❌
get_allocation_handle()/from_allocation_handle()— same mismatch
Properties named as non-nouns or with confusing boolean polarity
- ✔️
LaunchConfig.cooperative_launch— reads like an action;is_cooperativewould be more idiomatic for a boolean - ✔️
Event.is_timing_disabled— negative boolean;is_timing_enabledavoids double-negatives likenot event.is_timing_disabledCc: @leofang - ✔️
Event.is_sync_busy_waited— grammatically awkward;uses_busy_waitoris_busy_wait_enabledCc: @leofang - ✔️
system.Device.persistence_mode_enabled— missingis_prefix for boolean;is_persistence_mode_enabled - ✔️
system.Device.display_mode— returns bool but name doesn't suggest boolean;is_display_connected - ✔️
system.Device.display_active— returns bool but name doesn't suggest boolean;is_display_active - ✔️
system.Device.is_c2c_mode_enabled— verbose;is_c2c_enabled
Activity
[-]cuda.core: comprehensive public API naming audit[/-][+]cuda.core: method/member/property naming audit[/+]leofang commentedon Apr 28, 2026
Sorry, somehow I missed the ping here. We should sit down and review this nice list.
There were a few considerations/trade-offs when cuda.core started:
The last two might be less relevant in the agentic world. But good design principles help both human and agents learn faster!
Andy-Jost commentedon Apr 28, 2026
For the
KernelAttributes, I suggest we remove thedevice_idargument and make everything into a property. Then, to specify a device use indexing syntax:Andy-Jost commentedon Apr 28, 2026
Proposed Fixes to the Graph Conditional Node API
After looking at this in conjunction with the parallel
GraphBuilder/GraphDef/GraphNodesurfaces, I think the right cleanup is broader than just theif_condrename. The conditional API is currently inconsistent on three axes:GraphBuilder(capture)GraphDef/GraphNode(programmatic)create_conditional_handle(default_value=None)create_condition(default_value=None)driver.CUgraphConditionalHandleConditionwrapperif_cond/if_else/switch/while_loopif_cond/if_else/switch/while_loopThe branch methods agree on names, but that agreement preserves the lone abbreviation
if_cond(everything else is fully spelled). And the constructor side disagrees on name, return type, and parameter type. The capture API leaks a raw driver type into the public surface.Changes
Rename
Condition→GraphConditionto match theGraph*prefix used byGraphBuilder,GraphDef,GraphNode.Unify the factory to
create_conditionon both APIs, returning aGraphCondition:Drops the raw
driver.CUgraphConditionalHandlefrom the public surface.Rename
if_cond→if_theninGraphBuilder,GraphDef, andGraphNode. Pairs withif_else; consistent with the fully-spelledwhile_loop/switch.Add
GraphCondition.__int__so aGraphConditioncan be passed directly tolaunch()for kernels that callcudaGraphSetConditional, instead ofcondition.handle.Andy-Jost commentedon Apr 28, 2026
In working on
Event.is_sync_busy_waitedI found that the meaning of this property has always been inverted. This longstanding bug was concealed because we have no direct way to test the wait behavior.I'm planning to rename this to
Event.uses_blocking_syncto match the driver propertyCU_EVENT_BLOCKING_SYNC. This should be easier to keep straight.leofang commentedon Apr 28, 2026
Related: #657
leofang commentedon Apr 28, 2026
Related too: cupy/cupy#7911
The event sync behavior is one of the most confusing, hard-to-explain part of the CUDA doc...
Rename GraphDef -> GraphDefinition and Condition -> GraphCondition (#…
fix: update test_read_only_kernel_attributes for property API (NVIDIA…
cuda.core: remove GraphCondition.__int__ (NVIDIA#1945)
cuda.core: rename EventOptions to bare-adjective form (NVIDIA#1945)
cuda.core: rename Event.uses_blocking_sync to is_blocking_sync (NVIDI…
cuda.core: fix int(condition) call sites missed when removing GraphCo…
cuda.core: complete the naming audit from #1945 (#1986)
cuda.core: rename HostCallbackNode.callback_fn to callback (#2024)