IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python class

NPU

NPU

class max.driver.NPU(self, id: int = -1)

source

Bases: Accelerator

Creates an NPU accelerator device.

NPU is a subclass of Accelerator: an NPU is an accelerator, and isinstance(device, Accelerator) returns True for any NPU instance. The reason to construct an NPU instead of a bare Accelerator is to select the NPU dispatch path: the graph compiler stamps an "npu" device label, emits target="npu" Mojo kernels, and routes through the NPU plugin hook rather than the default GPU dispatch path.

On platforms without an NPU backend the device will still be created, but downstream graph compilation will fail with an unsupported target error.

from max import driver
device = driver.NPU()
device = driver.NPU(id=0)

Parameters:

id (int, optional) – The device ID to use. Defaults to -1, which selects the first available NPU.

Returns:

A new NPU device object.

Return type:

NPU