Skip to content

Commit 3d589a1

Browse files
committed
Applied review comment
Signed-off-by: Taylor Yeonbok Lee <[email protected]>
1 parent ac80221 commit 3d589a1

File tree

4 files changed

+13
-24
lines changed

4 files changed

+13
-24
lines changed

tensorrt_llm/_torch/model_config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,6 @@ def cached_file(path_or_repo_id, file_name):
456456
# Apply model_kwargs to override config parameters if provided
457457
model_kwargs = kwargs.pop('model_kwargs', None)
458458
if model_kwargs:
459-
from tensorrt_llm.logger import logger
460459

461460
def _recursive_update_config(config: transformers.PretrainedConfig,
462461
update_dict: Dict[str, Any]):

tensorrt_llm/llmapi/llm_args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,7 @@ class BaseLlmArgs(StrictBaseModel):
19121912
description="Optional parameters overriding model config defaults. "
19131913
"Precedence: (1) model_kwargs, (2) model config file, (3) model config class defaults. "
19141914
"Unknown keys are ignored",
1915-
status="beta")
1915+
status="prototype")
19161916

19171917
pipeline_parallel_size: int = Field(
19181918
default=1, description="The pipeline parallel size.")

tests/unittest/api_stability/references/llm.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ methods:
228228
default: null
229229
status: prototype
230230
model_kwargs:
231-
annotation: object
231+
annotation: Optional[Dict[str, Any]]
232232
default: null
233-
status: beta
233+
status: prototype
234234
return_annotation: None
235235
generate:
236236
parameters:

tests/unittest/llmapi/test_llm_args.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -138,28 +138,17 @@ def test_llm_args_with_pydantic_options(self):
138138
assert llm_args.max_num_tokens == 256
139139
assert llm_args.max_seq_len == 128
140140

141-
def test_llm_args_with_model_kwargs_trt(self):
141+
@pytest.mark.parametrize("llm_args_cls", [TrtLlmArgs, TorchLlmArgs])
142+
def test_llm_args_with_model_kwargs(self, llm_args_cls):
142143
yaml_content = """
143144
model_kwargs:
144145
num_hidden_layers: 2
145146
"""
146147
dict_content = self._yaml_to_dict(yaml_content)
147-
llm_args = TrtLlmArgs(model=llama_model_path)
148+
llm_args = llm_args_cls(model=llama_model_path)
148149
llm_args_dict = update_llm_args_with_extra_dict(llm_args.model_dump(),
149150
dict_content)
150-
llm_args = TrtLlmArgs(**llm_args_dict)
151-
assert llm_args.model_kwargs['num_hidden_layers'] == 2
152-
153-
def test_llm_args_with_model_kwargs_pt(self):
154-
yaml_content = """
155-
model_kwargs:
156-
num_hidden_layers: 2
157-
"""
158-
dict_content = self._yaml_to_dict(yaml_content)
159-
llm_args = TorchLlmArgs(model=llama_model_path)
160-
llm_args_dict = update_llm_args_with_extra_dict(llm_args.model_dump(),
161-
dict_content)
162-
llm_args = TorchLlmArgs(**llm_args_dict)
151+
llm_args = llm_args_cls(**llm_args_dict)
163152
assert llm_args.model_kwargs['num_hidden_layers'] == 2
164153

165154

@@ -473,12 +462,13 @@ def test_dynamic_setattr(self):
473462
def test_model_kwargs_with_num_hidden_layers(self):
474463
"""Test that model_kwargs can override num_hidden_layers."""
475464
from tensorrt_llm._torch.model_config import ModelConfig
476-
465+
config_no_kwargs = ModelConfig.from_pretrained(
466+
llama_model_path).pretrained_config
477467
model_kwargs = {'num_hidden_layers': 2}
478-
479-
config = ModelConfig.from_pretrained(llama_model_path,
480-
model_kwargs=model_kwargs)
481-
assert config.pretrained_config.num_hidden_layers == 2
468+
config_with_kwargs = ModelConfig.from_pretrained(
469+
llama_model_path, model_kwargs=model_kwargs).pretrained_config
470+
assert config_no_kwargs.num_hidden_layers != config_with_kwargs.num_hidden_layers
471+
assert config_with_kwargs.num_hidden_layers == 2
482472

483473

484474
class TestTrtLlmArgs:

0 commit comments

Comments
 (0)