Skip to content

Add Linux NPU discovery through sysfs accel devices#28703

Open
the0cp wants to merge 1 commit into
microsoft:mainfrom
the0cp:linux-npu-device-discovery
Open

Add Linux NPU discovery through sysfs accel devices#28703
the0cp wants to merge 1 commit into
microsoft:mainfrom
the0cp:linux-npu-device-discovery

Conversation

@the0cp
Copy link
Copy Markdown
Contributor

@the0cp the0cp commented May 28, 2026

Description

This PR adds Linux NPU discovery through sysfs accel devices

Currently, DeviceDiscovery::DiscoverDevicesForPlatform() on Linux discovers CPU and GPU devices, but NPU discovery is still missing. As a result, plugin execution providers that filter devices by OrtHardwareDeviceType_NPU do not receive any NPU hardware devices on Linux, even when the NPU is present and exposed by the kernel.

This change scans /sys/class/accel for accelN devices and creates OrtHardwareDevice entries with:

  • type = OrtHardwareDeviceType_NPU
  • PCI vendor_id
  • PCI device_id
  • accel_idx metadata
  • pci_bus_id metadata when available

This enables Linux systems with NPUs exposed through the accel subsystem, such as AMD Ryzen AI / XDNA devices, to be reported through ORT device discovery and made available to plugin EP factories.

Changes

  • Add Linux sysfs discovery for NPU devices under /sys/class/accel.
  • Read NPU PCI vendor and device IDs from the underlying sysfs device path.
  • Add NPU metadata including accel_idx and pci_bus_id.
  • Include discovered NPU devices in DeviceDiscovery::DiscoverDevicesForPlatform().
  • Add a kSysfsAccelPath constant for the Linux accel sysfs path.

Motivation

Linux plugin EPs that target NPUs rely on ORT passing OrtHardwareDeviceType_NPU devices into GetSupportedDevices(). Without Linux NPU discovery, those EPs cannot claim NPU devices and provider selection policies such as PREFER_NPU silently fall back to CPU.

Fixes #28660.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Linux DeviceDiscovery::DiscoverDevicesForPlatform does not enumerate NPU devices — plugin EPs targeting NPU are unusable on Linux

1 participant