From 284667ca0b3641a08bf55a22e809ffcfb7a321a9 Mon Sep 17 00:00:00 2001 From: blockgroot <170620375+blockgroot@users.noreply.github.com> Date: Thu, 6 Aug 2026 17:11:32 +0530 Subject: [PATCH] fix(trt_llm): warn when python_version is ignored TRT-LLM base images ship their own fixed Python interpreter, and docker_build_setup.py overrides config.base_image + python_executable_path unconditionally for every TRT-LLM v1 and v2 model. As a result, python_version was accepted and validated but had no effect on TRT-LLM deployments, with nothing surfacing that to the user. Warn in trt_llm_common_validation() when python_version differs from its default alongside a TRT-LLM config, matching the existing warning idiom in the same function. This is additive only: the override behavior is unchanged, existing configs just get visibility into it. Fixes #2168 --- truss/base/trt_llm_config.py | 9 +++++++ truss/tests/trt_llm/test_trt_llm_config.py | 28 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/truss/base/trt_llm_config.py b/truss/base/trt_llm_config.py index 200c891ed..52bb5be41 100644 --- a/truss/base/trt_llm_config.py +++ b/truss/base/trt_llm_config.py @@ -849,6 +849,15 @@ def trt_llm_common_validation(config: "TrussConfig"): from truss.base import truss_config assert config.trt_llm, "TRT-LLM configuration is required for TRT-LLM models" + default_python_version = truss_config.TrussConfig.model_fields[ + "python_version" + ].default + if config.python_version != default_python_version: + logger.warning( + f"`python_version: {config.python_version}` has no effect on TRT-LLM models: " + "the TRT-LLM base image ships its own fixed Python interpreter, independent of " + "this setting." + ) trt_llm_config: TRTLLMConfigurationV1 | TRTLLMConfigurationV2 = config.trt_llm.root base_model = ( trt_llm_config.build.base_model diff --git a/truss/tests/trt_llm/test_trt_llm_config.py b/truss/tests/trt_llm/test_trt_llm_config.py index e005c22cc..f4fe231af 100644 --- a/truss/tests/trt_llm/test_trt_llm_config.py +++ b/truss/tests/trt_llm/test_trt_llm_config.py @@ -12,6 +12,7 @@ TrussTRTLLMBuildConfiguration, TrussTRTLLMRuntimeConfiguration, ) +from truss.base.truss_config import TrussConfig def test_trt_llm_config_init_from_pydantic_models(trtllm_config): @@ -246,3 +247,30 @@ def test_trt_llm_config_additional_fields(trtllm_config_v2): assert config.inference_stack == "v2" assert isinstance(config.build, TrussTRTLLMBuildConfiguration) + + +def test_trt_llm_non_default_python_version_warns(trtllm_config, caplog): + """python_version has no effect on TRT-LLM models: the TRT-LLM base image ships + its own fixed Python interpreter. Setting a non-default value should warn.""" + trtllm_config["python_version"] = "py311" + + with caplog.at_level("WARNING"): + TrussConfig.from_dict(trtllm_config) + + assert "has no effect on TRT-LLM models" in caplog.text + + +def test_trt_llm_default_python_version_no_warning(trtllm_config, caplog): + with caplog.at_level("WARNING"): + TrussConfig.from_dict(trtllm_config) + + assert "has no effect on TRT-LLM models" not in caplog.text + + +def test_trt_llm_v2_non_default_python_version_warns(trtllm_config_v2, caplog): + trtllm_config_v2["python_version"] = "py311" + + with caplog.at_level("WARNING"): + TrussConfig.from_dict(trtllm_config_v2) + + assert "has no effect on TRT-LLM models" in caplog.text