From b9599194042ebbf1c73daad71858fa06a7f962d1 Mon Sep 17 00:00:00 2001 From: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com> Date: Mon, 31 Aug 2026 23:13:23 -0700 Subject: [PATCH] [https://nvbugs/6693991][fix] Tolerate the removed sampler_type LLM arg Removing sampler_type left no back-compat path, so callers pinned to an older TRT-LLM -- notably the verl rollout server, which passes it unconditionally on every version including HEAD -- died in _validate_args_for_torch_backend before the engine was ever built. Absorb the key with a warning instead. TorchSampler is now the only sampler, so every former value resolves to the same behavior and there is no choice left to honor; raising would only relocate the same hard failure. Both pre-pydantic kwarg gates consult the removed-key set, since they reject unknown names before the validator can run. No field is reintroduced, so the api-stability reference and the golden telemetry manifest are unchanged. Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com> --- tensorrt_llm/llmapi/llm.py | 11 +++++++---- tensorrt_llm/llmapi/llm_args.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/tensorrt_llm/llmapi/llm.py b/tensorrt_llm/llmapi/llm.py index db866443236e..53f4e40504a6 100644 --- a/tensorrt_llm/llmapi/llm.py +++ b/tensorrt_llm/llmapi/llm.py @@ -57,7 +57,8 @@ from ..logger import logger from ..sampling_params import LogitsProcessor, SamplingParams from ..scheduling_params import SchedulingParams -from .llm_args import (TORCH_LLMARGS_EXPLICIT_DOCSTRING, TorchLlmArgs, +from .llm_args import (TORCH_LLMARGS_EXPLICIT_DOCSTRING, + TORCH_LLMARGS_REMOVED_KEYS, TorchLlmArgs, validate_token_encoder_bucket_config) from .llm_utils import (CachedModelLoader, KvCacheRetentionConfig, LlmBuildStats, ModelLoader) @@ -403,6 +404,8 @@ def __init__(self, valid_keys = set( list(llm_args_cls.model_fields.keys()) + ['_mpi_session', 'backend']) + if issubclass(llm_args_cls, TorchLlmArgs): + valid_keys |= TORCH_LLMARGS_REMOVED_KEYS for key in kwargs: if key not in valid_keys: raise ValueError( @@ -2012,9 +2015,9 @@ def _validate_args_for_torch_backend(self, kwargs: dict) -> None: # Check if any arguments not supported by the PyTorch backend are passed. unsupported_args = [ - key for key in kwargs - if key not in torchllm_fields and key not in ('_mpi_session', - 'backend') + key for key in kwargs if key not in torchllm_fields and key not in ( + '_mpi_session', + 'backend') and key not in TORCH_LLMARGS_REMOVED_KEYS ] if unsupported_args: diff --git a/tensorrt_llm/llmapi/llm_args.py b/tensorrt_llm/llmapi/llm_args.py index 1ffb613eb660..7feec022b9c0 100644 --- a/tensorrt_llm/llmapi/llm_args.py +++ b/tensorrt_llm/llmapi/llm_args.py @@ -5294,7 +5294,35 @@ def validate_capture_num_tokens(cls, v): "The maximum number of CUDA streams to use for torch.compile.") +# Keys that were removed from TorchLlmArgs but are still tolerated on input, so +# that callers pinned to an older TRT-LLM keep constructing. `_TorchLLM` and +# `BaseLLM` reject unknown kwargs before pydantic runs, so both consult this set +# too. Each entry is absorbed by a `mode="before"` validator below. +TORCH_LLMARGS_REMOVED_KEYS = frozenset({"sampler_type"}) + + class TorchLlmArgs(BaseLlmArgs): + + @model_validator(mode="before") + @classmethod + def _warn_removed_sampler_type(cls, data): + """Absorb the removed `sampler_type` knob. + + TorchSampler is now the only sampler, so sampler selection has no + meaning and every former value resolves to the same behavior. Drop the + key with a warning rather than raising: raising would break the pinned + RL/rollout integrations (e.g. verl) that still pass it, for a choice + they can no longer make either way. + """ + if isinstance(data, dict) and "sampler_type" in data: + data = dict(data) + requested = data.pop("sampler_type") + logger.warning( + f"'sampler_type' was removed (got {requested!r}) and is " + "ignored. TorchSampler is the only sampler; remove the " + "argument to silence this warning.") + return data + # PyTorch backend specific configurations generation_config: Literal["auto", "trtllm"] = Field( default="trtllm",