# Python API

## Classes

| Name | Description |
| --- | --- |
| [`Accelerator`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/Accelerator/index.md>) | Represents an accelerator, i.e., an NPU, used for executing models. |
| [`BatchParam`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/BatchParam/index.md>) | Struct containing BatchLLM parameters. |
| [`Buffer`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/Buffer/index.md>) | A simple byte-sized buffer. |
| [`BufferInfo`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/BufferInfo/index.md>) | Struct representing input/output buffer information. |
| [`CacheInfo`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/CacheInfo/index.md>) | Struct representing KV-cache information. |
| [`CacheType`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/CacheType/index.md>) | [CacheType](<https://docs.mobilint.com/runtime/en/v1.2/api/python/CacheType/index.md>) |
| [`Cluster`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/Cluster/index.md>) | Enumerates clusters in the ARIES NPU. |
| [`Core`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/Core/index.md>) | Enumerates cores within a cluster in the ARIES NPU. |
| [`CoreAllocationPolicy`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/CoreAllocationPolicy/index.md>) | [Core](<https://docs.mobilint.com/runtime/en/v1.2/api/python/Core/index.md>) allocation policy |
| [`CoreId`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/CoreId/index.md>) | Represents a unique identifier for an NPU core. |
| [`CoreMode`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/CoreMode/index.md>) | Defines the core mode for NPU execution. |
| [`DataType`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/DataType/index.md>) | [DataType](<https://docs.mobilint.com/runtime/en/v1.2/api/python/DataType/index.md>) |
| [`Future`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/Future/index.md>) | Represents a future for retrieving the result of asynchronous inference. |
| [`LogLevel`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/LogLevel/index.md>) | [LogLevel](<https://docs.mobilint.com/runtime/en/v1.2/api/python/LogLevel/index.md>) |
| [`Model`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/Model/index.md>) | Represents an AI model loaded from an MXQ file. |
| [`ModelConfig`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/ModelConfig/index.md>) | Configures a core mode and core allocation of a model for NPU inference. The [`ModelConfig`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/ModelConfig/index.md>) class provides methods for setting a core mode and allocating cores for NPU inference. Supported core modes are single-core, multi-core, global4-core, and global8-core. Users can also specify which cores to allocate for the model. Additionally, the configuration offers an option to enforce the use of a specific NPU bundle. |
| [`ModelVariantHandle`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/ModelVariantHandle/index.md>) | Handle to a specific variant of a loaded model. |
| [`Scale`](<https://docs.mobilint.com/runtime/en/v1.2/api/python/Scale/index.md>) | Struct for scale values. |

## Functions

| Name | Description |
| --- | --- |
| [`load`](<#load>) | Single-step inference API. Creates model and uploads the model into NPU immediately. |
| [`set_log_level`](<#set-log-level>) |  |
| [`start_tracing_events`](<#start-tracing-events>) | Starts event tracing and prepares to save the trace log to a specified file. |
| [`stop_tracing_events`](<#stop-tracing-events>) | Stops event tracing and writes the recorded trace log. |
| [`get_model_summary`](<#get-model-summary>) | Generates a structured summary of the specified MXQ model. |
| [`get_available_device_numbers`](<#get-available-device-numbers>) | Get the number of available NPU devices. |

### load

```python
def load(path: str, model_config: Optional[ModelConfig] = None) -> Model
```

Single-step inference API. Creates model and uploads the model into NPU immediately.

This operation performs the [Accelerator](<https://docs.mobilint.com/runtime/en/v1.2/api/python/Accelerator/index.md>) declaration, [Model](<https://docs.mobilint.com/runtime/en/v1.2/api/python/Model/index.md>) declaration, and launch in a single step.

### set\_log\_level

```python
def set_log_level(level: LogLevel)
```

### start\_tracing\_events

```python
def start_tracing_events(path: str) -> bool
```

Starts event tracing and prepares to save the trace log to a specified file.

The trace log is recorded in "Chrome Tracing JSON format," which can be viewed at https://ui.perfetto.dev/.

The trace log is not written immediately; it is saved only when [stop\_tracing\_events()](<#stop-tracing-events>) is called.

**Parameters**

- `path` *\[in\]* — The file path where the trace log should be stored.

**Returns**

True if tracing starts successfully, False otherwise.

### stop\_tracing\_events

```python
def stop_tracing_events()
```

Stops event tracing and writes the recorded trace log.

This function finalizes tracing and saves the collected trace data to the file specified when [start\_tracing\_events()](<#start-tracing-events>) was called.

### get\_model\_summary

```python
def get_model_summary(mxq_path: str) -> str
```

Generates a structured summary of the specified MXQ model.

Returns an overview of the model contained in the MXQ file, including:

- Target NPU hardware
- Supported core modes and their associated cores
- The total number of model variants
- For each variant:

  - Input and output tensor shapes
  - A list of layers with their types, output shapes, and input layer indices

The summary is returned as a human-readable string in a table and is useful for inspecting model compatibility, structure, and input/output shapes.

**Parameters**

- `mxq_path` *\[in\]* — Path to the MXQ model file.

**Returns**

A formatted string containing the model summary.

### get\_available\_device\_numbers

```python
def get_available_device_numbers() -> List[int]
```

Get the number of available NPU devices.

**Returns**

The number of available NPU devices.
