How does TensorRT-LLM use In-flight Batching?
There is some confusion about how to use TensorRT-LLM Inflighting Batching.
- How does TensorRT-LLM use In-flight Batching?
- How do we make sure we use TensorRT-LLM?
- If In-flight Batching is used, can the output (generation) length of sentences in one batch be different?
Hi @liye0626 ,
We expose the in-flight batching feature through the Triton backend (even if it can be enabled in any serving system). Have you taken a look at the Triton backend of TensorRT-LLM?
If you take a look at the latest update in our main branch, you’ll see that we now export a tensor with output sequences.
Thanks, Julien
Hi @jdemouth-nvidia, You mean, in-flight batching feature must use Triton backend. If we only build TensorRT-LLM by referring to the guide, we cannot use the in-flight batching feature.
-
guide: https://github.com/NVIDIA/TensorRT-LLM/blob/release/0.5.0/docs/source/installation.md
-
tensorrtllm_backend: https://github.com/triton-inference-server/tensorrtllm_backend
@liye0626 Technically, you can use in-flight batching without depending on Triton backend. You can refer this example as to how to enable in-flight batching in a more standalone way.
@juney-nvidia currently both triton backend and the example that you linked is implementing in-flight batching in c++. Is there any examples implementing IFB using the python API? Thanks!
Also, can I implement continuous batching using the python API? I see some mentions in different issues but without a conclusion. Any links to helpful resource will be thankful.
For now support for in-flight batching requires you to use the C++ batch manager together with the C++ runtime. We plan to publish a Python wrapper in the near future but it’s not available yet.
@jdemouth-nvidia @juney-nvidia Thanks for your help, I have successfully enabled in-flighting batching by batch manager.
Awesome. Thanks for your patience. If we can continue to help, let us know :). I’m closing the issue for now.
@jdemouth-nvidia @juney-nvidia Thanks for your help, I have successfully enabled in-flighting batching by batch manager.
hello, How did you achieve this? use the C++ batch manager?
btw for anyone finding this issue, now there is Python API for inflight batching here https://github.com/NVIDIA/TensorRT-LLM/tree/main/examples/bindings/executor#advanced-example
btw for anyone finding this issue, now there is Python API for inflight batching here https://github.com/NVIDIA/TensorRT-LLM/tree/main/examples/bindings/executor#advanced-example顺便说一句,对于发现此问题的人来说,现在这里有用于动态批处理的 Python API https://github.com/NVIDIA/TensorRT-LLM/tree/main/examples/bindings/executor#advanced-example
Thanks for guidance ! How to make sure Infight Batching is turned on in this example code ? And btw does this example also work for TensorRT-LLM 0.5.0 ?
How to make sure Infight Batching is turned on in this example code ? And btw does this example also work for TensorRT-LLM 0.5.0 ?
@2012zzhao pretty sure it would not work with TensorRT-LLM 0.5.0 as it's really old, I think at least 0.9.0 would be needed (and then it's best to check the version of example which corresponds to the library version you're using). As for when it's tuned on, the example code actually does implement inflight batching so there is no need to turn it on, but it's not something you'd be using directly -- e.g. we've used this example to have inflight batching in our python http server, as we didn't need all the features of the triton server.