diff --git a/python/tensorrt_model_connect/families/internvl/plugin.py b/python/tensorrt_model_connect/families/internvl/plugin.py index ca86058230..c9576bc0b6 100644 --- a/python/tensorrt_model_connect/families/internvl/plugin.py +++ b/python/tensorrt_model_connect/families/internvl/plugin.py @@ -145,6 +145,18 @@ def get_vl_config(self, config: ModelConfig) -> dict | None: "image_token_str": "", } + def get_bundle_config_overrides(self, config: ModelConfig) -> dict[str, int]: + """Expose InternVL's nested text decoder contract at bundle scope.""" + return { + "vocab_size": config.vocab_size, + "hidden_size": config.hidden_size, + "num_hidden_layers": config.num_hidden_layers, + "num_attention_heads": config.num_attention_heads, + "num_key_value_heads": config.num_key_value_heads, + "head_dim": config.head_dim, + "bos_token_id": config.bos_token_id, + } + # --------------------------------------------------------------------------- # Text decoder weight loading diff --git a/tests/e2e/models/internvl/test_internvl_family_plugin_weights.py b/tests/e2e/models/internvl/test_internvl_family_plugin_weights.py index 8cbe837041..823e7fd400 100644 --- a/tests/e2e/models/internvl/test_internvl_family_plugin_weights.py +++ b/tests/e2e/models/internvl/test_internvl_family_plugin_weights.py @@ -231,6 +231,40 @@ def test_get_vl_config(self, tmp_path): assert "image_token_id" in vl_cfg assert "vl_prompt_template" in vl_cfg + def test_bundle_config_overrides_flatten_text_decoder(self, tmp_path): + """The native runtime receives InternVL's nested decoder geometry.""" + from tensorrt_model_connect.families.internvl import plugin + + config = { + "model_type": "internvl", + "text_config": { + "vocab_size": 151674, + "hidden_size": 1536, + "num_hidden_layers": 28, + "num_attention_heads": 12, + "num_key_value_heads": 2, + "head_dim": 128, + "bos_token_id": 151643, + }, + "vision_config": { + "hidden_size": 1024, + "num_hidden_layers": 24, + }, + } + _write_config(tmp_path, config) + + cfg = ModelConfig.from_dir(tmp_path) + + assert plugin.get_bundle_config_overrides(cfg) == { + "vocab_size": 151674, + "hidden_size": 1536, + "num_hidden_layers": 28, + "num_attention_heads": 12, + "num_key_value_heads": 2, + "head_dim": 128, + "bos_token_id": 151643, + } + def test_no_vl_config_without_vision(self, tmp_path): """get_vl_config returns None when no vision_config present.""" from tensorrt_model_connect.families.internvl import plugin