Dynamic Batch Sizes¶
Overview¶
The number of requests in a decode batch can vary during serving. Preparing multiple batch sizes lets the engine use a size suited to the current batch, reducing padding compared with always using the maximum batch size.
Both the vllm and transformers (optimum) model implementations support this approach. The configuration differs by model implementation: vllm uses the decode_batch_bucket_* options, while transformers (optimum) uses optimum_overrides["decoder_batch_sizes"]. The sections below describe how to configure each implementation.
vllm model implementation¶
Configuring bucket sizes¶
A bucket is a batch size used for decoding. You can generate these sizes automatically or specify them directly. The maximum bucket size is max_num_seqs divided by the pipeline-parallel size. By default, --rbln-decode-batch-bucket-limit is 1, so the engine creates one bucket whose size equals the maximum batch size. For example, if the maximum batch size is 8, --rbln-decode-batch-bucket-strategy is exponential, --rbln-decode-batch-bucket-step is 2, and --rbln-decode-batch-bucket-limit is 4, the engine creates four buckets with sizes 8, 4, 2, and 1.
See the Configuration Guide for detailed option descriptions and constraints.
Configuration examples¶
Automatic generation¶
Generate four batch-size buckets: 8, 4, 2, and 1.
Explicit sizes¶
Specify bucket sizes 1, 4, and 8 directly:
With these bucket sizes, a decode batch of 3 requests is padded to 4, and a batch of 5 is padded to 8.
transformers (optimum) model implementation¶
Set model_impl="transformers" and specify the decoder batch sizes in additional_config["optimum_overrides"]["decoder_batch_sizes"]. The example below compiles decoder graphs for batch sizes 1, 4, and 8 when the engine starts.
Note
- All values must be less than or equal to
max_num_seqs. - Batch sizes can be listed in any order. If the list does not include
max_num_seqs, it is added automatically. - For a precompiled model, configure the decoder batch sizes during compilation. This override does not change the batch sizes of an existing compiled model.