# `vllm_mlx.mlx_streams`

Helpers for binding MLX generation streams to worker threads.

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

## 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.mlx_streams
    options:
      members:
        - _STREAM_REBIND_LOCK
        - bind_generation_streams
      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.mlx_streams.bind_generation_streams" markdown="1">
<summary><code>vllm_mlx.mlx_streams.bind_generation_streams</code> · function</summary>

```python
vllm_mlx.mlx_streams.bind_generation_streams(module_names: Iterable[str] = ('mlx_lm.generate', 'mlx_vlm.generate')) -> object
```

Bind mlx-lm/mlx-vlm generation streams to the current thread.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `module_names` | `Iterable[str]` | `no` | `('mlx_lm.generate', 'mlx_vlm.generate')` | Optional positional or keyword input; defaults to `('mlx_lm.generate', 'mlx_vlm.generate')`. |

**Returns**

- Type: `object`
- Direct return expressions: `default_stream`

**Exceptions and behavior**

Function `bind_generation_streams` calls `mx.new_stream`, `mx.default_device`, `mx.set_default_stream`, `importlib.import_module`; returns `default_stream`.
No direct `raise` statement appears in this definition.

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

</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 |
| --- | --- | --- | --- | --- |
| [`bind_generation_streams`](#contract-vllm_mlx.mlx_streams.bind_generation_streams) | function | `bind_generation_streams(module_names: Iterable[str] = ('mlx_lm.generate', 'mlx_vlm.generate')) -> object` | Bind mlx-lm/mlx-vlm generation streams to the current thread. | [#L15-L39](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/mlx_streams.py#L15-L39) |
