# `examples.test_batch_sync`

Test generate_batch_sync() performance.

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

## 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.

::: examples.test_batch_sync
    options:
      members:
        - main
      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-examples.test_batch_sync.main" markdown="1">
<summary><code>examples.test_batch_sync.main</code> · function</summary>

```python
examples.test_batch_sync.main() -> not annotated
```

Function `main` calls `print`, `load`, `SamplingParams`, `EngineConfig`.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `not annotated`

**Exceptions and behavior**

Function `main` calls `print`, `load`, `SamplingParams`, `EngineConfig`.
No direct `raise` statement appears in this definition.

[View source #L8-L101](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/test_batch_sync.py#L8-L101).

</details>

<details class="api-contract" id="contract-examples.test_batch_sync.main.format_prompt" markdown="1">
<summary><code>examples.test_batch_sync.main.format_prompt</code> · nested function</summary>

```python
examples.test_batch_sync.main.format_prompt(p) -> not annotated
```

Nested Function `main.format_prompt` calls `tokenizer.apply_chat_template`; returns `tokenizer.apply_chat_template([{'role': 'user', 'content': p}], tokenize=False, add_generation_prompt=True)`.

**Parameters**

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

**Returns**

- Type: `not annotated`
- Direct return expressions: `tokenizer.apply_chat_template([{'role': 'user', 'content': p}], tokenize=False, add_generation_prompt=True)`

**Exceptions and behavior**

Nested Function `main.format_prompt` calls `tokenizer.apply_chat_template`; returns `tokenizer.apply_chat_template([{'role': 'user', 'content': p}], tokenize=False, add_generation_prompt=True)`.
No direct `raise` statement appears in this definition.

[View source #L24-L29](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/test_batch_sync.py#L24-L29).

</details>

<details class="api-contract" id="contract-examples.test_batch_sync.main.run_async" markdown="1">
<summary><code>examples.test_batch_sync.main.run_async</code> · nested function</summary>

```python
async examples.test_batch_sync.main.run_async() -> not annotated
```

Nested Function `main.run_async` calls `EngineConfig`, `SchedulerConfig`, `EngineCore`, `engine.start`; awaits asynchronous work; returns `(total_tokens, elapsed)`.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `not annotated`
- Direct return expressions: `(total_tokens, elapsed)`

**Exceptions and behavior**

Nested Function `main.run_async` calls `EngineConfig`, `SchedulerConfig`, `EngineCore`, `engine.start`; awaits asynchronous work; returns `(total_tokens, elapsed)`.
No direct `raise` statement appears in this definition.

[View source #L71-L93](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/test_batch_sync.py#L71-L93).

</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 |
| --- | --- | --- | --- | --- |
| [`main`](#contract-examples.test_batch_sync.main) | function | `main() -> not annotated` | Function `main` calls `print`, `load`, `SamplingParams`, `EngineConfig`. | [#L8-L101](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/test_batch_sync.py#L8-L101) |
| [`main.format_prompt`](#contract-examples.test_batch_sync.main.format_prompt) | nested function | `main.format_prompt(p) -> not annotated` | Nested Function `main.format_prompt` calls `tokenizer.apply_chat_template`; returns `tokenizer.apply_chat_template([{'role': 'user', 'content': p}], tokenize=False, add_generation_prompt=True)`. | [#L24-L29](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/test_batch_sync.py#L24-L29) |
| [`main.run_async`](#contract-examples.test_batch_sync.main.run_async) | nested function | `async main.run_async() -> not annotated` | Nested Function `main.run_async` calls `EngineConfig`, `SchedulerConfig`, `EngineCore`, `engine.start`; awaits asynchronous work; returns `(total_tokens, elapsed)`. | [#L71-L93](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/examples/test_batch_sync.py#L71-L93) |
