Coverage for cuda / core / system / typing.py: 97.66%

171 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-05-22 01:37 +0000

1# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 

2# 

3# SPDX-License-Identifier: Apache-2.0 

4 

5from cuda.core._utils.pycompat import StrEnum 

6 

7__all__ = [ 

8 "AddressingMode", 

9 "AffinityScope", 

10 "ClockId", 

11 "ClockType", 

12 "ClocksEventReasons", 

13 "CoolerControl", 

14 "CoolerTarget", 

15 "EventType", 

16 "FanControlPolicy", 

17 "GpuP2PCapsIndex", 

18 "GpuP2PStatus", 

19 "GpuTopologyLevel", 

20 "InforomObject", 

21 "SystemEventType", 

22 "TemperatureThresholds", 

23 "ThermalController", 

24 "ThermalTarget", 

25] 

26 

27 

28class AddressingMode(StrEnum): 

29 """ 

30 Addressing mode of a device. 

31 

32 For Kepler™ or newer fully supported devices. 

33 """ 

34 

35 HMM = "hmm" 

36 ATS = "ats" 

37 

38 

39AddressingMode.HMM.__doc__ = """ 

40 System allocated memory (``malloc``, ``mmap``) is addressable from the device 

41 (GPU), via software-based mirroring of the CPU's page tables, on the GPU. 

42""" 

43 

44AddressingMode.ATS.__doc__ = """ 

45 System allocated memory (``malloc``, ``mmap``) is addressable from the device 

46 (GPU), via Address Translation Services. This means that there is (effectively) 

47 a single set of page tables, and the CPU and GPU both use them. 

48""" 

49 

50 

51class AffinityScope(StrEnum): 

52 """ 

53 Scope for affinity queries. 

54 """ 

55 

56 NODE = "node" 

57 SOCKET = "socket" 

58 

59 

60AffinityScope.NODE.__doc__ = """ 

61The NUMA node is the scope of the affinity query. This is the default scope. 

62""" 

63 

64AffinityScope.SOCKET.__doc__ = """ 

65The CPU socket is the scope of the affinity query. 

66""" 

67 

68 

69class ClockId(StrEnum): 

70 """ 

71 Clock Ids. These are used in combination with :class:`ClockType` to specify a single clock value. 

72 """ 

73 

74 CURRENT = "current" 

75 CUSTOMER_BOOST_MAX = "customer_boost_max" 

76 # APP_CLOCK_TARGET and APP_CLOCK_DEFAULT are deprecated so not included here 

77 

78 

79ClockId.CURRENT.__doc__ = "Current actual clock value." 

80ClockId.CUSTOMER_BOOST_MAX.__doc__ = "OEM-defined maximum clock rate" 

81 

82 

83class ClocksEventReasons(StrEnum): 

84 """ 

85 Reasons for a clocks event. These are used in combination with :class:`ClockType` to specify the reason 

86 for a clocks event. 

87 """ 

88 

89 NONE = "none" 

90 GPU_IDLE = "gpu_idle" 

91 APPLICATIONS_CLOCKS_SETTING = "applications_clocks_setting" 

92 SW_POWER_CAP = "sw_power_cap" 

93 HW_SLOWDOWN = "hw_slowdown" 

94 SYNC_BOOST = "sync_boost" 

95 SW_THERMAL_SLOWDOWN = "sw_thermal_slowdown" 

96 HW_THERMAL_SLOWDOWN = "hw_thermal_slowdown" 

97 HW_POWER_BRAKE_SLOWDOWN = "hw_power_brake_slowdown" 

98 DISPLAY_CLOCK_SETTING = "display_clock_setting" 

99 

100 

101class ClockType(StrEnum): 

102 """ 

103 Clock types. All speeds are in Mhz. 

104 """ 

105 

106 GRAPHICS = "graphics" 

107 SM = "sm" 

108 MEMORY = "memory" 

109 VIDEO = "video" 

110 

111 

112class CoolerControl(StrEnum): 

113 """ 

114 Cooler control type. 

115 """ 

116 

117 TOGGLE = "toggle" 

118 VARIABLE = "variable" 

119 

120 

121CoolerControl.TOGGLE.__doc__ = """ 

122This cooler can only be toggled either ON or OFF (e.g. a switch). 

123""" 

124 

125CoolerControl.VARIABLE.__doc__ = """ 

126This cooler's level can be adjusted from some minimum to some maximum (e.g. a knob). 

127""" 

128 

129 

130class CoolerTarget(StrEnum): 

131 """ 

132 Cooler target. 

133 """ 

134 

135 NONE = "none" 

136 GPU = "gpu" 

137 MEMORY = "memory" 

138 POWER_SUPPLY = "power_supply" 

139 # THERMAL_GPU_RELATED is a composite target, so it is omitted here and will 

140 # get returned as 3 separate targets: GPU, MEMORY, and POWER_SUPPLY. 

141 

142 

143CoolerTarget.NONE.__doc__ = "This cooler controls nothing." 

144CoolerTarget.GPU.__doc__ = "This cooler can cool the GPU." 

145CoolerTarget.MEMORY.__doc__ = "This cooler can cool the memory." 

146CoolerTarget.POWER_SUPPLY.__doc__ = "This cooler can cool the power supply." 

147 

148 

149class EventType(StrEnum): 

150 """ 

151 Event types that can be waited on with :class:`DeviceEvents`. 

152 """ 

153 

154 NONE = "none" 

155 SINGLE_BIT_ECC_ERROR = "single_bit_ecc_error" 

156 DOUBLE_BIT_ECC_ERROR = "double_bit_ecc_error" 

157 PSTATE = "pstate" 

158 XID_CRITICAL_ERROR = "xid_critical_error" 

159 CLOCK = "clock" 

160 POWER_SOURCE_CHANGE = "power_source_change" 

161 MIG_CONFIG_CHANGE = "mig_config_change" 

162 SINGLE_BIT_ECC_ERROR_STORM = "single_bit_ecc_error_storm" 

163 DRAM_RETIREMENT_EVENT = "dram_retirement_event" 

164 DRAM_RETIREMENT_FAILURE = "dram_retirement_failure" 

165 NON_FATAL_POISON_ERROR = "non_fatal_poison_error" 

166 FATAL_POISON_ERROR = "fatal_poison_error" 

167 GPU_UNAVAILABLE_ERROR = "gpu_unavailable_error" 

168 GPU_RECOVERY_ACTION = "gpu_recovery_action" 

169 

170 

171EventType.PSTATE.__doc__ = """ 

172Event about PState changes 

173 

174On Fermi™ architecture, PState changes are also an indicator that GPU is throttling down due to 

175no work being executed on the GPU, power capping or thermal capping. In a typical situation, 

176Fermi-based GPU should stay in P0 for the duration of the execution of the compute process. 

177""" 

178 

179 

180class FanControlPolicy(StrEnum): 

181 """ 

182 Fan control policies. 

183 """ 

184 

185 TEMPERATURE_CONTROLLED = "temperature_controlled" 

186 MANUAL = "manual" 

187 

188 

189class GpuP2PCapsIndex(StrEnum): 

190 """ 

191 GPU peer-to-peer capabilities index. 

192 """ 

193 

194 READ = "read" 

195 WRITE = "write" 

196 NVLINK = "nvlink" 

197 ATOMICS = "atomics" 

198 PCI = "pci" 

199 PROP = "prop" 

200 UNKNOWN = "unknown" 

201 

202 

203class GpuP2PStatus(StrEnum): 

204 """ 

205 GPU peer-to-peer status. 

206 """ 

207 

208 OK = "ok" 

209 CHIPSET_NOT_SUPPORTED = "chipset not supported" 

210 GPU_NOT_SUPPORTED = "GPU not supported" 

211 IOH_TOPOLOGY_NOT_SUPPORTED = "IOH topology not supported" 

212 DISABLED_BY_REGKEY = "disabled by regkey" 

213 NOT_SUPPORTED = "not supported" 

214 UNKNOWN = "unknown" 

215 

216 

217class GpuTopologyLevel(StrEnum): 

218 """ 

219 Represents level relationships within a system between two GPUs. 

220 """ 

221 

222 INTERNAL = "internal" 

223 SINGLE = "single" 

224 MULTIPLE = "multiple" 

225 HOSTBRIDGE = "hostbridge" 

226 NODE = "node" 

227 SYSTEM = "system" 

228 

229 

230class InforomObject(StrEnum): 

231 """ 

232 InfoROM objects types. 

233 """ 

234 

235 OEM = "oem" 

236 ECC = "ecc" 

237 POWER = "power" 

238 DEN = "den" 

239 

240 

241InforomObject.OEM.__doc__ = "An object defined by OEM." 

242InforomObject.ECC.__doc__ = "The ECC object determining the level of ECC support." 

243InforomObject.POWER.__doc__ = "The power management object." 

244InforomObject.DEN.__doc__ = "DRAM Encryption object." 

245 

246 

247class SystemEventType(StrEnum): 

248 """ 

249 System event types. 

250 """ 

251 

252 UNBIND = "unbind" 

253 BIND = "bind" 

254 

255 

256class TemperatureThresholds(StrEnum): 

257 """ 

258 Temperature threshold types. 

259 """ 

260 

261 SHUTDOWN = "shutdown" 

262 SLOWDOWN = "slowdown" 

263 MEM_MAX = "mem_max" 

264 GPU_MAX = "gpu_max" 

265 ACOUSTIC_MIN = "acoustic_min" 

266 ACOUSTIC_CURR = "acoustic_curr" 

267 ACOUSTIC_MAX = "acoustic_max" 

268 GPS_CURR = "gps_curr" 

269 

270 

271class ThermalController(StrEnum): 

272 """ 

273 Thermal controller types. 

274 """ 

275 

276 GPU_INTERNAL = "gpu_internal" 

277 ADM1032 = "adm1032" 

278 ADT7461 = "adt7461" 

279 MAX6649 = "max6649" 

280 MAX1617 = "max1617" 

281 LM99 = "lm99" 

282 LM89 = "lm89" 

283 LM64 = "lm64" 

284 G781 = "g781" 

285 ADT7473 = "adt7473" 

286 SBMAX6649 = "sbmax6649" 

287 VBIOSEVT = "vbiosevt" 

288 OS = "os" 

289 NVSYSCON_CANOAS = "nvsyscon_canoas" 

290 NVSYSCON_E551 = "nvsyscon_e551" 

291 MAX6649R = "max6649r" 

292 ADT7473S = "adt7473s" 

293 UNKNOWN = "unknown" 

294 

295 

296class ThermalTarget(StrEnum): 

297 """ 

298 Thermal sensor targets. 

299 """ 

300 

301 NONE = "none" 

302 GPU = "gpu" 

303 MEMORY = "memory" 

304 POWER_SUPPLY = "power_supply" 

305 BOARD = "board" 

306 VCD_BOARD = "vcd_board" 

307 VCD_INLET = "vcd_inlet" 

308 VCD_OUTLET = "vcd_outlet" 

309 ALL = "all" 

310 

311 

312ThermalTarget.GPU.__doc__ = "GPU core temperature requires physical GPU handle." 

313ThermalTarget.MEMORY.__doc__ = "GPU memory temperature requires physical GPU handle." 

314ThermalTarget.POWER_SUPPLY.__doc__ = "GPU power supply temperature requires physical GPU handle." 

315ThermalTarget.BOARD.__doc__ = "GPU board ambient temperature requires physical GPU handle." 

316ThermalTarget.VCD_BOARD.__doc__ = "Visual Computing Device Board temperature requires visual computing device handle." 

317ThermalTarget.VCD_INLET.__doc__ = "Visual Computing Device Inlet temperature requires visual computing device handle." 

318ThermalTarget.VCD_OUTLET.__doc__ = "Visual Computing Device Outlet temperature requires visual computing device handle." 

319 

320 

321# DeviceArch values are derived from cuda.bindings.nvml at definition time, so 

322# the class can only be defined when nvml is importable. 

323try: 

324 from cuda.bindings import nvml as _nvml 

325 

326 try: 

327 from cuda.bindings._internal._fast_enum import FastEnum as _FastEnum 

328 except ImportError: 

329 from enum import IntEnum as _FastEnum 

330 

331 # This uses FastEnum instead of StrEnum because the ordering of the values is 

332 # meaningful, e.g. Kepler "or later" 

333 class DeviceArch(_FastEnum): 

334 """ 

335 Device architecture. 

336 """ 

337 

338 KEPLER = int(_nvml.DeviceArch.KEPLER) 

339 MAXWELL = int(_nvml.DeviceArch.MAXWELL) 

340 PASCAL = int(_nvml.DeviceArch.PASCAL) 

341 VOLTA = int(_nvml.DeviceArch.VOLTA) 

342 TURING = int(_nvml.DeviceArch.TURING) 

343 AMPERE = int(_nvml.DeviceArch.AMPERE) 

344 ADA = int(_nvml.DeviceArch.ADA) 

345 HOPPER = int(_nvml.DeviceArch.HOPPER) 

346 BLACKWELL = int(_nvml.DeviceArch.BLACKWELL) 

347 UNKNOWN = int(_nvml.DeviceArch.UNKNOWN) 

348 

349 __all__.append("DeviceArch") 

350 

351 FieldId = _nvml.FieldId 

352 

353 __all__.append("FieldId") 

354 

355 del _nvml, _FastEnum 

356 

357except ImportError: 

358 pass 

359 

360 

361del StrEnum