[Bugfix][Platform] Stop re-initializing NVML on every device-capability check (fixes #50381) (#50393)
Signed-off-by: seewoo <seewoo@ucsc.edu> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -741,12 +741,16 @@ class NvmlCudaPlatform(CudaPlatformBase):
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
@with_nvml_context
|
||||
def has_device_capability(
|
||||
cls,
|
||||
capability: tuple[int, int] | int,
|
||||
device_id: int = 0,
|
||||
) -> bool:
|
||||
# No @with_nvml_context here: the base implementation only reads
|
||||
# get_device_capability(), which is cached and brings its own NVML
|
||||
# context. Wrapping this method as well cost an nvmlInit()/
|
||||
# nvmlShutdown() pair on every call, including calls made per attention
|
||||
# layer per step from the Triton reshape-and-cache path.
|
||||
try:
|
||||
return super().has_device_capability(capability, device_id)
|
||||
except RuntimeError:
|
||||
|
||||
Reference in New Issue
Block a user