# `vllm_mlx.patches.qwen3_5_mtp`

Runtime MTP (Multi-Token Prediction) support for Qwen3.5 models.

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

## 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.patches.qwen3_5_mtp
    options:
      members:
        - logger
        - _MTP_KEY_PREFIXES
        - _strip_mtp_key_prefix
        - _QWEN_MTP_RMSNORM_WEIGHT_SUFFIXES
        - _QWEN_MTP_HIDDEN_STATE_MODES
        - _resolve_qwen_mtp_hidden_state_mode
        - _select_qwen_mtp_hidden_state
        - _is_qwen_mtp_rmsnorm_weight
        - _apply_qwen_mtp_rmsnorm_offset_fixups
        - _fixup_moe_mtp
        - inject_mtp_support
        - validate_mtp_support
      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.patches.qwen3_5_mtp._strip_mtp_key_prefix" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp._strip_mtp_key_prefix</code> · function</summary>

```python
vllm_mlx.patches.qwen3_5_mtp._strip_mtp_key_prefix(key: str) -> str | None
```

Return an MTP-relative key for supported standalone shard layouts.

**Parameters**

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

**Returns**

- Type: `str | None`
- Direct return expressions: `key.removeprefix(prefix)`; `None`

**Exceptions and behavior**

Function `_strip_mtp_key_prefix` calls `key.startswith`, `key.removeprefix`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

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

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp._resolve_qwen_mtp_hidden_state_mode" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp._resolve_qwen_mtp_hidden_state_mode</code> · function</summary>

```python
vllm_mlx.patches.qwen3_5_mtp._resolve_qwen_mtp_hidden_state_mode(config: dict) -> str
```

Resolve the checkpoint's MTP hidden-state contract safely.

**Parameters**

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

**Returns**

- Type: `str`
- Direct return expressions: `'post_norm'`; `mode`

**Exceptions and behavior**

Function `_resolve_qwen_mtp_hidden_state_mode` calls `config.get`, `text_config.get`, `isinstance`, `logger.warning`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

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

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp._select_qwen_mtp_hidden_state" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp._select_qwen_mtp_hidden_state</code> · function</summary>

```python
vllm_mlx.patches.qwen3_5_mtp._select_qwen_mtp_hidden_state(mode: str, hidden_states, normed) -> not annotated
```

Select the representation expected by the checkpoint's MTP head.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `mode` | `str` | `yes` | `none` | Required positional or keyword input. |
| `hidden_states` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `normed` | `not annotated` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `not annotated`
- Direct return expressions: `hidden_states if mode == 'pre_norm' else normed`

**Exceptions and behavior**

Function `_select_qwen_mtp_hidden_state` returns `hidden_states if mode == 'pre_norm' else normed`.
No direct `raise` statement appears in this definition.

[View source #L68-L70](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L68-L70).

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp._is_qwen_mtp_rmsnorm_weight" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp._is_qwen_mtp_rmsnorm_weight</code> · function</summary>

```python
vllm_mlx.patches.qwen3_5_mtp._is_qwen_mtp_rmsnorm_weight(key: str, weight) -> bool
```

Return True for MTP RMSNorm weights that use Qwen's offset convention.

**Parameters**

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

**Returns**

- Type: `bool`
- Direct return expressions: `weight.ndim == 1 and any((key.endswith(suffix) for suffix in _QWEN_MTP_RMSNORM_WEIGHT_SUFFIXES))`

**Exceptions and behavior**

Function `_is_qwen_mtp_rmsnorm_weight` calls `any`, `key.endswith`; returns `weight.ndim == 1 and any((key.endswith(suffix) for suffix in _QWEN_MTP_RMSNORM_WEIGHT_SUFFIXES))`.
No direct `raise` statement appears in this definition.

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

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp._apply_qwen_mtp_rmsnorm_offset_fixups" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp._apply_qwen_mtp_rmsnorm_offset_fixups</code> · function</summary>

```python
vllm_mlx.patches.qwen3_5_mtp._apply_qwen_mtp_rmsnorm_offset_fixups(mtp_weights: dict) -> int
```

Apply Qwen raw-offset RMSNorm fixups without double-shifting MLX weights.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `mtp_weights` | `dict` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `int`
- Direct return expressions: `norm_fixup_count`

**Exceptions and behavior**

Function `_apply_qwen_mtp_rmsnorm_offset_fixups` calls `list`, `mtp_weights.items`, `_is_qwen_mtp_rmsnorm_weight`, `weight.mean().item`; returns `norm_fixup_count`.
No direct `raise` statement appears in this definition.

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

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp._fixup_moe_mtp" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp._fixup_moe_mtp</code> · function</summary>

```python
vllm_mlx.patches.qwen3_5_mtp._fixup_moe_mtp(mtp, inner_model, loaded_keys: set, mx) -> None
```

Fix missing weights in MoE MTP module.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `mtp` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `inner_model` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `loaded_keys` | `set` | `yes` | `none` | Required positional or keyword input. |
| `mx` | `not annotated` | `yes` | `none` | Required positional or keyword input. |

**Returns**

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

**Exceptions and behavior**

Function `_fixup_moe_mtp` calls `reversed`, `logger.warning`, `getattr`, `mlx.utils.tree_flatten`; returns `None`.
No direct `raise` statement appears in this definition.

[View source #L93-L157](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L93-L157).

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support</code> · function</summary>

```python
vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support(model: Any, model_path, config: dict) -> bool
```

Inject MTP module into a loaded Qwen3.5 model.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model` | `Any` | `yes` | `none` | A model loaded via mlx_lm (strict=False, MTP weights ignored) |
| `model_path` | `not annotated` | `yes` | `none` | Path to model directory (contains model-mtp.safetensors) |
| `config` | `dict` | `yes` | `none` | Parsed config.json dict |

**Returns**

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

**Exceptions and behavior**

Function `inject_mtp_support` calls `config.get`, `_resolve_qwen_mtp_hidden_state_mode`, `text_config.get`, `logger.info`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L160-L447](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L160-L447).

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._MTPModule" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._MTPModule</code> · nested class</summary>

```python
vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._MTPModule(args, n_layers)
```

Nested Class `inject_mtp_support._MTPModule` derives from `nn.Module` and declares 1 direct member(s).

**Parameters**

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

**Returns**

- Constructs: `vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._MTPModule`

**Exceptions and behavior**

Nested Class `inject_mtp_support._MTPModule` derives from `nn.Module` and declares 1 direct member(s).
No direct `raise` statement appears in this definition.

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

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._MTPModule.__init__" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._MTPModule.__init__</code> · nested function</summary>

```python
vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._MTPModule.__init__(args, n_layers) -> not annotated
```

Nested Function `inject_mtp_support._MTPModule.__init__` updates `self.pre_fc_norm_hidden`, `self.pre_fc_norm_embedding`, `self.fc`, `self.layers`; calls `super().__init__`, `super`, `nn.RMSNorm`, `nn.Linear`.

**Parameters**

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

**Returns**

- Type: `not annotated`

**Exceptions and behavior**

Nested Function `inject_mtp_support._MTPModule.__init__` updates `self.pre_fc_norm_hidden`, `self.pre_fc_norm_embedding`, `self.fc`, `self.layers`; calls `super().__init__`, `super`, `nn.RMSNorm`, `nn.Linear`.
No direct `raise` statement appears in this definition.

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

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP</code> · nested class</summary>

```python
vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP()
```

Qwen3.5 with MTP support (injected at runtime).

**Parameters**

This callable has no explicit inputs.

**Returns**

- Constructs: `vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP`

**Exceptions and behavior**

Nested Class `inject_mtp_support._Qwen3_5MTP` derives from `original_class` and declares 3 direct member(s).
No direct `raise` statement appears in this definition.

[View source #L368-L438](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L368-L438).

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP.__call__" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP.__call__</code> · nested function</summary>

```python
vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP.__call__(inputs, cache = None, return_hidden: bool = False, input_embeddings = None, **kwargs) -> not annotated
```

Nested Function `inject_mtp_support._Qwen3_5MTP.__call__` calls `inner.embed_tokens`, `len`, `create_attention_mask`, `create_ssm_mask`; has 2 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `inputs` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `cache` | `not annotated` | `no` | `None` | Optional positional or keyword input; defaults to `None`. |
| `return_hidden` | `bool` | `no` | `False` | Optional positional or keyword input; defaults to `False`. |
| `input_embeddings` | `not annotated` | `no` | `None` | Optional positional or keyword input; defaults to `None`. |
| `**kwargs` | `not annotated` | `no` | `none` | Additional variadic keyword inputs accepted by this callable. |

**Returns**

- Type: `not annotated`
- Direct return expressions: `(out, _select_qwen_mtp_hidden_state(hidden_state_mode, hidden_states, normed))`; `out`

**Exceptions and behavior**

Nested Function `inject_mtp_support._Qwen3_5MTP.__call__` calls `inner.embed_tokens`, `len`, `create_attention_mask`, `create_ssm_mask`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L371-L408](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L371-L408).

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP.mtp_forward" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP.mtp_forward</code> · nested function</summary>

```python
vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP.mtp_forward(hidden_states, next_token_ids, cache = None, mtp_cache = None) -> not annotated
```

Run MTP head: predict token n+2 from hidden states + token n+1.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `hidden_states` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `next_token_ids` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `cache` | `not annotated` | `no` | `None` | Optional positional or keyword input; defaults to `None`. |
| `mtp_cache` | `not annotated` | `no` | `None` | Optional positional or keyword input; defaults to `None`. |

**Returns**

- Type: `not annotated`
- Direct return expressions: `self.model.embed_tokens.as_linear(x)`; `self.lm_head(x)`

**Exceptions and behavior**

Nested Function `inject_mtp_support._Qwen3_5MTP.mtp_forward` calls `self.model.embed_tokens`, `self.mtp.pre_fc_norm_embedding`, `self.mtp.pre_fc_norm_hidden`, `self.mtp.fc`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L410-L432](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L410-L432).

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP.make_mtp_cache" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP.make_mtp_cache</code> · nested function</summary>

```python
vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP.make_mtp_cache() -> not annotated
```

Create KV cache for MTP layers.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `not annotated`
- Direct return expressions: `None`; `[KVCache() for _ in self.mtp.layers]`

**Exceptions and behavior**

Nested Function `inject_mtp_support._Qwen3_5MTP.make_mtp_cache` calls `KVCache`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L434-L438](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L434-L438).

</details>

<details class="api-contract" id="contract-vllm_mlx.patches.qwen3_5_mtp.validate_mtp_support" markdown="1">
<summary><code>vllm_mlx.patches.qwen3_5_mtp.validate_mtp_support</code> · function</summary>

```python
vllm_mlx.patches.qwen3_5_mtp.validate_mtp_support(model: Any) -> bool
```

Validate that a loaded model has working MTP support.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `model` | `Any` | `yes` | `none` | A model loaded via mlx_lm.load() |

**Returns**

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

**Exceptions and behavior**

Function `validate_mtp_support` calls `hasattr`, `getattr`, `logger.warning`, `inspect.signature`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L450-L512](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L450-L512).

</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 |
| --- | --- | --- | --- | --- |
| [`_strip_mtp_key_prefix`](#contract-vllm_mlx.patches.qwen3_5_mtp._strip_mtp_key_prefix) | function | `_strip_mtp_key_prefix(key: str) -> str \| None` | Return an MTP-relative key for supported standalone shard layouts. | [#L31-L36](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L31-L36) |
| [`_resolve_qwen_mtp_hidden_state_mode`](#contract-vllm_mlx.patches.qwen3_5_mtp._resolve_qwen_mtp_hidden_state_mode) | function | `_resolve_qwen_mtp_hidden_state_mode(config: dict) -> str` | Resolve the checkpoint's MTP hidden-state contract safely. | [#L52-L65](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L52-L65) |
| [`_select_qwen_mtp_hidden_state`](#contract-vllm_mlx.patches.qwen3_5_mtp._select_qwen_mtp_hidden_state) | function | `_select_qwen_mtp_hidden_state(mode: str, hidden_states, normed) -> not annotated` | Select the representation expected by the checkpoint's MTP head. | [#L68-L70](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L68-L70) |
| [`_is_qwen_mtp_rmsnorm_weight`](#contract-vllm_mlx.patches.qwen3_5_mtp._is_qwen_mtp_rmsnorm_weight) | function | `_is_qwen_mtp_rmsnorm_weight(key: str, weight) -> bool` | Return True for MTP RMSNorm weights that use Qwen's offset convention. | [#L73-L77](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L73-L77) |
| [`_apply_qwen_mtp_rmsnorm_offset_fixups`](#contract-vllm_mlx.patches.qwen3_5_mtp._apply_qwen_mtp_rmsnorm_offset_fixups) | function | `_apply_qwen_mtp_rmsnorm_offset_fixups(mtp_weights: dict) -> int` | Apply Qwen raw-offset RMSNorm fixups without double-shifting MLX weights. | [#L80-L90](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L80-L90) |
| [`_fixup_moe_mtp`](#contract-vllm_mlx.patches.qwen3_5_mtp._fixup_moe_mtp) | function | `_fixup_moe_mtp(mtp, inner_model, loaded_keys: set, mx) -> None` | Fix missing weights in MoE MTP module. | [#L93-L157](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L93-L157) |
| [`inject_mtp_support`](#contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support) | function | `inject_mtp_support(model: Any, model_path, config: dict) -> bool` | Inject MTP module into a loaded Qwen3.5 model. | [#L160-L447](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L160-L447) |
| [`inject_mtp_support._MTPModule`](#contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._MTPModule) | nested class | `inject_mtp_support._MTPModule(args, n_layers)` | Nested Class `inject_mtp_support._MTPModule` derives from `nn.Module` and declares 1 direct member(s). | [#L239-L252](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L239-L252) |
| [`inject_mtp_support._MTPModule.__init__`](#contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._MTPModule.__init__) | nested function | `inject_mtp_support._MTPModule.__init__(args, n_layers) -> not annotated` | Nested Function `inject_mtp_support._MTPModule.__init__` updates `self.pre_fc_norm_hidden`, `self.pre_fc_norm_embedding`, `self.fc`, `self.layers`; calls `super().__init__`, `super`, `nn.RMSNorm`, `nn.Linear`. | [#L240-L252](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L240-L252) |
| [`inject_mtp_support._Qwen3_5MTP`](#contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP) | nested class | `inject_mtp_support._Qwen3_5MTP()` | Qwen3.5 with MTP support (injected at runtime). | [#L368-L438](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L368-L438) |
| [`inject_mtp_support._Qwen3_5MTP.__call__`](#contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP.__call__) | nested function | `inject_mtp_support._Qwen3_5MTP.__call__(inputs, cache = None, return_hidden: bool = False, input_embeddings = None, **kwargs) -> not annotated` | Nested Function `inject_mtp_support._Qwen3_5MTP.__call__` calls `inner.embed_tokens`, `len`, `create_attention_mask`, `create_ssm_mask`; has 2 explicit return paths. | [#L371-L408](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L371-L408) |
| [`inject_mtp_support._Qwen3_5MTP.mtp_forward`](#contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP.mtp_forward) | nested function | `inject_mtp_support._Qwen3_5MTP.mtp_forward(hidden_states, next_token_ids, cache = None, mtp_cache = None) -> not annotated` | Run MTP head: predict token n+2 from hidden states + token n+1. | [#L410-L432](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L410-L432) |
| [`inject_mtp_support._Qwen3_5MTP.make_mtp_cache`](#contract-vllm_mlx.patches.qwen3_5_mtp.inject_mtp_support._Qwen3_5MTP.make_mtp_cache) | nested function | `inject_mtp_support._Qwen3_5MTP.make_mtp_cache() -> not annotated` | Create KV cache for MTP layers. | [#L434-L438](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L434-L438) |
| [`validate_mtp_support`](#contract-vllm_mlx.patches.qwen3_5_mtp.validate_mtp_support) | function | `validate_mtp_support(model: Any) -> bool` | Validate that a loaded model has working MTP support. | [#L450-L512](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/patches/qwen3_5_mtp.py#L450-L512) |
