---
title: "Boost your throughput with dynamic batching"
description: "Modal added a `@modal.batched()` decorator that groups incoming requests into batches flushed when either `max_batch_size` is reached or `wait_ms` elapses, avoiding the unbounded waits of fixed-size batching."
url: "https://swe.quest/articles/boost-your-throughput-with-dynamic-batching-c7c722ba8af78c33"
canonical: "https://modal.com/blog/batching-whisper"
source: "Modal"
published: "2024-09-16"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 4
tags: ["inference","performance","serverless","python"]
---

# Boost your throughput with dynamic batching

A post on [Modal](https://swe.quest/sources/modal.md), published 2024-09-16, 4 min read, Announcement. Original: [https://modal.com/blog/batching-whisper](https://modal.com/blog/batching-whisper)

## Summary

Modal added a \`@modal.batched()\` decorator that groups incoming requests into batches flushed when either \`max\_batch\_size\` is reached or \`wait\_ms\` elapses, avoiding the unbounded waits of fixed-size batching. Batching helps GPU inference because model weights (over 6 GB for Whisper large v3) must be moved from memory to compute units per pass, and inference is usually memory-bandwidth bound. On an A10G, batching Whisper with a max batch size of 64 raised throughput from about 1.2 to 3.3 requests per second per container, cutting inference cost by roughly 65%. The function only needs to accept and return lists.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- GPU inference basics ([easy posts on Hardware](https://swe.quest/tags/hardware.md?difficulty=easy))
- Python decorators ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))

## Keywords

Modal, Whisper, dynamic batching, A10G, vLLM, Hugging Face

## Related posts

- [Benchmarking Text Generation Inference](https://swe.quest/articles/benchmarking-text-generation-inference-6c04e8c47131c2d4.md): Hugging Face · 2024-05-29 · Medium · 10 min read · Inference & serving, Performance engineering, LLMs
  Text Generation Inference ships a benchmarking tool that profiles LLM serving across batch sizes, plotting throughput against latency separately for prefill and decode so deployments can be tuned for a workload such as RAG or chat.
- [Prefill and Decode for Concurrent Requests - Optimizing LLM Performance](https://swe.quest/articles/prefill-and-decode-for-concurrent-requests-optimizing-llm-performance-66a6db57e54903ca.md): Hugging Face · 2025-04-16 · Medium · 10 min read · Inference & serving, LLMs, Performance engineering, Hardware
  LLM token generation splits into a compute-bound prefill phase, which processes all prompt tokens in parallel to produce the first token, and a memory-bandwidth-bound decode phase, which produces later tokens one at a time.
- [Autoscaling endpoints for LLM inference](https://swe.quest/articles/autoscaling-endpoints-for-llm-inference-44142f946febf6fd.md): Together AI · 2026-07-31 · Medium · 10 min read · Inference & serving, Capacity planning, LLMs, Performance engineering, Cost optimization
  LLM serving breaks classic autoscaling assumptions. GPU utilization misrepresents load, and multi-minute cold starts mean scaling has to act on leading signals.
- [Configuring Dedicated Model Inference](https://swe.quest/articles/configuring-dedicated-model-inference-8368c7de6b0b1442.md): Together AI · 2026-07-29 · Medium · 7 min read · Inference & serving, Load balancing, Deployment, Performance engineering
  Together AI's Dedicated Model Inference separates a stable endpoint name, disposable deployments (model revision + config + autoscaling replicas), and immutable config revisions that specify engine, GPU type/count, parallelism and a latency/throughput/balanced profile.
- [Open-weight models are fast on Neon AI Gateway. Here's why](https://swe.quest/articles/open-weight-models-are-fast-on-neon-ai-gateway-here-s-why-a042a513966cd27f.md): Neon · 2026-08-20 · Medium · 7 min read · Inference & serving, LLMs, Performance engineering, Caching, AI agents
  Neon AI Gateway serves open-weight models through Databricks Foundation Model APIs, so it gets that stack's inference optimizations: continuous batching with PagedAttention-style KV-cache paging and overlapped prefill/decode, a TensorRT-LLM backend with fused and GroupGEMM kernels for MoE, tensor parallelism, FP8 quantization, and per-GPU tuning.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
