Skip to content
Open
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
8 changes: 8 additions & 0 deletions src/winml/modelkit/sysinfo/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ def get_vendor_id_device_id_from_pnp_id(pnp_id: str) -> tuple[int, int]:
device_id = int.from_bytes(id_segment[4:].encode("ascii"), byteorder="little")
return vendor_id, device_id

# Some NVIDIA GPUs are exposed via ACPI IDs without VEN_/DEV_ tokens
# (e.g., "ACPI\\NVDA200A\\0"). Parse the NVDA tag directly.
acpi_nvda_match = re.search(r"^ACPI\\NVDA([0-9A-Fa-f]{4})(?:\\|$)", pnp_id)
if acpi_nvda_match is not None:
vendor_id = 0x10DE
device_id = int(acpi_nvda_match.group(1), 16)
return vendor_id, device_id

vendor_id_str_groups = re.search(r"VEN_([0-9A-Za-z]+)", pnp_id)
if vendor_id_str_groups is None:
raise ValueError(f"Invalid PNPDeviceID format: {pnp_id}")
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/sysinfo/test_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ def test_qualcomm_ven_quirk(self) -> None:
vendor_id, device_id = get_vendor_id_device_id_from_pnp_id("PCI\\VEN_QCOM&DEV_5C40")
assert (vendor_id, device_id) == (0x4D4F4351, 0x30344335)

def test_nvidia_acpi_quirk(self) -> None:
"""``ACPI\\NVDA####`` should map to NVIDIA vendor id + hex device id."""
vendor_id, device_id = get_vendor_id_device_id_from_pnp_id("ACPI\\NVDA200A\\0")
assert (vendor_id, device_id) == (0x10DE, 0x200A)

def test_missing_vendor_raises(self) -> None:
with pytest.raises(ValueError, match="Invalid PNPDeviceID"):
get_vendor_id_device_id_from_pnp_id("PCI\\DEV_2204")
Expand Down
Loading