<#734 Dynamic Batcher: Useful for dynamically batc...
# flyte-github
a
#734 Dynamic Batcher: Useful for dynamically batching onto a constrainted resource like gpus Pull request opened by kumare3 Ships with 2 batchers 1. GPU batcher
Copy code
async def process(batch: list[dict]) -> list[str]:
            ...

        async with DynamicBatcher(process_fn=process) as batcher:
            futures = []
            for record in my_records:
                f = await batcher.submit(record)
                futures.append(f)
            results = await asyncio.gather(*futures)
1. Token batcher
Copy code
async def inference(batch: list[Prompt]) -> list[str]:
            ...

        async with TokenBatcher(inference_fn=inference) as batcher:
            future = await batcher.submit(Prompt(text="Hello"))
            result = await future
Docs here: unionai/unionai-docs#806 flyteorg/flyte-sdk