MCPcopy
hub / github.com/NVIDIA/TensorRT-LLM / validate_model_format_misc

Method validate_model_format_misc

tensorrt_llm/llmapi/llm_args.py:2617–2653  ·  view source on GitHub ↗

Load the model format, and do the following: 1. Load the build_config if got an engine. 2. Load the parallel_config if got a checkpoint.

(self)

Source from the content-addressed store, hash-verified

2615
2616 @model_validator(mode="after")
2617 def validate_model_format_misc(self):
2618 '''
2619 Load the model format, and do the following:
2620
2621 1. Load the build_config if got an engine.
2622 2. Load the parallel_config if got a checkpoint.
2623 '''
2624 model_obj = _ModelWrapper(self.model)
2625
2626 if model_obj.is_local_model and self.backend not in [
2627 'pytorch', '_autodeploy'
2628 ]:
2629 # Load parallel_config from the engine.
2630 model_format = get_model_format(
2631 self.model, trust_remote_code=self.trust_remote_code)
2632
2633 if model_format is _ModelFormatKind.TLLM_ENGINE:
2634 if self.build_config is not None:
2635 logger.warning(
2636 "The build_config is ignored for model format of TLLM_ENGINE."
2637 )
2638 self._load_config_from_engine(model_obj.model_dir)
2639 runtime_defaults = self._pretrained_config.runtime_defaults
2640 if runtime_defaults:
2641 self.kv_cache_config.fill_empty_fields_from_runtime_defaults(
2642 runtime_defaults)
2643
2644 # Load parallel_config from the checkpoint.
2645 elif model_format is _ModelFormatKind.TLLM_CKPT:
2646 # We need to create a temporary instance to call _load_config_from_ckpt
2647 self._load_config_from_ckpt(model_obj.model_dir)
2648 else:
2649 model_format = _ModelFormatKind.HF
2650
2651 # Store the model format in the values
2652 self._model_format = model_format
2653 return self
2654
2655 @field_validator('calib_config', mode='before')
2656 @classmethod

Callers

nothing calls this directly

Calls 5

_ModelWrapperClass · 0.85
get_model_formatFunction · 0.85
warningMethod · 0.45

Tested by

no test coverage detected