From 6f8ef86e0b5b82307aa8641b857a1c94fc334d24 Mon Sep 17 00:00:00 2001 From: Juhi Mittal Date: Fri, 31 Jul 2026 22:08:00 +0000 Subject: [PATCH] fix(export): handle nested vocab_size for multimodal configs (e.g. Gemma4) Gemma4Config stores vocab_size under text_config.vocab_size rather than at the top level. The export path now falls back to text_config.vocab_size when model.config.vocab_size is absent. Fixes: NVBug 6445613 / GitHub TensorRT-LLM#16171 Signed-off-by: Juhi Mittal --- modelopt/torch/export/model_config_export.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 modelopt/torch/export/model_config_export.py diff --git a/modelopt/torch/export/model_config_export.py b/modelopt/torch/export/model_config_export.py old mode 100644 new mode 100755 index 1230702e320..24cda45219a --- a/modelopt/torch/export/model_config_export.py +++ b/modelopt/torch/export/model_config_export.py @@ -149,7 +149,10 @@ def torch_to_tensorrt_llm_checkpoint( elif hasattr(model, "config"): # Huggingface models model_metadata_config = model.config.__dict__ - vocab_size = model.config.vocab_size + if hasattr(model.config, "vocab_size"): + vocab_size = model.config.vocab_size + else: + vocab_size = model.config.text_config.vocab_size hf_config = model.config architectures = getattr(model.config, "architectures", None) architecture = architectures[0] if architectures else ""