Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cuda_bindings/cuda/bindings/nvml.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ cpdef int device_get_topology_common_ancestor(intptr_t device1, intptr_t device2
cpdef int device_get_p2p_status(intptr_t device1, intptr_t device2, int p2p_ind_ex) except? -1
cpdef str device_get_uuid(intptr_t device)
cpdef unsigned int device_get_minor_number(intptr_t device) except? 0
cpdef str device_get_board_part_number(intptr_t device)
cpdef str device_get_inforom_version(intptr_t device, int object)
cpdef str device_get_inforom_image_version(intptr_t device)
cpdef bytes device_get_board_part_number(intptr_t device)
cpdef bytes device_get_inforom_version(intptr_t device, int object)
cpdef bytes device_get_inforom_image_version(intptr_t device)
cpdef unsigned int device_get_inforom_configuration_checksum(intptr_t device) except? 0
cpdef device_validate_inforom(intptr_t device)
cpdef tuple device_get_last_bbx_flush_time(intptr_t device)
Expand Down
12 changes: 6 additions & 6 deletions cuda_bindings/cuda/bindings/nvml.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20035,7 +20035,7 @@ cpdef unsigned int device_get_minor_number(intptr_t device) except? 0:
return minor_number


cpdef str device_get_board_part_number(intptr_t device):
cpdef bytes device_get_board_part_number(intptr_t device):
"""Retrieves the the device board part number which is programmed into the board's InfoROM.

Args:
Expand All @@ -20048,10 +20048,10 @@ cpdef str device_get_board_part_number(intptr_t device):
with nogil:
__status__ = nvmlDeviceGetBoardPartNumber(<Device>device, part_number, length)
check_status(__status__)
return cpython.PyUnicode_FromString(part_number)
return cpython.PyBytes_FromStringAndSize(part_number, 80)
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using PyBytes_FromStringAndSize with the full buffer size (80) may include uninitialized or garbage data beyond the actual string content returned by the NVML API. Consider using the actual string length (e.g., via strlen) instead of the hardcoded buffer size, unless the NVML API guarantees that all 80 bytes are meaningful. If embedded NULLs need to be preserved, you could use strlen to find the length up to the first NULL, or modify the approach based on confirmed NVML API behavior.

Copilot uses AI. Check for mistakes.


cpdef str device_get_inforom_version(intptr_t device, int object):
cpdef bytes device_get_inforom_version(intptr_t device, int object):
"""Retrieves the version information for the device's infoROM object.

Args:
Expand All @@ -20065,10 +20065,10 @@ cpdef str device_get_inforom_version(intptr_t device, int object):
with nogil:
__status__ = nvmlDeviceGetInforomVersion(<Device>device, <_InforomObject>object, version, length)
check_status(__status__)
return cpython.PyUnicode_FromString(version)
return cpython.PyBytes_FromStringAndSize(version, 16)
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using PyBytes_FromStringAndSize with the full buffer size (16) may include uninitialized or garbage data beyond the actual string content returned by the NVML API. Consider using the actual string length (e.g., via strlen) instead of the hardcoded buffer size, unless the NVML API guarantees that all 16 bytes are meaningful. If embedded NULLs need to be preserved, you could use strlen to find the length up to the first NULL, or modify the approach based on confirmed NVML API behavior.

Copilot uses AI. Check for mistakes.


cpdef str device_get_inforom_image_version(intptr_t device):
cpdef bytes device_get_inforom_image_version(intptr_t device):
"""Retrieves the global infoROM image version.

Args:
Expand All @@ -20081,7 +20081,7 @@ cpdef str device_get_inforom_image_version(intptr_t device):
with nogil:
__status__ = nvmlDeviceGetInforomImageVersion(<Device>device, version, length)
check_status(__status__)
return cpython.PyUnicode_FromString(version)
return cpython.PyBytes_FromStringAndSize(version, 16)
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using PyBytes_FromStringAndSize with the full buffer size (16) may include uninitialized or garbage data beyond the actual string content returned by the NVML API. Consider using the actual string length (e.g., via strlen) instead of the hardcoded buffer size, unless the NVML API guarantees that all 16 bytes are meaningful. If embedded NULLs need to be preserved, you could use strlen to find the length up to the first NULL, or modify the approach based on confirmed NVML API behavior.

Copilot uses AI. Check for mistakes.


cpdef unsigned int device_get_inforom_configuration_checksum(intptr_t device) except? 0:
Expand Down
6 changes: 3 additions & 3 deletions cuda_core/cuda/core/system/_inforom.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cdef class InforomInfo:
def __init__(self, device: Device):
self._device = device

def get_version(self, inforom: InforomObject) -> str:
def get_version(self, inforom: InforomObject) -> bytes:
"""
Retrieves the InfoROM version for a given InfoROM object.

Expand All @@ -34,7 +34,7 @@ cdef class InforomInfo:
return nvml.device_get_inforom_version(self._device._handle, inforom)

@property
def image_version(self) -> str:
def image_version(self) -> bytes:
"""
Retrieves the global InfoROM image version.

Expand Down Expand Up @@ -100,7 +100,7 @@ cdef class InforomInfo:
return nvml.device_get_last_bbx_flush_time(self._device._handle)

@property
def board_part_number(self) -> str:
def board_part_number(self) -> bytes:
"""
The device board part number which is programmed into the board's InfoROM.
"""
Expand Down
6 changes: 3 additions & 3 deletions cuda_core/tests/system/test_system_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,11 @@ def test_get_inforom_version():

with unsupported_before(device, "HAS_INFOROM"):
inforom_image_version = inforom.image_version
assert isinstance(inforom_image_version, str)
assert isinstance(inforom_image_version, bytes)
assert len(inforom_image_version) > 0

inforom_version = inforom.get_version(system.InforomObject.INFOROM_OEM)
assert isinstance(inforom_version, str)
assert isinstance(inforom_version, bytes)
assert len(inforom_version) > 0

checksum = inforom.configuration_checksum
Expand All @@ -537,7 +537,7 @@ def test_get_inforom_version():

with unsupported_before(device, "HAS_INFOROM"):
board_part_number = inforom.board_part_number
assert isinstance(board_part_number, str)
assert isinstance(board_part_number, bytes)
assert len(board_part_number) > 0

inforom.validate()
Expand Down
Loading