# `vllm_mlx.worker`

MLX Worker for vLLM.

[View the complete module source at #L1-L278](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L1-L278).

## API details

Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.

::: vllm_mlx.worker
    options:
      members:
        - logger
        - MLXWorker
      filters: []
      show_if_no_docstring: true

## Complete contract reference

Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker</code> · class</summary>

```python
vllm_mlx.worker.MLXWorker(vllm_config: 'VllmConfig', local_rank: int, rank: int, distributed_init_method: str, is_driver_worker: bool = False)
```

Worker implementation for MLX-based inference on Apple Silicon.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `vllm_config` | `'VllmConfig'` | `yes` | `none` | Complete vLLM configuration |
| `local_rank` | `int` | `yes` | `none` | Local device index (usually 0 for single GPU) |
| `rank` | `int` | `yes` | `none` | Global rank in distributed setup |
| `distributed_init_method` | `str` | `yes` | `none` | Distributed initialization method |
| `is_driver_worker` | `bool` | `no` | `False` | Whether this worker handles driver responsibilities |

**Returns**

- Constructs: `vllm_mlx.worker.MLXWorker`

**Exceptions and behavior**

Class `MLXWorker` declares 21 direct member(s).
No direct `raise` statement appears in this definition.

[View source #L23-L278](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L23-L278).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.__init__" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.__init__</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.__init__(vllm_config: 'VllmConfig', local_rank: int, rank: int, distributed_init_method: str, is_driver_worker: bool = False) -> None
```

Initialize MLX worker.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `vllm_config` | `'VllmConfig'` | `yes` | `none` | Complete vLLM configuration |
| `local_rank` | `int` | `yes` | `none` | Local device index (usually 0 for single GPU) |
| `rank` | `int` | `yes` | `none` | Global rank in distributed setup |
| `distributed_init_method` | `str` | `yes` | `none` | Distributed initialization method |
| `is_driver_worker` | `bool` | `no` | `False` | Whether this worker handles driver responsibilities |

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `MLXWorker.__init__` updates `self.vllm_config`, `self.model_config`, `self.cache_config`, `self.parallel_config`; calls `torch.device`, `logger.info`.
No direct `raise` statement appears in this definition.

[View source #L36-L75](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L36-L75).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.init_device" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.init_device</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.init_device() -> None
```

Initialize MLX device and verify it's working.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `MLXWorker.init_device` updates `self.model_runner`; calls `mx.default_device`, `logger.info`, `get_mlx_device_info`, `MLXModelRunner`; can raise `ImportError`.
Directly raised exceptions: `ImportError`.

[View source #L77-L103](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L77-L103).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.load_model" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.load_model</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.load_model() -> None
```

Load model using mlx-lm.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `MLXWorker.load_model` calls `RuntimeError`, `self.model_runner.load_model`, `logger.info`; can raise `RuntimeError`.
Directly raised exceptions: `RuntimeError`.

[View source #L105-L111](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L105-L111).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.determine_available_memory" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.determine_available_memory</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.determine_available_memory() -> int
```

Determine available memory for KV cache.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `int`
- Direct return expressions: `available`; `4 * 1024 * 1024 * 1024`

**Exceptions and behavior**

Method `MLXWorker.determine_available_memory` calls `subprocess.run`, `int`, `result.stdout.strip`, `logger.info`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L113-L143](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L113-L143).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.initialize_cache" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.initialize_cache</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.initialize_cache(num_gpu_blocks: int, num_cpu_blocks: int) -> None
```

Initialize KV cache with the given size.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `num_gpu_blocks` | `int` | `yes` | `none` | Required positional or keyword input. |
| `num_cpu_blocks` | `int` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `MLXWorker.initialize_cache` updates `self.cache_config.num_gpu_blocks`, `self.cache_config.num_cpu_blocks`; calls `self.model_runner.initialize_cache`, `logger.info`.
No direct `raise` statement appears in this definition.

[View source #L145-L153](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L145-L153).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.get_kv_cache_spec" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.get_kv_cache_spec</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.get_kv_cache_spec() -> dict
```

Get KV cache specification.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `dict`
- Direct return expressions: `self.model_runner.get_kv_cache_spec()`; `{}`

**Exceptions and behavior**

Method `MLXWorker.get_kv_cache_spec` calls `self.model_runner.get_kv_cache_spec`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L155-L159](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L155-L159).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.compile_or_warm_up_model" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.compile_or_warm_up_model</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.compile_or_warm_up_model() -> None
```

Warm up model for inference.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `MLXWorker.compile_or_warm_up_model` calls `self.model_runner.warm_up`, `logger.info`.
No direct `raise` statement appears in this definition.

[View source #L161-L165](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L161-L165).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.execute_model" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.execute_model</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.execute_model(scheduler_output: 'SchedulerOutput') -> 'ModelRunnerOutput | None'
```

Execute model inference for the given scheduler output.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `scheduler_output` | `'SchedulerOutput'` | `yes` | `none` | Contains requests to process |

**Returns**

- Type: `'ModelRunnerOutput | None'`
- Direct return expressions: `self.model_runner.execute_model(scheduler_output)`

**Exceptions and behavior**

Method `MLXWorker.execute_model` calls `RuntimeError`, `self.model_runner.execute_model`; can raise `RuntimeError`; returns `self.model_runner.execute_model(scheduler_output)`.
Directly raised exceptions: `RuntimeError`.

[View source #L167-L183](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L167-L183).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.get_model" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.get_model</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.get_model() -> not annotated
```

Get the underlying model.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `not annotated`
- Direct return expressions: `self.model_runner.model`; `None`

**Exceptions and behavior**

Method `MLXWorker.get_model` has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L185-L189](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L185-L189).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.check_health" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.check_health</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.check_health() -> None
```

Check worker health.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `MLXWorker.check_health` calls `mx.array`, `mx.sum(test).item`, `mx.sum`, `RuntimeError`; can raise `RuntimeError`.
Directly raised exceptions: `RuntimeError`.

[View source #L191-L200](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L191-L200).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.shutdown" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.shutdown</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.shutdown() -> None
```

Clean up resources.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `MLXWorker.shutdown` updates `self.model`, `self.tokenizer`, `self.model_runner`; calls `logger.info`, `mx.clear_cache`, `gc.collect`.
No direct `raise` statement appears in this definition.

[View source #L202-L219](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L202-L219).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.add_lora" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.add_lora</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.add_lora(lora_request) -> bool
```

Report that dynamically adding a LoRA adapter is unsupported.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `lora_request` | `not annotated` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `bool`
- Direct return expressions: `False`

**Exceptions and behavior**

Method `MLXWorker.add_lora` calls `logger.warning`; returns `False`.
No direct `raise` statement appears in this definition.

[View source #L222-L226](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L222-L226).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.remove_lora" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.remove_lora</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.remove_lora(lora_id: int) -> bool
```

Report that dynamically removing a LoRA adapter is unsupported.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `lora_id` | `int` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `bool`
- Direct return expressions: `False`

**Exceptions and behavior**

Method `MLXWorker.remove_lora` returns `False`.
No direct `raise` statement appears in this definition.

[View source #L228-L231](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L228-L231).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.pin_lora" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.pin_lora</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.pin_lora(lora_id: int) -> bool
```

Report that pinning a LoRA adapter is unsupported.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `lora_id` | `int` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `bool`
- Direct return expressions: `False`

**Exceptions and behavior**

Method `MLXWorker.pin_lora` returns `False`.
No direct `raise` statement appears in this definition.

[View source #L233-L236](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L233-L236).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.list_loras" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.list_loras</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.list_loras() -> set[int]
```

Return the empty set because runtime LoRA adapters are unsupported.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `set[int]`
- Direct return expressions: `set()`

**Exceptions and behavior**

Method `MLXWorker.list_loras` calls `set`; returns `set()`.
No direct `raise` statement appears in this definition.

[View source #L238-L241](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L238-L241).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.sleep" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.sleep</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.sleep(level: int = 1) -> None
```

Leave the worker active because MLX unified memory has no sleep mode.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `level` | `int` | `no` | `1` | Optional positional or keyword input; defaults to `1`. |

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `MLXWorker.sleep` calls `logger.debug`.
No direct `raise` statement appears in this definition.

[View source #L244-L247](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L244-L247).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.wake_up" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.wake_up</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.wake_up(tags: list[str] | None = None) -> None
```

Perform no work because the MLX worker never enters sleep mode.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `tags` | `list[str] \| None` | `no` | `None` | Optional positional or keyword input; defaults to `None`. |

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `MLXWorker.wake_up` calls `logger.debug`.
No direct `raise` statement appears in this definition.

[View source #L249-L252](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L249-L252).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.vocab_size" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.vocab_size</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.vocab_size() -> int
```

Get vocabulary size.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `int`
- Direct return expressions: `self.model_config.get_vocab_size()`

**Exceptions and behavior**

Method `MLXWorker.vocab_size` calls `self.model_config.get_vocab_size`; returns `self.model_config.get_vocab_size()`.
No direct `raise` statement appears in this definition.

[View source #L255-L257](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L255-L257).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.get_cache_block_size_bytes" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.get_cache_block_size_bytes</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.get_cache_block_size_bytes() -> int
```

Get size of a cache block in bytes.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `int`
- Direct return expressions: `self.model_runner.get_cache_block_size_bytes()`; `2 * block_size * num_layers * num_heads * head_size * 2`

**Exceptions and behavior**

Method `MLXWorker.get_cache_block_size_bytes` calls `self.model_runner.get_cache_block_size_bytes`, `self.model_config.get_head_size`, `self.model_config.get_num_kv_heads`, `self.model_config.get_num_layers`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L259-L271](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L259-L271).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.profile" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.profile</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.profile(is_start: bool = True) -> None
```

Profiling (not yet implemented for MLX).

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `is_start` | `bool` | `no` | `True` | Optional positional or keyword input; defaults to `True`. |

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `MLXWorker.profile` calls `logger.debug`.
No direct `raise` statement appears in this definition.

[View source #L273-L275](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L273-L275).

</details>

<details class="api-contract" id="contract-vllm_mlx.worker.MLXWorker.__repr__" markdown="1">
<summary><code>vllm_mlx.worker.MLXWorker.__repr__</code> · method</summary>

```python
vllm_mlx.worker.MLXWorker.__repr__() -> str
```

Method `MLXWorker.__repr__` returns `f'<MLXWorker rank={self.rank} local_rank={self.local_rank}>'`.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `str`
- Direct return expressions: `f'<MLXWorker rank={self.rank} local_rank={self.local_rank}>'`

**Exceptions and behavior**

Method `MLXWorker.__repr__` returns `f'<MLXWorker rank={self.rank} local_rank={self.local_rank}>'`.
No direct `raise` statement appears in this definition.

[View source #L277-L278](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L277-L278).

</details>

## Complete symbol map

This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.

| Symbol | Kind | Signature and inputs | What it does | Source |
| --- | --- | --- | --- | --- |
| [`MLXWorker`](#contract-vllm_mlx.worker.MLXWorker) | class | `MLXWorker(vllm_config: 'VllmConfig', local_rank: int, rank: int, distributed_init_method: str, is_driver_worker: bool = False)` | Worker implementation for MLX-based inference on Apple Silicon. | [#L23-L278](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L23-L278) |
| [`MLXWorker.__init__`](#contract-vllm_mlx.worker.MLXWorker.__init__) | method | `MLXWorker.__init__(vllm_config: 'VllmConfig', local_rank: int, rank: int, distributed_init_method: str, is_driver_worker: bool = False) -> None` | Initialize MLX worker. | [#L36-L75](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L36-L75) |
| [`MLXWorker.init_device`](#contract-vllm_mlx.worker.MLXWorker.init_device) | method | `MLXWorker.init_device() -> None` | Initialize MLX device and verify it's working. | [#L77-L103](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L77-L103) |
| [`MLXWorker.load_model`](#contract-vllm_mlx.worker.MLXWorker.load_model) | method | `MLXWorker.load_model() -> None` | Load model using mlx-lm. | [#L105-L111](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L105-L111) |
| [`MLXWorker.determine_available_memory`](#contract-vllm_mlx.worker.MLXWorker.determine_available_memory) | method | `MLXWorker.determine_available_memory() -> int` | Determine available memory for KV cache. | [#L113-L143](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L113-L143) |
| [`MLXWorker.initialize_cache`](#contract-vllm_mlx.worker.MLXWorker.initialize_cache) | method | `MLXWorker.initialize_cache(num_gpu_blocks: int, num_cpu_blocks: int) -> None` | Initialize KV cache with the given size. | [#L145-L153](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L145-L153) |
| [`MLXWorker.get_kv_cache_spec`](#contract-vllm_mlx.worker.MLXWorker.get_kv_cache_spec) | method | `MLXWorker.get_kv_cache_spec() -> dict` | Get KV cache specification. | [#L155-L159](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L155-L159) |
| [`MLXWorker.compile_or_warm_up_model`](#contract-vllm_mlx.worker.MLXWorker.compile_or_warm_up_model) | method | `MLXWorker.compile_or_warm_up_model() -> None` | Warm up model for inference. | [#L161-L165](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L161-L165) |
| [`MLXWorker.execute_model`](#contract-vllm_mlx.worker.MLXWorker.execute_model) | method | `MLXWorker.execute_model(scheduler_output: 'SchedulerOutput') -> 'ModelRunnerOutput \| None'` | Execute model inference for the given scheduler output. | [#L167-L183](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L167-L183) |
| [`MLXWorker.get_model`](#contract-vllm_mlx.worker.MLXWorker.get_model) | method | `MLXWorker.get_model() -> not annotated` | Get the underlying model. | [#L185-L189](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L185-L189) |
| [`MLXWorker.check_health`](#contract-vllm_mlx.worker.MLXWorker.check_health) | method | `MLXWorker.check_health() -> None` | Check worker health. | [#L191-L200](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L191-L200) |
| [`MLXWorker.shutdown`](#contract-vllm_mlx.worker.MLXWorker.shutdown) | method | `MLXWorker.shutdown() -> None` | Clean up resources. | [#L202-L219](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L202-L219) |
| [`MLXWorker.add_lora`](#contract-vllm_mlx.worker.MLXWorker.add_lora) | method | `MLXWorker.add_lora(lora_request) -> bool` | Report that dynamically adding a LoRA adapter is unsupported. | [#L222-L226](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L222-L226) |
| [`MLXWorker.remove_lora`](#contract-vllm_mlx.worker.MLXWorker.remove_lora) | method | `MLXWorker.remove_lora(lora_id: int) -> bool` | Report that dynamically removing a LoRA adapter is unsupported. | [#L228-L231](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L228-L231) |
| [`MLXWorker.pin_lora`](#contract-vllm_mlx.worker.MLXWorker.pin_lora) | method | `MLXWorker.pin_lora(lora_id: int) -> bool` | Report that pinning a LoRA adapter is unsupported. | [#L233-L236](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L233-L236) |
| [`MLXWorker.list_loras`](#contract-vllm_mlx.worker.MLXWorker.list_loras) | method | `MLXWorker.list_loras() -> set[int]` | Return the empty set because runtime LoRA adapters are unsupported. | [#L238-L241](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L238-L241) |
| [`MLXWorker.sleep`](#contract-vllm_mlx.worker.MLXWorker.sleep) | method | `MLXWorker.sleep(level: int = 1) -> None` | Leave the worker active because MLX unified memory has no sleep mode. | [#L244-L247](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L244-L247) |
| [`MLXWorker.wake_up`](#contract-vllm_mlx.worker.MLXWorker.wake_up) | method | `MLXWorker.wake_up(tags: list[str] \| None = None) -> None` | Perform no work because the MLX worker never enters sleep mode. | [#L249-L252](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L249-L252) |
| [`MLXWorker.vocab_size`](#contract-vllm_mlx.worker.MLXWorker.vocab_size) | method | `MLXWorker.vocab_size() -> int` | Get vocabulary size. | [#L255-L257](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L255-L257) |
| [`MLXWorker.get_cache_block_size_bytes`](#contract-vllm_mlx.worker.MLXWorker.get_cache_block_size_bytes) | method | `MLXWorker.get_cache_block_size_bytes() -> int` | Get size of a cache block in bytes. | [#L259-L271](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L259-L271) |
| [`MLXWorker.profile`](#contract-vllm_mlx.worker.MLXWorker.profile) | method | `MLXWorker.profile(is_start: bool = True) -> None` | Profiling (not yet implemented for MLX). | [#L273-L275](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L273-L275) |
| [`MLXWorker.__repr__`](#contract-vllm_mlx.worker.MLXWorker.__repr__) | method | `MLXWorker.__repr__() -> str` | Method `MLXWorker.__repr__` returns `f'<MLXWorker rank={self.rank} local_rank={self.local_rank}>'`. | [#L277-L278](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/worker.py#L277-L278) |
