dynamic¶
dynamic ¶
Attributes¶
Classes¶
QueueFullError ¶
Bases: Exception
Raised when queue is full and blocking is disabled.
DynamicBatchStrategy ¶
DynamicBatchStrategy(min_batch_size: int = 1, max_batch_size: int = 32, max_wait_ms: float = 50, queue_size: int = 1000, block_on_full: bool = True)
Bases: BatchStrategy[P, R]
Dynamic batching with adaptive batch size (sync version).
This strategy
- Collects requests into batches
- Adjusts batch size based on queue depth
- Uses timeout to ensure low latency
- Distributes results to individual requests
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_batch_size | int | Minimum batch size (default: 1). | 1 |
max_batch_size | int | Maximum batch size (default: 32). | 32 |
max_wait_ms | float | Maximum wait time before processing batch (default: 50ms). | 50 |
queue_size | int | Maximum queue size (default: 1000). | 1000 |
block_on_full | bool | Block when queue is full instead of raising error. | True |
Source code in inferflow/asyncio/batch/dynamic.py
Attributes¶
Functions¶
submit async ¶
Submit an item for batched processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item | P | Preprocessed input. | required |
Returns:
| Type | Description |
|---|---|
R | Inference result. |
Raises:
| Type | Description |
|---|---|
RuntimeError | If strategy is not started. |
QueueFullError | If queue is full and blocking is disabled. |
Source code in inferflow/asyncio/batch/dynamic.py
start async ¶
Start the batch processing worker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime | Runtime[P, R] | Runtime to use for inference. | required |
Source code in inferflow/asyncio/batch/dynamic.py
stop async ¶
Stop the batch processing worker (async).