# `vllm_mlx.model_registry`

Registry-backed multi-model serving with memory-budget eviction.

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

## 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.model_registry
    options:
      members:
        - logger
        - ModelOwnershipError
        - _ModelOwnershipRegistry
        - _ownership_registry
        - get_registry
        - ContentionStrategy
        - EngineFactory
        - RegistryServeDefaults
        - ContentionPolicy
        - RegistryManagerConfig
        - RegisteredModel
        - ResolvedModelConfig
        - LoadedModel
        - PendingLoad
        - ModelLease
        - _clone_scheduler_config
        - _parse_memory_budget_bytes
        - _safe_available_memory_bytes
        - _device_working_set_bytes
        - MemoryBudgetReport
        - build_memory_budget_report
        - log_memory_budget_report
        - _estimate_model_bytes_from_source
        - load_registry_config
        - ModelManager
      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.model_registry.ModelOwnershipError" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelOwnershipError</code> · class</summary>

```python
vllm_mlx.model_registry.ModelOwnershipError()
```

Raised when an EngineCore attempts to use a model already in use.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Constructs: `vllm_mlx.model_registry.ModelOwnershipError`

**Exceptions and behavior**

Class `ModelOwnershipError` derives from `RuntimeError` and declares 0 direct member(s).
No direct `raise` statement appears in this definition.

[View source #L38-L39](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L38-L39).

</details>

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

```python
vllm_mlx.model_registry._ModelOwnershipRegistry()
```

Process-local model ownership guard used by EngineCore.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Constructs: `vllm_mlx.model_registry._ModelOwnershipRegistry`

**Exceptions and behavior**

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

[View source #L42-L82](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L42-L82).

</details>

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

```python
vllm_mlx.model_registry._ModelOwnershipRegistry.__init__() -> None
```

Method `_ModelOwnershipRegistry.__init__` updates `self._owners`.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `_ModelOwnershipRegistry.__init__` updates `self._owners`.
No direct `raise` statement appears in this definition.

[View source #L45-L46](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L45-L46).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry._ModelOwnershipRegistry.acquire" markdown="1">
<summary><code>vllm_mlx.model_registry._ModelOwnershipRegistry.acquire</code> · method</summary>

```python
vllm_mlx.model_registry._ModelOwnershipRegistry.acquire(*, model: Any, engine: Any, engine_id: str, force: bool = True) -> None
```

Method `_ModelOwnershipRegistry.acquire` calls `id`, `self._owners.get`, `ModelOwnershipError`; can raise `ModelOwnershipError`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model` | `Any` | `yes` | `none` | Required keyword-only input. |
| `engine` | `Any` | `yes` | `none` | Required keyword-only input. |
| `engine_id` | `str` | `yes` | `none` | Required keyword-only input. |
| `force` | `bool` | `no` | `True` | Optional keyword-only input; defaults to `True`. |

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `_ModelOwnershipRegistry.acquire` calls `id`, `self._owners.get`, `ModelOwnershipError`; can raise `ModelOwnershipError`.
Directly raised exceptions: `ModelOwnershipError`.

[View source #L48-L63](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L48-L63).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry._ModelOwnershipRegistry.release" markdown="1">
<summary><code>vllm_mlx.model_registry._ModelOwnershipRegistry.release</code> · method</summary>

```python
vllm_mlx.model_registry._ModelOwnershipRegistry.release(model: Any, engine_id: str) -> None
```

Method `_ModelOwnershipRegistry.release` calls `id`, `self._owners.get`, `self._owners.pop`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model` | `Any` | `yes` | `none` | Required positional or keyword input. |
| `engine_id` | `str` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `_ModelOwnershipRegistry.release` calls `id`, `self._owners.get`, `self._owners.pop`.
No direct `raise` statement appears in this definition.

[View source #L65-L69](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L65-L69).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry._ModelOwnershipRegistry.is_owned" markdown="1">
<summary><code>vllm_mlx.model_registry._ModelOwnershipRegistry.is_owned</code> · method</summary>

```python
vllm_mlx.model_registry._ModelOwnershipRegistry.is_owned(model: Any) -> tuple[bool, str | None]
```

Method `_ModelOwnershipRegistry.is_owned` calls `id`, `self._owners.get`; has 2 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model` | `Any` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `tuple[bool, str | None]`
- Direct return expressions: `(True, owner)`; `(False, None)`

**Exceptions and behavior**

Method `_ModelOwnershipRegistry.is_owned` calls `id`, `self._owners.get`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L71-L76](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L71-L76).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry._ModelOwnershipRegistry.get_stats" markdown="1">
<summary><code>vllm_mlx.model_registry._ModelOwnershipRegistry.get_stats</code> · method</summary>

```python
vllm_mlx.model_registry._ModelOwnershipRegistry.get_stats() -> dict[str, Any]
```

Method `_ModelOwnershipRegistry.get_stats` calls `len`; returns `{'total_entries': len(self._owners), 'active_owners': len(self._owners)}`.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `dict[str, Any]`
- Direct return expressions: `{'total_entries': len(self._owners), 'active_owners': len(self._owners)}`

**Exceptions and behavior**

Method `_ModelOwnershipRegistry.get_stats` calls `len`; returns `{'total_entries': len(self._owners), 'active_owners': len(self._owners)}`.
No direct `raise` statement appears in this definition.

[View source #L78-L82](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L78-L82).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.get_registry" markdown="1">
<summary><code>vllm_mlx.model_registry.get_registry</code> · function</summary>

```python
vllm_mlx.model_registry.get_registry() -> _ModelOwnershipRegistry
```

Return the global model ownership registry used by EngineCore.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `_ModelOwnershipRegistry`
- Direct return expressions: `_ownership_registry`

**Exceptions and behavior**

Function `get_registry` returns `_ownership_registry`.
No direct `raise` statement appears in this definition.

[View source #L88-L90](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L88-L90).

</details>

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

```python
vllm_mlx.model_registry.RegistryServeDefaults(continuous_batching: bool, force_mllm: bool, enable_mtp: bool, prefill_step_size: int, specprefill_enabled: bool, specprefill_threshold: int, specprefill_keep_pct: float, specprefill_backbone_pct: float, specprefill_draft_model: str | None, stream_interval: int, gpu_memory_utilization: float, scheduler_config: SchedulerConfig | None, max_tokens: int, download_config: DownloadConfig)
```

Global serve defaults inherited by registry entries.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `continuous_batching` | `bool` | `yes` | `none` | Required constructor field. |
| `force_mllm` | `bool` | `yes` | `none` | Required constructor field. |
| `enable_mtp` | `bool` | `yes` | `none` | Required constructor field. |
| `prefill_step_size` | `int` | `yes` | `none` | Required constructor field. |
| `specprefill_enabled` | `bool` | `yes` | `none` | Required constructor field. |
| `specprefill_threshold` | `int` | `yes` | `none` | Required constructor field. |
| `specprefill_keep_pct` | `float` | `yes` | `none` | Required constructor field. |
| `specprefill_backbone_pct` | `float` | `yes` | `none` | Required constructor field. |
| `specprefill_draft_model` | `str \| None` | `yes` | `none` | Required constructor field. |
| `stream_interval` | `int` | `yes` | `none` | Required constructor field. |
| `gpu_memory_utilization` | `float` | `yes` | `none` | Required constructor field. |
| `scheduler_config` | `SchedulerConfig \| None` | `yes` | `none` | Required constructor field. |
| `max_tokens` | `int` | `yes` | `none` | Required constructor field. |
| `download_config` | `DownloadConfig` | `yes` | `none` | Required constructor field. |

**Returns**

- Constructs: `vllm_mlx.model_registry.RegistryServeDefaults`

**Exceptions and behavior**

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

[View source #L109-L125](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L109-L125).

</details>

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

```python
vllm_mlx.model_registry.ContentionPolicy(strategy: ContentionStrategy = 'wait_then_fail', wait_timeout_s: float | None = 30.0, preempt_after_s: float | None = None)
```

Policy used when a new model cannot fit inside the memory budget.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `strategy` | `ContentionStrategy` | `no` | `'wait_then_fail'` | Optional constructor field; defaults to `'wait_then_fail'`. |
| `wait_timeout_s` | `float \| None` | `no` | `30.0` | Optional constructor field; defaults to `30.0`. |
| `preempt_after_s` | `float \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |

**Returns**

- Constructs: `vllm_mlx.model_registry.ContentionPolicy`

**Exceptions and behavior**

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

[View source #L129-L134](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L129-L134).

</details>

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

```python
vllm_mlx.model_registry.RegistryManagerConfig(memory_budget_bytes: int, policy: ContentionPolicy)
```

Global registry manager configuration.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `memory_budget_bytes` | `int` | `yes` | `none` | Required constructor field. |
| `policy` | `ContentionPolicy` | `yes` | `none` | Required constructor field. |

**Returns**

- Constructs: `vllm_mlx.model_registry.RegistryManagerConfig`

**Exceptions and behavior**

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

[View source #L138-L142](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L138-L142).

</details>

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

```python
vllm_mlx.model_registry.RegisteredModel(name: str, source: str, preload: bool = False, continuous_batching: bool | None = None, force_mllm: bool | None = None, enable_mtp: bool | None = None, prefill_step_size: int | None = None, specprefill_enabled: bool | None = None, specprefill_threshold: int | None = None, specprefill_keep_pct: float | None = None, specprefill_backbone_pct: float | None = None, specprefill_draft_model: str | None = None, stream_interval: int | None = None, gpu_memory_utilization: float | None = None, estimated_memory_bytes: int | None = None)
```

One configured model entry.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `str` | `yes` | `none` | Required constructor field. |
| `source` | `str` | `yes` | `none` | Required constructor field. |
| `preload` | `bool` | `no` | `False` | Optional constructor field; defaults to `False`. |
| `continuous_batching` | `bool \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |
| `force_mllm` | `bool \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |
| `enable_mtp` | `bool \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |
| `prefill_step_size` | `int \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |
| `specprefill_enabled` | `bool \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |
| `specprefill_threshold` | `int \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |
| `specprefill_keep_pct` | `float \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |
| `specprefill_backbone_pct` | `float \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |
| `specprefill_draft_model` | `str \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |
| `stream_interval` | `int \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |
| `gpu_memory_utilization` | `float \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |
| `estimated_memory_bytes` | `int \| None` | `no` | `None` | Optional constructor field; defaults to `None`. |

**Returns**

- Constructs: `vllm_mlx.model_registry.RegisteredModel`

**Exceptions and behavior**

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

[View source #L146-L163](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L146-L163).

</details>

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

```python
vllm_mlx.model_registry.ResolvedModelConfig(entry: RegisteredModel, resolved_source: str, continuous_batching: bool, force_mllm: bool, enable_mtp: bool, prefill_step_size: int, specprefill_enabled: bool, specprefill_threshold: int, specprefill_keep_pct: float, specprefill_backbone_pct: float, specprefill_draft_model: str | None, stream_interval: int, gpu_memory_utilization: float, scheduler_config: SchedulerConfig | None, estimated_memory_bytes: int)
```

Effective configuration for a loaded model.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `entry` | `RegisteredModel` | `yes` | `none` | Required constructor field. |
| `resolved_source` | `str` | `yes` | `none` | Required constructor field. |
| `continuous_batching` | `bool` | `yes` | `none` | Required constructor field. |
| `force_mllm` | `bool` | `yes` | `none` | Required constructor field. |
| `enable_mtp` | `bool` | `yes` | `none` | Required constructor field. |
| `prefill_step_size` | `int` | `yes` | `none` | Required constructor field. |
| `specprefill_enabled` | `bool` | `yes` | `none` | Required constructor field. |
| `specprefill_threshold` | `int` | `yes` | `none` | Required constructor field. |
| `specprefill_keep_pct` | `float` | `yes` | `none` | Required constructor field. |
| `specprefill_backbone_pct` | `float` | `yes` | `none` | Required constructor field. |
| `specprefill_draft_model` | `str \| None` | `yes` | `none` | Required constructor field. |
| `stream_interval` | `int` | `yes` | `none` | Required constructor field. |
| `gpu_memory_utilization` | `float` | `yes` | `none` | Required constructor field. |
| `scheduler_config` | `SchedulerConfig \| None` | `yes` | `none` | Required constructor field. |
| `estimated_memory_bytes` | `int` | `yes` | `none` | Required constructor field. |

**Returns**

- Constructs: `vllm_mlx.model_registry.ResolvedModelConfig`

**Exceptions and behavior**

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

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

</details>

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

```python
vllm_mlx.model_registry.LoadedModel(config: ResolvedModelConfig, engine: BaseEngine, loaded_at: float = field(default_factory=time.time), last_used_at: float = field(default_factory=time.time), active_requests: int = 0, active_tasks: set[asyncio.Task[Any]] = field(default_factory=set), preempting: bool = False)
```

Runtime state for a loaded engine.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `config` | `ResolvedModelConfig` | `yes` | `none` | Required constructor field. |
| `engine` | `BaseEngine` | `yes` | `none` | Required constructor field. |
| `loaded_at` | `float` | `no` | `field(default_factory=time.time)` | Optional constructor field; defaults to `field(default_factory=time.time)`. |
| `last_used_at` | `float` | `no` | `field(default_factory=time.time)` | Optional constructor field; defaults to `field(default_factory=time.time)`. |
| `active_requests` | `int` | `no` | `0` | Optional constructor field; defaults to `0`. |
| `active_tasks` | `set[asyncio.Task[Any]]` | `no` | `field(default_factory=set)` | Optional constructor field; defaults to `field(default_factory=set)`. |
| `preempting` | `bool` | `no` | `False` | Optional constructor field; defaults to `False`. |

**Returns**

- Constructs: `vllm_mlx.model_registry.LoadedModel`

**Exceptions and behavior**

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

[View source #L188-L197](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L188-L197).

</details>

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

```python
vllm_mlx.model_registry.PendingLoad(model_name: str, required_bytes: int, future: asyncio.Future[LoadedModel])
```

A reserved model load in progress.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model_name` | `str` | `yes` | `none` | Required constructor field. |
| `required_bytes` | `int` | `yes` | `none` | Required constructor field. |
| `future` | `asyncio.Future[LoadedModel]` | `yes` | `none` | Required constructor field. |

**Returns**

- Constructs: `vllm_mlx.model_registry.PendingLoad`

**Exceptions and behavior**

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

[View source #L201-L206](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L201-L206).

</details>

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

```python
vllm_mlx.model_registry.ModelLease(manager: 'ModelManager | None', model_name: str, engine: BaseEngine, release_cb: Callable[[], Awaitable[None]])
```

Active lease for a loaded model.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `manager` | `'ModelManager \| None'` | `yes` | `none` | Required constructor field. |
| `model_name` | `str` | `yes` | `none` | Required constructor field. |
| `engine` | `BaseEngine` | `yes` | `none` | Required constructor field. |
| `release_cb` | `Callable[[], Awaitable[None]]` | `yes` | `none` | Required constructor field. |

**Returns**

- Constructs: `vllm_mlx.model_registry.ModelLease`

**Exceptions and behavior**

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

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

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelLease.release" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelLease.release</code> · method</summary>

```python
async vllm_mlx.model_registry.ModelLease.release() -> None
```

Release this lease once and allow the model to become evictable.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `None`
- Direct return expressions: `None`

**Exceptions and behavior**

Method `ModelLease.release` updates `self.manager`; calls `self.release_cb`; awaits asynchronous work; returns `None`.
No direct `raise` statement appears in this definition.

[View source #L218-L225](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L218-L225).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelLease.__aenter__" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelLease.__aenter__</code> · method</summary>

```python
async vllm_mlx.model_registry.ModelLease.__aenter__() -> 'ModelLease'
```

Method `ModelLease.__aenter__` returns `self`.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `'ModelLease'`
- Direct return expressions: `self`

**Exceptions and behavior**

Method `ModelLease.__aenter__` returns `self`.
No direct `raise` statement appears in this definition.

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

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelLease.__aexit__" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelLease.__aexit__</code> · method</summary>

```python
async vllm_mlx.model_registry.ModelLease.__aexit__(exc_type, exc, tb) -> None
```

Method `ModelLease.__aexit__` calls `self.release`; awaits asynchronous work.

**Parameters**

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

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `ModelLease.__aexit__` calls `self.release`; awaits asynchronous work.
No direct `raise` statement appears in this definition.

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

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry._clone_scheduler_config" markdown="1">
<summary><code>vllm_mlx.model_registry._clone_scheduler_config</code> · function</summary>

```python
vllm_mlx.model_registry._clone_scheduler_config(config: SchedulerConfig | None) -> SchedulerConfig | None
```

Clone a SchedulerConfig so per-model overrides do not mutate globals.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `config` | `SchedulerConfig \| None` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `SchedulerConfig | None`
- Direct return expressions: `None`; `SchedulerConfig(**vars(config))`

**Exceptions and behavior**

Function `_clone_scheduler_config` calls `SchedulerConfig`, `vars`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

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

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry._parse_memory_budget_bytes" markdown="1">
<summary><code>vllm_mlx.model_registry._parse_memory_budget_bytes</code> · function</summary>

```python
vllm_mlx.model_registry._parse_memory_budget_bytes(value: Any) -> int
```

Parse a memory budget from bytes, MB, or GB.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `value` | `Any` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `int`
- Direct return expressions: `int(float(value) * 1024 ** 3)`; `int(float(raw[:-2]) * 1024 ** 3)`; `int(float(raw[:-2]) * 1024 ** 2)`; `int(float(raw[:-1]))`; `int(float(raw) * 1024 ** 3)`

**Exceptions and behavior**

Function `_parse_memory_budget_bytes` calls `ValueError`, `isinstance`, `int`, `float`; can raise `ValueError`, `TypeError`; has 5 explicit return paths.
Directly raised exceptions: `ValueError`, `TypeError`.

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

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry._safe_available_memory_bytes" markdown="1">
<summary><code>vllm_mlx.model_registry._safe_available_memory_bytes</code> · function</summary>

```python
vllm_mlx.model_registry._safe_available_memory_bytes() -> int
```

Best-effort available system memory.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `int`
- Direct return expressions: `0`; `int(psutil.virtual_memory().available)`

**Exceptions and behavior**

Function `_safe_available_memory_bytes` calls `int`, `psutil.virtual_memory`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

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

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry._device_working_set_bytes" markdown="1">
<summary><code>vllm_mlx.model_registry._device_working_set_bytes</code> · function</summary>

```python
vllm_mlx.model_registry._device_working_set_bytes() -> int | None
```

Best-effort Metal recommended working-set size, or None when unavailable.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `int | None`
- Direct return expressions: `None`; `working_set or None`

**Exceptions and behavior**

Function `_device_working_set_bytes` calls `mx.metal.is_available`, `mx.device_info`, `info.get`, `int`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L266-L282](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L266-L282).

</details>

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

```python
vllm_mlx.model_registry.MemoryBudgetReport(budget_bytes: int, device_working_set_bytes: int | None, gpu_memory_utilization: float | None, gpu_memory_utilization_source: str | None, per_engine_cache_limit_bytes: int | None, per_engine_cache_percent: float | None, continuous_batching_entries: int, total_entries: int)
```

Reconciliation of the manager weight budget with the Metal ceiling.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `budget_bytes` | `int` | `yes` | `none` | Required constructor field. |
| `device_working_set_bytes` | `int \| None` | `yes` | `none` | Required constructor field. |
| `gpu_memory_utilization` | `float \| None` | `yes` | `none` | Required constructor field. |
| `gpu_memory_utilization_source` | `str \| None` | `yes` | `none` | Required constructor field. |
| `per_engine_cache_limit_bytes` | `int \| None` | `yes` | `none` | Required constructor field. |
| `per_engine_cache_percent` | `float \| None` | `yes` | `none` | Required constructor field. |
| `continuous_batching_entries` | `int` | `yes` | `none` | Required constructor field. |
| `total_entries` | `int` | `yes` | `none` | Required constructor field. |

**Returns**

- Constructs: `vllm_mlx.model_registry.MemoryBudgetReport`

**Exceptions and behavior**

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

[View source #L286-L339](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L286-L339).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.MemoryBudgetReport.allocation_ceiling_bytes" markdown="1">
<summary><code>vllm_mlx.model_registry.MemoryBudgetReport.allocation_ceiling_bytes</code> · method</summary>

```python
vllm_mlx.model_registry.MemoryBudgetReport.allocation_ceiling_bytes() -> int | None
```

Metal soft allocation limit that will be installed at engine start.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `int | None`
- Direct return expressions: `None`; `int(self.device_working_set_bytes * self.gpu_memory_utilization)`

**Exceptions and behavior**

Method `MemoryBudgetReport.allocation_ceiling_bytes` calls `int`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L313-L322](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L313-L322).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.MemoryBudgetReport.exceeds_ceiling" markdown="1">
<summary><code>vllm_mlx.model_registry.MemoryBudgetReport.exceeds_ceiling</code> · method</summary>

```python
vllm_mlx.model_registry.MemoryBudgetReport.exceeds_ceiling() -> bool
```

True when the weights budget alone cannot fit under the ceiling.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `bool`
- Direct return expressions: `ceiling is not None and self.budget_bytes > ceiling`

**Exceptions and behavior**

Method `MemoryBudgetReport.exceeds_ceiling` returns `ceiling is not None and self.budget_bytes > ceiling`.
No direct `raise` statement appears in this definition.

[View source #L325-L331](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L325-L331).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.MemoryBudgetReport.cache_limit_exceeds_ceiling" markdown="1">
<summary><code>vllm_mlx.model_registry.MemoryBudgetReport.cache_limit_exceeds_ceiling</code> · method</summary>

```python
vllm_mlx.model_registry.MemoryBudgetReport.cache_limit_exceeds_ceiling() -> bool
```

True when one engine's prefix cache could alone fill the ceiling.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `bool`
- Direct return expressions: `False`; `self.per_engine_cache_limit_bytes >= ceiling`

**Exceptions and behavior**

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

[View source #L334-L339](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L334-L339).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.build_memory_budget_report" markdown="1">
<summary><code>vllm_mlx.model_registry.build_memory_budget_report</code> · function</summary>

```python
vllm_mlx.model_registry.build_memory_budget_report(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, device_working_set_bytes: int | None = None) -> MemoryBudgetReport
```

Reconcile the manager weight budget against the Metal allocation ceiling.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `manager_config` | `RegistryManagerConfig` | `yes` | `none` | Required positional or keyword input. |
| `registry` | `dict[str, RegisteredModel]` | `yes` | `none` | Required positional or keyword input. |
| `defaults` | `RegistryServeDefaults` | `yes` | `none` | Required positional or keyword input. |
| `device_working_set_bytes` | `int \| None` | `no` | `None` | Optional keyword-only input; defaults to `None`. |

**Returns**

- Type: `MemoryBudgetReport`
- Direct return expressions: `MemoryBudgetReport(budget_bytes=manager_config.memory_budget_bytes, device_working_set_bytes=device_working_set_bytes, …`

**Exceptions and behavior**

Function `build_memory_budget_report` calls `_device_working_set_bytes`, `sorted`, `candidates.append`, `len`; returns `MemoryBudgetReport(budget_bytes=manager_config.memory_budget_bytes, device_working_set_bytes=device_working_set_bytes, …`.
No direct `raise` statement appears in this definition.

[View source #L342-L421](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L342-L421).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.log_memory_budget_report" markdown="1">
<summary><code>vllm_mlx.model_registry.log_memory_budget_report</code> · function</summary>

```python
vllm_mlx.model_registry.log_memory_budget_report(report: MemoryBudgetReport) -> None
```

Log the budget/ceiling reconciliation, warning when they conflict.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `report` | `MemoryBudgetReport` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `None`
- Direct return expressions: `None`

**Exceptions and behavior**

Function `log_memory_budget_report` calls `logger.info`, `logger.warning`; returns `None`.
No direct `raise` statement appears in this definition.

[View source #L424-L502](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L424-L502).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry._estimate_model_bytes_from_source" markdown="1">
<summary><code>vllm_mlx.model_registry._estimate_model_bytes_from_source</code> · function</summary>

```python
vllm_mlx.model_registry._estimate_model_bytes_from_source(source: str) -> int
```

Estimate model footprint from local artifact size when possible.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `source` | `str` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `int`
- Direct return expressions: `0`; `path.stat().st_size if path.suffix in {'.safetensors', '.gguf'} else 0`; `total`

**Exceptions and behavior**

Function `_estimate_model_bytes_from_source` calls `Path`, `path.exists`, `path.is_file`, `path.stat`; has 3 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L505-L521](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L505-L521).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.load_registry_config" markdown="1">
<summary><code>vllm_mlx.model_registry.load_registry_config</code> · function</summary>

```python
vllm_mlx.model_registry.load_registry_config(config_path: str | os.PathLike[str], defaults: RegistryServeDefaults) -> tuple[RegistryManagerConfig, dict[str, RegisteredModel]]
```

Load and validate the models registry YAML file.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `config_path` | `str \| os.PathLike[str]` | `yes` | `none` | Required positional or keyword input. |
| `defaults` | `RegistryServeDefaults` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `tuple[RegistryManagerConfig, dict[str, RegisteredModel]]`
- Direct return expressions: `(manager, registry)`

**Exceptions and behavior**

Function `load_registry_config` calls `yaml.safe_load`, `Path(config_path).read_text`, `Path`, `raw.get`; can raise `ValueError`; returns `(manager, registry)`.
Directly raised exceptions: `ValueError`.

[View source #L524-L621](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L524-L621).

</details>

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

```python
vllm_mlx.model_registry.ModelManager(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, engine_factory: EngineFactory | None = None)
```

Registry-backed model manager with lazy load and memory-budget eviction.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `manager_config` | `RegistryManagerConfig` | `yes` | `none` | Required positional or keyword input. |
| `registry` | `dict[str, RegisteredModel]` | `yes` | `none` | Required positional or keyword input. |
| `defaults` | `RegistryServeDefaults` | `yes` | `none` | Required positional or keyword input. |
| `engine_factory` | `EngineFactory \| None` | `no` | `None` | Optional keyword-only input; defaults to `None`. |

**Returns**

- Constructs: `vllm_mlx.model_registry.ModelManager`

**Exceptions and behavior**

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

[View source #L624-L1201](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L624-L1201).

</details>

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

```python
vllm_mlx.model_registry.ModelManager.__init__(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, engine_factory: EngineFactory | None = None) -> None
```

Method `ModelManager.__init__` updates `self._config`, `self._registry`, `self._defaults`, `self._engine_factory`; calls `asyncio.Condition`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `manager_config` | `RegistryManagerConfig` | `yes` | `none` | Required positional or keyword input. |
| `registry` | `dict[str, RegisteredModel]` | `yes` | `none` | Required positional or keyword input. |
| `defaults` | `RegistryServeDefaults` | `yes` | `none` | Required positional or keyword input. |
| `engine_factory` | `EngineFactory \| None` | `no` | `None` | Optional keyword-only input; defaults to `None`. |

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `ModelManager.__init__` updates `self._config`, `self._registry`, `self._defaults`, `self._engine_factory`; calls `asyncio.Condition`.
No direct `raise` statement appears in this definition.

[View source #L627-L643](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L627-L643).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager.memory_budget_bytes" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager.memory_budget_bytes</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager.memory_budget_bytes() -> int
```

Return the registry's configured resident-model memory budget.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `int`
- Direct return expressions: `self._config.memory_budget_bytes`

**Exceptions and behavior**

Method `ModelManager.memory_budget_bytes` returns `self._config.memory_budget_bytes`.
No direct `raise` statement appears in this definition.

[View source #L646-L649](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L646-L649).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager.registered_model_names" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager.registered_model_names</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager.registered_model_names() -> list[str]
```

Return sorted list of all registered model names.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `list[str]`
- Direct return expressions: `sorted(self._registry.keys())`

**Exceptions and behavior**

Method `ModelManager.registered_model_names` calls `sorted`, `self._registry.keys`; returns `sorted(self._registry.keys())`.
No direct `raise` statement appears in this definition.

[View source #L652-L654](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L652-L654).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager.has_model" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager.has_model</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager.has_model(model_name: str) -> bool
```

Return whether a model name is present in the serving registry.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model_name` | `str` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `bool`
- Direct return expressions: `model_name in self._registry`

**Exceptions and behavior**

Method `ModelManager.has_model` returns `model_name in self._registry`.
No direct `raise` statement appears in this definition.

[View source #L656-L659](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L656-L659).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager.list_models" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager.list_models</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager.list_models() -> list[dict[str, Any]]
```

Return registry state for /v1/models.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `list[dict[str, Any]]`
- Direct return expressions: `data`

**Exceptions and behavior**

Method `ModelManager.list_models` calls `self._registry.items`, `self._loaded.get`, `self._unloading.get`, `self._loading.get`; returns `data`.
No direct `raise` statement appears in this definition.

[View source #L661-L699](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L661-L699).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager.preload" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager.preload</code> · method</summary>

```python
async vllm_mlx.model_registry.ModelManager.preload() -> None
```

Preload any entries marked preload=true.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `ModelManager.preload` calls `self._registry.values`, `self.acquire`, `lease.release`; awaits asynchronous work.
No direct `raise` statement appears in this definition.

[View source #L701-L706](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L701-L706).

</details>

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

```python
async vllm_mlx.model_registry.ModelManager.shutdown() -> None
```

Stop and unload every loaded engine.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `ModelManager.shutdown` updates `self._shutting_down`; calls `set`, `self._loading.values`, `self._loaded.values`, `cancel_tasks.update`; awaits asynchronous work.
No direct `raise` statement appears in this definition.

[View source #L708-L739](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L708-L739).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager.acquire" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager.acquire</code> · method</summary>

```python
async vllm_mlx.model_registry.ModelManager.acquire(model_name: str) -> ModelLease
```

Acquire a lease for a configured model.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model_name` | `str` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `ModelLease`
- Direct return expressions: `claimed`

**Exceptions and behavior**

Method `ModelManager.acquire` calls `KeyError`, `time.monotonic`, `set`, `RuntimeError`; awaits asynchronous work; can raise `KeyError`, `RuntimeError`; returns `claimed`.
Directly raised exceptions: `KeyError`, `RuntimeError`.

[View source #L741-L819](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L741-L819).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager.release" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager.release</code> · method</summary>

```python
async vllm_mlx.model_registry.ModelManager.release(model_name: str) -> None
```

Release a previously acquired model lease.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model_name` | `str` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `None`
- Direct return expressions: `None`

**Exceptions and behavior**

Method `ModelManager.release` calls `self._loaded.get`, `max`, `time.time`, `asyncio.current_task`; awaits asynchronous work; returns `None`.
No direct `raise` statement appears in this definition.

[View source #L821-L842](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L821-L842).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._claim_loaded_locked" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._claim_loaded_locked</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._claim_loaded_locked(model_name: str, *, loaded_override: LoadedModel | None = None) -> ModelLease | None
```

Method `ModelManager._claim_loaded_locked` calls `self._loaded.get`, `time.time`, `asyncio.current_task`, `loaded.active_tasks.add`; has 2 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model_name` | `str` | `yes` | `none` | Required positional or keyword input. |
| `loaded_override` | `LoadedModel \| None` | `no` | `None` | Optional keyword-only input; defaults to `None`. |

**Returns**

- Type: `ModelLease | None`
- Direct return expressions: `None`; `ModelLease(manager=self, model_name=model_name, engine=loaded.engine, release_cb=_release)`

**Exceptions and behavior**

Method `ModelManager._claim_loaded_locked` calls `self._loaded.get`, `time.time`, `asyncio.current_task`, `loaded.active_tasks.add`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L844-L874](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L844-L874).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._claim_loaded_locked._release" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._claim_loaded_locked._release</code> · nested function</summary>

```python
async vllm_mlx.model_registry.ModelManager._claim_loaded_locked._release() -> None
```

Nested Function `ModelManager._claim_loaded_locked._release` calls `self.release`; awaits asynchronous work.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `None`

**Exceptions and behavior**

Nested Function `ModelManager._claim_loaded_locked._release` calls `self.release`; awaits asynchronous work.
No direct `raise` statement appears in this definition.

[View source #L866-L867](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L866-L867).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._execute_load" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._execute_load</code> · method</summary>

```python
async vllm_mlx.model_registry.ModelManager._execute_load(pending: PendingLoad) -> LoadedModel
```

Instantiate a reserved model load outside the manager lock.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `pending` | `PendingLoad` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `LoadedModel`
- Direct return expressions: `loaded`

**Exceptions and behavior**

Method `ModelManager._execute_load` calls `self._resolve_source`, `self._instantiate_model`, `self._loading.pop`, `current.future.done`; awaits asynchronous work; can raise `RuntimeError`; returns `loaded`.
Directly raised exceptions: `RuntimeError`.

[View source #L876-L913](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L876-L913).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._wait_for_change" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._wait_for_change</code> · method</summary>

```python
async vllm_mlx.model_registry.ModelManager._wait_for_change(timeout: float | None) -> None
```

Method `ModelManager._wait_for_change` calls `self._condition.wait`, `RuntimeError`, `asyncio.wait_for`; awaits asynchronous work; can raise `RuntimeError`; returns `None`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `timeout` | `float \| None` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `None`
- Direct return expressions: `None`

**Exceptions and behavior**

Method `ModelManager._wait_for_change` calls `self._condition.wait`, `RuntimeError`, `asyncio.wait_for`; awaits asynchronous work; can raise `RuntimeError`; returns `None`.
Directly raised exceptions: `RuntimeError`.

[View source #L915-L922](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L915-L922).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._run_unloads" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._run_unloads</code> · method</summary>

```python
async vllm_mlx.model_registry.ModelManager._run_unloads(unloads: list[LoadedModel]) -> None
```

Method `ModelManager._run_unloads` calls `loaded.engine.stop`, `self._unloading.pop`, `self._condition.notify_all`; awaits asynchronous work.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `unloads` | `list[LoadedModel]` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `ModelManager._run_unloads` calls `loaded.engine.stop`, `self._unloading.pop`, `self._condition.notify_all`; awaits asynchronous work.
No direct `raise` statement appears in this definition.

[View source #L924-L931](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L924-L931).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._reserve_load_locked" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._reserve_load_locked</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._reserve_load_locked(model_name: str, required_bytes: int) -> PendingLoad
```

Method `ModelManager._reserve_load_locked` calls `asyncio.get_running_loop().create_future`, `asyncio.get_running_loop`, `PendingLoad`; returns `pending`.

**Parameters**

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

**Returns**

- Type: `PendingLoad`
- Direct return expressions: `pending`

**Exceptions and behavior**

Method `ModelManager._reserve_load_locked` calls `asyncio.get_running_loop().create_future`, `asyncio.get_running_loop`, `PendingLoad`; returns `pending`.
No direct `raise` statement appears in this definition.

[View source #L933-L941](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L933-L941).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._begin_unload_locked" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._begin_unload_locked</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._begin_unload_locked(model_name: str) -> LoadedModel
```

Method `ModelManager._begin_unload_locked` calls `self._loaded.pop`; returns `loaded`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model_name` | `str` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `LoadedModel`
- Direct return expressions: `loaded`

**Exceptions and behavior**

Method `ModelManager._begin_unload_locked` calls `self._loaded.pop`; returns `loaded`.
No direct `raise` statement appears in this definition.

[View source #L943-L946](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L943-L946).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._collect_idle_unloads_locked" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._collect_idle_unloads_locked</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._collect_idle_unloads_locked(requested_model: str, required_bytes: int) -> list[LoadedModel]
```

Method `ModelManager._collect_idle_unloads_locked` calls `self._committed_bytes_locked`, `sorted`, `self._loaded.items`, `selected.append`; returns `selected`.

**Parameters**

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

**Returns**

- Type: `list[LoadedModel]`
- Direct return expressions: `selected`

**Exceptions and behavior**

Method `ModelManager._collect_idle_unloads_locked` calls `self._committed_bytes_locked`, `sorted`, `self._loaded.items`, `selected.append`; returns `selected`.
No direct `raise` statement appears in this definition.

[View source #L948-L968](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L948-L968).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._maybe_preempt_locked" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._maybe_preempt_locked</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._maybe_preempt_locked(*, model_name: str, required_bytes: int, start: float) -> set[asyncio.Task[Any]]
```

Method `ModelManager._maybe_preempt_locked` calls `self._should_preempt_locked`, `set`, `self._committed_bytes_locked`, `sorted`; has 2 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model_name` | `str` | `yes` | `none` | Required keyword-only input. |
| `required_bytes` | `int` | `yes` | `none` | Required keyword-only input. |
| `start` | `float` | `yes` | `none` | Required keyword-only input. |

**Returns**

- Type: `set[asyncio.Task[Any]]`
- Direct return expressions: `set()`; `cancel_tasks`

**Exceptions and behavior**

Method `ModelManager._maybe_preempt_locked` calls `self._should_preempt_locked`, `set`, `self._committed_bytes_locked`, `sorted`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L970-L1003](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L970-L1003).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._should_wait_locked" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._should_wait_locked</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._should_wait_locked(start: float) -> bool
```

Method `ModelManager._should_wait_locked` calls `self._remaining_wait_timeout`; has 2 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `start` | `float` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `bool`
- Direct return expressions: `False`; `timeout is None or timeout > 0`

**Exceptions and behavior**

Method `ModelManager._should_wait_locked` calls `self._remaining_wait_timeout`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L1005-L1010](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1005-L1010).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._should_preempt_locked" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._should_preempt_locked</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._should_preempt_locked(start: float) -> bool
```

Method `ModelManager._should_preempt_locked` calls `time.monotonic`; has 3 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `start` | `float` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `bool`
- Direct return expressions: `True`; `False`; `elapsed >= trigger`

**Exceptions and behavior**

Method `ModelManager._should_preempt_locked` calls `time.monotonic`; has 3 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L1012-L1020](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1012-L1020).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._remaining_wait_timeout" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._remaining_wait_timeout</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._remaining_wait_timeout(start: float) -> float | None
```

Method `ModelManager._remaining_wait_timeout` calls `max`, `time.monotonic`; has 2 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `start` | `float` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `float | None`
- Direct return expressions: `None`; `max(timeout - (time.monotonic() - start), 0.0)`

**Exceptions and behavior**

Method `ModelManager._remaining_wait_timeout` calls `max`, `time.monotonic`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L1022-L1026](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1022-L1026).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._can_reserve_locked" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._can_reserve_locked</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._can_reserve_locked(required_bytes: int) -> bool
```

Method `ModelManager._can_reserve_locked` calls `self._committed_bytes_locked`; returns `self._committed_bytes_locked() + required_bytes <= self._config.memory_budget_bytes`.

**Parameters**

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

**Returns**

- Type: `bool`
- Direct return expressions: `self._committed_bytes_locked() + required_bytes <= self._config.memory_budget_bytes`

**Exceptions and behavior**

Method `ModelManager._can_reserve_locked` calls `self._committed_bytes_locked`; returns `self._committed_bytes_locked() + required_bytes <= self._config.memory_budget_bytes`.
No direct `raise` statement appears in this definition.

[View source #L1028-L1032](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1028-L1032).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._committed_bytes_locked" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._committed_bytes_locked</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._committed_bytes_locked() -> int
```

Method `ModelManager._committed_bytes_locked` calls `sum`, `self._loaded.values`, `self._loading.values`, `self._unloading.values`; returns `loaded_bytes + loading_bytes + unloading_bytes`.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `int`
- Direct return expressions: `loaded_bytes + loading_bytes + unloading_bytes`

**Exceptions and behavior**

Method `ModelManager._committed_bytes_locked` calls `sum`, `self._loaded.values`, `self._loading.values`, `self._unloading.values`; returns `loaded_bytes + loading_bytes + unloading_bytes`.
No direct `raise` statement appears in this definition.

[View source #L1034-L1042](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1034-L1042).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._instantiate_model" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._instantiate_model</code> · method</summary>

```python
async vllm_mlx.model_registry.ModelManager._instantiate_model(entry: RegisteredModel, resolved_source: str) -> LoadedModel
```

Method `ModelManager._instantiate_model` calls `self._resolve_model_config`, `self._engine_factory`, `BatchedEngine`, `SimpleEngine`; awaits asynchronous work; returns `LoadedModel(config=config, engine=engine)`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `entry` | `RegisteredModel` | `yes` | `none` | Required positional or keyword input. |
| `resolved_source` | `str` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `LoadedModel`
- Direct return expressions: `LoadedModel(config=config, engine=engine)`

**Exceptions and behavior**

Method `ModelManager._instantiate_model` calls `self._resolve_model_config`, `self._engine_factory`, `BatchedEngine`, `SimpleEngine`; awaits asynchronous work; returns `LoadedModel(config=config, engine=engine)`.
No direct `raise` statement appears in this definition.

[View source #L1044-L1073](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1044-L1073).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._resolve_source" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._resolve_source</code> · method</summary>

```python
async vllm_mlx.model_registry.ModelManager._resolve_source(entry: RegisteredModel) -> str
```

Method `ModelManager._resolve_source` calls `asyncio.to_thread`; awaits asynchronous work; returns `await asyncio.to_thread(self._resolve_source_sync, entry)`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `entry` | `RegisteredModel` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `str`
- Direct return expressions: `await asyncio.to_thread(self._resolve_source_sync, entry)`

**Exceptions and behavior**

Method `ModelManager._resolve_source` calls `asyncio.to_thread`; awaits asynchronous work; returns `await asyncio.to_thread(self._resolve_source_sync, entry)`.
No direct `raise` statement appears in this definition.

[View source #L1075-L1076](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1075-L1076).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._resolve_source_sync" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._resolve_source_sync</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._resolve_source_sync(entry: RegisteredModel) -> str
```

Method `ModelManager._resolve_source_sync` calls `Path(source).exists`, `Path`, `ensure_model_downloaded`, `is_mllm_model`; has 2 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `entry` | `RegisteredModel` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `str`
- Direct return expressions: `source`; `str(downloaded)`

**Exceptions and behavior**

Method `ModelManager._resolve_source_sync` calls `Path(source).exists`, `Path`, `ensure_model_downloaded`, `is_mllm_model`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L1078-L1087](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1078-L1087).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._resolve_estimated_bytes" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._resolve_estimated_bytes</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._resolve_estimated_bytes(entry: RegisteredModel, resolved_source: str) -> int
```

Method `ModelManager._resolve_estimated_bytes` calls `_estimate_model_bytes_from_source`, `Path`, `source_path.exists`, `ValueError`; can raise `ValueError`; has 3 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `entry` | `RegisteredModel` | `yes` | `none` | Required positional or keyword input. |
| `resolved_source` | `str` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `int`
- Direct return expressions: `entry.estimated_memory_bytes`; `estimated`; `max(available // 8, 1)`

**Exceptions and behavior**

Method `ModelManager._resolve_estimated_bytes` calls `_estimate_model_bytes_from_source`, `Path`, `source_path.exists`, `ValueError`; can raise `ValueError`; has 3 explicit return paths.
Directly raised exceptions: `ValueError`.

[View source #L1089-L1121](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1089-L1121).

</details>

<details class="api-contract" id="contract-vllm_mlx.model_registry.ModelManager._resolve_model_config" markdown="1">
<summary><code>vllm_mlx.model_registry.ModelManager._resolve_model_config</code> · method</summary>

```python
vllm_mlx.model_registry.ModelManager._resolve_model_config(entry: RegisteredModel, resolved_source: str) -> ResolvedModelConfig
```

Method `ModelManager._resolve_model_config` calls `_clone_scheduler_config`, `self._resolve_estimated_bytes`, `ResolvedModelConfig`; returns `ResolvedModelConfig(entry=entry, resolved_source=resolved_source, continuous_batching=continuous_batching, force_mllm=f…`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `entry` | `RegisteredModel` | `yes` | `none` | Required positional or keyword input. |
| `resolved_source` | `str` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `ResolvedModelConfig`
- Direct return expressions: `ResolvedModelConfig(entry=entry, resolved_source=resolved_source, continuous_batching=continuous_batching, force_mllm=f…`

**Exceptions and behavior**

Method `ModelManager._resolve_model_config` calls `_clone_scheduler_config`, `self._resolve_estimated_bytes`, `ResolvedModelConfig`; returns `ResolvedModelConfig(entry=entry, resolved_source=resolved_source, continuous_batching=continuous_batching, force_mllm=f…`.
No direct `raise` statement appears in this definition.

[View source #L1123-L1201](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1123-L1201).

</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 |
| --- | --- | --- | --- | --- |
| [`ModelOwnershipError`](#contract-vllm_mlx.model_registry.ModelOwnershipError) | class | `ModelOwnershipError()` | Raised when an EngineCore attempts to use a model already in use. | [#L38-L39](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L38-L39) |
| [`_ModelOwnershipRegistry`](#contract-vllm_mlx.model_registry._ModelOwnershipRegistry) | class | `_ModelOwnershipRegistry()` | Process-local model ownership guard used by EngineCore. | [#L42-L82](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L42-L82) |
| [`_ModelOwnershipRegistry.__init__`](#contract-vllm_mlx.model_registry._ModelOwnershipRegistry.__init__) | method | `_ModelOwnershipRegistry.__init__() -> None` | Method `_ModelOwnershipRegistry.__init__` updates `self._owners`. | [#L45-L46](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L45-L46) |
| [`_ModelOwnershipRegistry.acquire`](#contract-vllm_mlx.model_registry._ModelOwnershipRegistry.acquire) | method | `_ModelOwnershipRegistry.acquire(*, model: Any, engine: Any, engine_id: str, force: bool = True) -> None` | Method `_ModelOwnershipRegistry.acquire` calls `id`, `self._owners.get`, `ModelOwnershipError`; can raise `ModelOwnershipError`. | [#L48-L63](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L48-L63) |
| [`_ModelOwnershipRegistry.release`](#contract-vllm_mlx.model_registry._ModelOwnershipRegistry.release) | method | `_ModelOwnershipRegistry.release(model: Any, engine_id: str) -> None` | Method `_ModelOwnershipRegistry.release` calls `id`, `self._owners.get`, `self._owners.pop`. | [#L65-L69](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L65-L69) |
| [`_ModelOwnershipRegistry.is_owned`](#contract-vllm_mlx.model_registry._ModelOwnershipRegistry.is_owned) | method | `_ModelOwnershipRegistry.is_owned(model: Any) -> tuple[bool, str \| None]` | Method `_ModelOwnershipRegistry.is_owned` calls `id`, `self._owners.get`; has 2 explicit return paths. | [#L71-L76](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L71-L76) |
| [`_ModelOwnershipRegistry.get_stats`](#contract-vllm_mlx.model_registry._ModelOwnershipRegistry.get_stats) | method | `_ModelOwnershipRegistry.get_stats() -> dict[str, Any]` | Method `_ModelOwnershipRegistry.get_stats` calls `len`; returns `{'total_entries': len(self._owners), 'active_owners': len(self._owners)}`. | [#L78-L82](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L78-L82) |
| [`get_registry`](#contract-vllm_mlx.model_registry.get_registry) | function | `get_registry() -> _ModelOwnershipRegistry` | Return the global model ownership registry used by EngineCore. | [#L88-L90](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L88-L90) |
| [`RegistryServeDefaults`](#contract-vllm_mlx.model_registry.RegistryServeDefaults) | class | `RegistryServeDefaults(continuous_batching: bool, force_mllm: bool, enable_mtp: bool, prefill_step_size: int, specprefill_enabled: bool, specprefill_threshold: int, specprefill_keep_pct: float, specprefill_backbone_pct: float, specprefill_draft_model: str \| None, stream_interval: int, gpu_memory_utilization: float, scheduler_config: SchedulerConfig \| None, max_tokens: int, download_config: DownloadConfig)` | Global serve defaults inherited by registry entries. | [#L109-L125](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L109-L125) |
| [`ContentionPolicy`](#contract-vllm_mlx.model_registry.ContentionPolicy) | class | `ContentionPolicy(strategy: ContentionStrategy = 'wait_then_fail', wait_timeout_s: float \| None = 30.0, preempt_after_s: float \| None = None)` | Policy used when a new model cannot fit inside the memory budget. | [#L129-L134](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L129-L134) |
| [`RegistryManagerConfig`](#contract-vllm_mlx.model_registry.RegistryManagerConfig) | class | `RegistryManagerConfig(memory_budget_bytes: int, policy: ContentionPolicy)` | Global registry manager configuration. | [#L138-L142](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L138-L142) |
| [`RegisteredModel`](#contract-vllm_mlx.model_registry.RegisteredModel) | class | `RegisteredModel(name: str, source: str, preload: bool = False, continuous_batching: bool \| None = None, force_mllm: bool \| None = None, enable_mtp: bool \| None = None, prefill_step_size: int \| None = None, specprefill_enabled: bool \| None = None, specprefill_threshold: int \| None = None, specprefill_keep_pct: float \| None = None, specprefill_backbone_pct: float \| None = None, specprefill_draft_model: str \| None = None, stream_interval: int \| None = None, gpu_memory_utilization: float \| None = None, estimated_memory_bytes: int \| None = None)` | One configured model entry. | [#L146-L163](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L146-L163) |
| [`ResolvedModelConfig`](#contract-vllm_mlx.model_registry.ResolvedModelConfig) | class | `ResolvedModelConfig(entry: RegisteredModel, resolved_source: str, continuous_batching: bool, force_mllm: bool, enable_mtp: bool, prefill_step_size: int, specprefill_enabled: bool, specprefill_threshold: int, specprefill_keep_pct: float, specprefill_backbone_pct: float, specprefill_draft_model: str \| None, stream_interval: int, gpu_memory_utilization: float, scheduler_config: SchedulerConfig \| None, estimated_memory_bytes: int)` | Effective configuration for a loaded model. | [#L167-L184](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L167-L184) |
| [`LoadedModel`](#contract-vllm_mlx.model_registry.LoadedModel) | class | `LoadedModel(config: ResolvedModelConfig, engine: BaseEngine, loaded_at: float = field(default_factory=time.time), last_used_at: float = field(default_factory=time.time), active_requests: int = 0, active_tasks: set[asyncio.Task[Any]] = field(default_factory=set), preempting: bool = False)` | Runtime state for a loaded engine. | [#L188-L197](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L188-L197) |
| [`PendingLoad`](#contract-vllm_mlx.model_registry.PendingLoad) | class | `PendingLoad(model_name: str, required_bytes: int, future: asyncio.Future[LoadedModel])` | A reserved model load in progress. | [#L201-L206](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L201-L206) |
| [`ModelLease`](#contract-vllm_mlx.model_registry.ModelLease) | class | `ModelLease(manager: 'ModelManager \| None', model_name: str, engine: BaseEngine, release_cb: Callable[[], Awaitable[None]])` | Active lease for a loaded model. | [#L210-L231](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L210-L231) |
| [`ModelLease.release`](#contract-vllm_mlx.model_registry.ModelLease.release) | method | `async ModelLease.release() -> None` | Release this lease once and allow the model to become evictable. | [#L218-L225](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L218-L225) |
| [`ModelLease.__aenter__`](#contract-vllm_mlx.model_registry.ModelLease.__aenter__) | method | `async ModelLease.__aenter__() -> 'ModelLease'` | Method `ModelLease.__aenter__` returns `self`. | [#L227-L228](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L227-L228) |
| [`ModelLease.__aexit__`](#contract-vllm_mlx.model_registry.ModelLease.__aexit__) | method | `async ModelLease.__aexit__(exc_type, exc, tb) -> None` | Method `ModelLease.__aexit__` calls `self.release`; awaits asynchronous work. | [#L230-L231](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L230-L231) |
| [`_clone_scheduler_config`](#contract-vllm_mlx.model_registry._clone_scheduler_config) | function | `_clone_scheduler_config(config: SchedulerConfig \| None) -> SchedulerConfig \| None` | Clone a SchedulerConfig so per-model overrides do not mutate globals. | [#L234-L238](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L234-L238) |
| [`_parse_memory_budget_bytes`](#contract-vllm_mlx.model_registry._parse_memory_budget_bytes) | function | `_parse_memory_budget_bytes(value: Any) -> int` | Parse a memory budget from bytes, MB, or GB. | [#L241-L256](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L241-L256) |
| [`_safe_available_memory_bytes`](#contract-vllm_mlx.model_registry._safe_available_memory_bytes) | function | `_safe_available_memory_bytes() -> int` | Best-effort available system memory. | [#L259-L263](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L259-L263) |
| [`_device_working_set_bytes`](#contract-vllm_mlx.model_registry._device_working_set_bytes) | function | `_device_working_set_bytes() -> int \| None` | Best-effort Metal recommended working-set size, or None when unavailable. | [#L266-L282](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L266-L282) |
| [`MemoryBudgetReport`](#contract-vllm_mlx.model_registry.MemoryBudgetReport) | class | `MemoryBudgetReport(budget_bytes: int, device_working_set_bytes: int \| None, gpu_memory_utilization: float \| None, gpu_memory_utilization_source: str \| None, per_engine_cache_limit_bytes: int \| None, per_engine_cache_percent: float \| None, continuous_batching_entries: int, total_entries: int)` | Reconciliation of the manager weight budget with the Metal ceiling. | [#L286-L339](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L286-L339) |
| [`MemoryBudgetReport.allocation_ceiling_bytes`](#contract-vllm_mlx.model_registry.MemoryBudgetReport.allocation_ceiling_bytes) | method | `MemoryBudgetReport.allocation_ceiling_bytes() -> int \| None` | Metal soft allocation limit that will be installed at engine start. | [#L313-L322](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L313-L322) |
| [`MemoryBudgetReport.exceeds_ceiling`](#contract-vllm_mlx.model_registry.MemoryBudgetReport.exceeds_ceiling) | method | `MemoryBudgetReport.exceeds_ceiling() -> bool` | True when the weights budget alone cannot fit under the ceiling. | [#L325-L331](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L325-L331) |
| [`MemoryBudgetReport.cache_limit_exceeds_ceiling`](#contract-vllm_mlx.model_registry.MemoryBudgetReport.cache_limit_exceeds_ceiling) | method | `MemoryBudgetReport.cache_limit_exceeds_ceiling() -> bool` | True when one engine's prefix cache could alone fill the ceiling. | [#L334-L339](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L334-L339) |
| [`build_memory_budget_report`](#contract-vllm_mlx.model_registry.build_memory_budget_report) | function | `build_memory_budget_report(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, device_working_set_bytes: int \| None = None) -> MemoryBudgetReport` | Reconcile the manager weight budget against the Metal allocation ceiling. | [#L342-L421](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L342-L421) |
| [`log_memory_budget_report`](#contract-vllm_mlx.model_registry.log_memory_budget_report) | function | `log_memory_budget_report(report: MemoryBudgetReport) -> None` | Log the budget/ceiling reconciliation, warning when they conflict. | [#L424-L502](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L424-L502) |
| [`_estimate_model_bytes_from_source`](#contract-vllm_mlx.model_registry._estimate_model_bytes_from_source) | function | `_estimate_model_bytes_from_source(source: str) -> int` | Estimate model footprint from local artifact size when possible. | [#L505-L521](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L505-L521) |
| [`load_registry_config`](#contract-vllm_mlx.model_registry.load_registry_config) | function | `load_registry_config(config_path: str \| os.PathLike[str], defaults: RegistryServeDefaults) -> tuple[RegistryManagerConfig, dict[str, RegisteredModel]]` | Load and validate the models registry YAML file. | [#L524-L621](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L524-L621) |
| [`ModelManager`](#contract-vllm_mlx.model_registry.ModelManager) | class | `ModelManager(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, engine_factory: EngineFactory \| None = None)` | Registry-backed model manager with lazy load and memory-budget eviction. | [#L624-L1201](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L624-L1201) |
| [`ModelManager.__init__`](#contract-vllm_mlx.model_registry.ModelManager.__init__) | method | `ModelManager.__init__(manager_config: RegistryManagerConfig, registry: dict[str, RegisteredModel], defaults: RegistryServeDefaults, *, engine_factory: EngineFactory \| None = None) -> None` | Method `ModelManager.__init__` updates `self._config`, `self._registry`, `self._defaults`, `self._engine_factory`; calls `asyncio.Condition`. | [#L627-L643](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L627-L643) |
| [`ModelManager.memory_budget_bytes`](#contract-vllm_mlx.model_registry.ModelManager.memory_budget_bytes) | method | `ModelManager.memory_budget_bytes() -> int` | Return the registry's configured resident-model memory budget. | [#L646-L649](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L646-L649) |
| [`ModelManager.registered_model_names`](#contract-vllm_mlx.model_registry.ModelManager.registered_model_names) | method | `ModelManager.registered_model_names() -> list[str]` | Return sorted list of all registered model names. | [#L652-L654](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L652-L654) |
| [`ModelManager.has_model`](#contract-vllm_mlx.model_registry.ModelManager.has_model) | method | `ModelManager.has_model(model_name: str) -> bool` | Return whether a model name is present in the serving registry. | [#L656-L659](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L656-L659) |
| [`ModelManager.list_models`](#contract-vllm_mlx.model_registry.ModelManager.list_models) | method | `ModelManager.list_models() -> list[dict[str, Any]]` | Return registry state for /v1/models. | [#L661-L699](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L661-L699) |
| [`ModelManager.preload`](#contract-vllm_mlx.model_registry.ModelManager.preload) | method | `async ModelManager.preload() -> None` | Preload any entries marked preload=true. | [#L701-L706](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L701-L706) |
| [`ModelManager.shutdown`](#contract-vllm_mlx.model_registry.ModelManager.shutdown) | method | `async ModelManager.shutdown() -> None` | Stop and unload every loaded engine. | [#L708-L739](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L708-L739) |
| [`ModelManager.acquire`](#contract-vllm_mlx.model_registry.ModelManager.acquire) | method | `async ModelManager.acquire(model_name: str) -> ModelLease` | Acquire a lease for a configured model. | [#L741-L819](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L741-L819) |
| [`ModelManager.release`](#contract-vllm_mlx.model_registry.ModelManager.release) | method | `async ModelManager.release(model_name: str) -> None` | Release a previously acquired model lease. | [#L821-L842](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L821-L842) |
| [`ModelManager._claim_loaded_locked`](#contract-vllm_mlx.model_registry.ModelManager._claim_loaded_locked) | method | `ModelManager._claim_loaded_locked(model_name: str, *, loaded_override: LoadedModel \| None = None) -> ModelLease \| None` | Method `ModelManager._claim_loaded_locked` calls `self._loaded.get`, `time.time`, `asyncio.current_task`, `loaded.active_tasks.add`; has 2 explicit return paths. | [#L844-L874](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L844-L874) |
| [`ModelManager._claim_loaded_locked._release`](#contract-vllm_mlx.model_registry.ModelManager._claim_loaded_locked._release) | nested function | `async ModelManager._claim_loaded_locked._release() -> None` | Nested Function `ModelManager._claim_loaded_locked._release` calls `self.release`; awaits asynchronous work. | [#L866-L867](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L866-L867) |
| [`ModelManager._execute_load`](#contract-vllm_mlx.model_registry.ModelManager._execute_load) | method | `async ModelManager._execute_load(pending: PendingLoad) -> LoadedModel` | Instantiate a reserved model load outside the manager lock. | [#L876-L913](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L876-L913) |
| [`ModelManager._wait_for_change`](#contract-vllm_mlx.model_registry.ModelManager._wait_for_change) | method | `async ModelManager._wait_for_change(timeout: float \| None) -> None` | Method `ModelManager._wait_for_change` calls `self._condition.wait`, `RuntimeError`, `asyncio.wait_for`; awaits asynchronous work; can raise `RuntimeError`; returns `None`. | [#L915-L922](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L915-L922) |
| [`ModelManager._run_unloads`](#contract-vllm_mlx.model_registry.ModelManager._run_unloads) | method | `async ModelManager._run_unloads(unloads: list[LoadedModel]) -> None` | Method `ModelManager._run_unloads` calls `loaded.engine.stop`, `self._unloading.pop`, `self._condition.notify_all`; awaits asynchronous work. | [#L924-L931](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L924-L931) |
| [`ModelManager._reserve_load_locked`](#contract-vllm_mlx.model_registry.ModelManager._reserve_load_locked) | method | `ModelManager._reserve_load_locked(model_name: str, required_bytes: int) -> PendingLoad` | Method `ModelManager._reserve_load_locked` calls `asyncio.get_running_loop().create_future`, `asyncio.get_running_loop`, `PendingLoad`; returns `pending`. | [#L933-L941](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L933-L941) |
| [`ModelManager._begin_unload_locked`](#contract-vllm_mlx.model_registry.ModelManager._begin_unload_locked) | method | `ModelManager._begin_unload_locked(model_name: str) -> LoadedModel` | Method `ModelManager._begin_unload_locked` calls `self._loaded.pop`; returns `loaded`. | [#L943-L946](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L943-L946) |
| [`ModelManager._collect_idle_unloads_locked`](#contract-vllm_mlx.model_registry.ModelManager._collect_idle_unloads_locked) | method | `ModelManager._collect_idle_unloads_locked(requested_model: str, required_bytes: int) -> list[LoadedModel]` | Method `ModelManager._collect_idle_unloads_locked` calls `self._committed_bytes_locked`, `sorted`, `self._loaded.items`, `selected.append`; returns `selected`. | [#L948-L968](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L948-L968) |
| [`ModelManager._maybe_preempt_locked`](#contract-vllm_mlx.model_registry.ModelManager._maybe_preempt_locked) | method | `ModelManager._maybe_preempt_locked(*, model_name: str, required_bytes: int, start: float) -> set[asyncio.Task[Any]]` | Method `ModelManager._maybe_preempt_locked` calls `self._should_preempt_locked`, `set`, `self._committed_bytes_locked`, `sorted`; has 2 explicit return paths. | [#L970-L1003](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L970-L1003) |
| [`ModelManager._should_wait_locked`](#contract-vllm_mlx.model_registry.ModelManager._should_wait_locked) | method | `ModelManager._should_wait_locked(start: float) -> bool` | Method `ModelManager._should_wait_locked` calls `self._remaining_wait_timeout`; has 2 explicit return paths. | [#L1005-L1010](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1005-L1010) |
| [`ModelManager._should_preempt_locked`](#contract-vllm_mlx.model_registry.ModelManager._should_preempt_locked) | method | `ModelManager._should_preempt_locked(start: float) -> bool` | Method `ModelManager._should_preempt_locked` calls `time.monotonic`; has 3 explicit return paths. | [#L1012-L1020](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1012-L1020) |
| [`ModelManager._remaining_wait_timeout`](#contract-vllm_mlx.model_registry.ModelManager._remaining_wait_timeout) | method | `ModelManager._remaining_wait_timeout(start: float) -> float \| None` | Method `ModelManager._remaining_wait_timeout` calls `max`, `time.monotonic`; has 2 explicit return paths. | [#L1022-L1026](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1022-L1026) |
| [`ModelManager._can_reserve_locked`](#contract-vllm_mlx.model_registry.ModelManager._can_reserve_locked) | method | `ModelManager._can_reserve_locked(required_bytes: int) -> bool` | Method `ModelManager._can_reserve_locked` calls `self._committed_bytes_locked`; returns `self._committed_bytes_locked() + required_bytes <= self._config.memory_budget_bytes`. | [#L1028-L1032](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1028-L1032) |
| [`ModelManager._committed_bytes_locked`](#contract-vllm_mlx.model_registry.ModelManager._committed_bytes_locked) | method | `ModelManager._committed_bytes_locked() -> int` | Method `ModelManager._committed_bytes_locked` calls `sum`, `self._loaded.values`, `self._loading.values`, `self._unloading.values`; returns `loaded_bytes + loading_bytes + unloading_bytes`. | [#L1034-L1042](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1034-L1042) |
| [`ModelManager._instantiate_model`](#contract-vllm_mlx.model_registry.ModelManager._instantiate_model) | method | `async ModelManager._instantiate_model(entry: RegisteredModel, resolved_source: str) -> LoadedModel` | Method `ModelManager._instantiate_model` calls `self._resolve_model_config`, `self._engine_factory`, `BatchedEngine`, `SimpleEngine`; awaits asynchronous work; returns `LoadedModel(config=config, engine=engine)`. | [#L1044-L1073](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1044-L1073) |
| [`ModelManager._resolve_source`](#contract-vllm_mlx.model_registry.ModelManager._resolve_source) | method | `async ModelManager._resolve_source(entry: RegisteredModel) -> str` | Method `ModelManager._resolve_source` calls `asyncio.to_thread`; awaits asynchronous work; returns `await asyncio.to_thread(self._resolve_source_sync, entry)`. | [#L1075-L1076](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1075-L1076) |
| [`ModelManager._resolve_source_sync`](#contract-vllm_mlx.model_registry.ModelManager._resolve_source_sync) | method | `ModelManager._resolve_source_sync(entry: RegisteredModel) -> str` | Method `ModelManager._resolve_source_sync` calls `Path(source).exists`, `Path`, `ensure_model_downloaded`, `is_mllm_model`; has 2 explicit return paths. | [#L1078-L1087](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1078-L1087) |
| [`ModelManager._resolve_estimated_bytes`](#contract-vllm_mlx.model_registry.ModelManager._resolve_estimated_bytes) | method | `ModelManager._resolve_estimated_bytes(entry: RegisteredModel, resolved_source: str) -> int` | Method `ModelManager._resolve_estimated_bytes` calls `_estimate_model_bytes_from_source`, `Path`, `source_path.exists`, `ValueError`; can raise `ValueError`; has 3 explicit return paths. | [#L1089-L1121](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1089-L1121) |
| [`ModelManager._resolve_model_config`](#contract-vllm_mlx.model_registry.ModelManager._resolve_model_config) | method | `ModelManager._resolve_model_config(entry: RegisteredModel, resolved_source: str) -> ResolvedModelConfig` | Method `ModelManager._resolve_model_config` calls `_clone_scheduler_config`, `self._resolve_estimated_bytes`, `ResolvedModelConfig`; returns `ResolvedModelConfig(entry=entry, resolved_source=resolved_source, continuous_batching=continuous_batching, force_mllm=f…`. | [#L1123-L1201](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/model_registry.py#L1123-L1201) |
