Skip to content
Open
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
4 changes: 1 addition & 3 deletions truss/base/trt_llm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,7 @@ def _bei_specfic_migration(self):
logger.warning(
f"build.max_num_tokens={self.max_num_tokens}, upgrading to {BEI_REQUIRED_MAX_NUM_TOKENS}"
)
self = self.model_copy(
update={"max_num_tokens": BEI_REQUIRED_MAX_NUM_TOKENS}
)
self.max_num_tokens = BEI_REQUIRED_MAX_NUM_TOKENS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

Can you help me understand how you came across this bug? Specifically the steps you took on the platform to trigger it?

# set page_kv_cache and use_paged_context_fmha to false for encoder
self.plugin_configuration.paged_kv_cache = False
self.plugin_configuration.use_paged_context_fmha = False
Expand Down
27 changes: 27 additions & 0 deletions truss/tests/trt_llm/test_trt_llm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pydantic
import pytest

from truss.base.constants import BEI_REQUIRED_MAX_NUM_TOKENS
from truss.base.trt_llm_config import (
TRTLLMConfiguration,
TRTLLMConfigurationV1,
Expand Down Expand Up @@ -246,3 +247,29 @@ def test_trt_llm_config_additional_fields(trtllm_config_v2):

assert config.inference_stack == "v2"
assert isinstance(config.build, TrussTRTLLMBuildConfiguration)


def test_trt_llm_build_config_encoder_upgrades_max_num_tokens(trtllm_config):
"""BEI requires a minimum max_num_tokens, and the encoder path enforces it.

The upgrade rebound the local `self` instead of assigning the field, so it
logged the upgrade while leaving max_num_tokens at the user's value.
"""
build = copy.deepcopy(trtllm_config["trt_llm"]["build"])
build["base_model"] = "encoder"
build["max_num_tokens"] = 1024

build_config = TrussTRTLLMBuildConfiguration(**build)

assert build_config.max_num_tokens == BEI_REQUIRED_MAX_NUM_TOKENS


def test_trt_llm_build_config_decoder_keeps_max_num_tokens(trtllm_config):
"""Only the encoder path upgrades max_num_tokens."""
build = copy.deepcopy(trtllm_config["trt_llm"]["build"])
build["base_model"] = "decoder"
build["max_num_tokens"] = 1024

build_config = TrussTRTLLMBuildConfiguration(**build)

assert build_config.max_num_tokens == 1024