Batch inference
Send several requests at once and a worker runs them together, so the same GPU gets through far more work. It's on by default, and the worker decides how many to run at once.
How it works
A GPU writing one reply leaves most of its power unused. Run several requests together and they share each step, so they finish in barely more time than one on its own.
Each reply is a little slower while others run, but the worker gets through many more in total. That suits batch jobs, such as summarising thousands of documents, and apps with many people using them at once.
Send requests at once
Nothing changes in each request. Just send them at the same time rather than waiting for each reply:
import asyncio
from pendra import AsyncPendra
client = AsyncPendra(api_key="pdr_sk_...")
async def summarise(text):
response = await client.chat.completions.create(
model="qwen3.6:27b",
messages=[{"role": "user", "content": f"Summarise this: {text}"}],
)
return response.choices[0].message.content
async def main():
documents = ["...", "...", "..."]
summaries = await asyncio.gather(*(summarise(d) for d in documents))
print(summaries)
asyncio.run(main())
How many at once
On Automatic, the worker runs as many requests at once as each model's memory allows. Up to about eight costs each reply very little. Beyond that, the worker gets through more in total but each reply slows down. To cap it, open the worker's Settings and set Requests at once.
If every place is busy, Pendra holds a request for up to 30 seconds and
moves it to another worker if one frees up. Otherwise you get a
429. Wait for the time in its Retry-After header
and try again. See When a
worker is full.
Good to know
- Chat models run requests together. Image, speech, embedding and reranking models take one at a time.
- To get through even more, add workers. Pendra spreads requests across every worker serving the model.
- To serve one request at a time instead, turn off Run requests together in the worker's Settings.