feat: Add n support for TRT-LLM (Stacked PR on top of #8744)#8746
Merged
Conversation
Signed-off-by: Indrajit Bhosale <iamindrajitb@gmail.com>
Contributor
Signed-off-by: Indrajit Bhosale <iamindrajitb@gmail.com>
…mo into ibhosale/n-options-output
Signed-off-by: Indrajit Bhosale <iamindrajitb@gmail.com>
nv-yna
reviewed
Apr 29, 2026
Signed-off-by: Indrajit Bhosale <iamindrajitb@gmail.com>
…tllm Signed-off-by: Indrajit Bhosale <iamindrajitb@gmail.com> # Conflicts: # components/src/dynamo/trtllm/tests/test_trtllm_handler_base.py
nv-yna
approved these changes
Apr 29, 2026
furionw
pushed a commit
that referenced
this pull request
May 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview:
Add TRT-LLM backend support for the OpenAI-compatible
nfield on top of PR #8744.This PR is intentionally scoped to TRT-LLM only. The shared OpenAI/Rust response contract and vLLM plumbing are handled in the parent PR.
WHY:
PR #8744 adds the shared Dynamo contract for carrying multiple OpenAI choices by preserving each backend output
index.TensorRT-LLM supports
ninSamplingParamsas the number of sequences to generate, andtrtllm-serveexposes an OpenAI-compatible/v1/chat/completionsendpoint. Dynamo needed the TRT-LLM-specific plumbing to passnthrough and keep streamed choices separated.References:
SamplingParams.n: https://nvidia.github.io/TensorRT-LLM/llm-api/reference.htmlDetails:
components/src/dynamo/trtllm/llm_engine.pycomponents/src/dynamo/trtllm/request_handlers/handler_base.pynthrough to TRT-LLM sampling params.indexin streamed chunks.n > 1output streams.best_offield aligned withnwhen needed, because TRT-LLM validatesbest_of >= n.components/src/dynamo/trtllm/tests/test_trtllm_handler_base.pynis applied to sampling params.best_ofcompatibility adjustment for TRT-LLM validation.docs/backends/trtllm/trtllm-reference-guide.mdn > 1behavior relevant to this backend path.tests/serve/test_trtllm.pyn=2returns two choices.Where should the reviewer start?
Start with:
components/src/dynamo/trtllm/request_handlers/handler_base.pyThat file contains the main TRT-LLM streaming path and the per-choice cursor logic for
n > 1.Then review:
components/src/dynamo/trtllm/llm_engine.pycomponents/src/dynamo/trtllm/tests/test_trtllm_handler_base.pytests/serve/test_trtllm.pydocs/backends/trtllm/trtllm-reference-guide.mdRelated Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit
Release Notes
New Features
nparameter with TensorRT-LLM backendBug Fixes
Documentation