Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions tensorrt_llm/llmapi/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down
28 changes: 28 additions & 0 deletions tensorrt_llm/llmapi/llm_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading