[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:
Sebastian Woo
2026-08-07 08:30:00 +00:00
committed by GitHub
co-authored by Claude
parent b8db7f4abd
commit 4f76c8ad9d
2 changed files with 82 additions and 1 deletions
+5 -1
View File
@@ -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: