MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT-LLM / save

Method save

tensorrt_llm/llmapi/llm_utils.py:287–301  ·  view source on GitHub ↗

Save the built engine on a single GPU to the given path.

(
        self,
        model: _ModelRuntimeContext,
        model_dir: str,
        engine_dir: str,
    )

Source from the content-addressed store, hash-verified

285 return self._model_format
286
287 def save(
288 self,
289 model: _ModelRuntimeContext,
290 model_dir: str,
291 engine_dir: str,
292 ):
293 ''' Save the built engine on a single GPU to the given path. '''
294 model.engine.save(engine_dir)
295 if model.mapping.rank == 0:
296 tokenizer = ModelLoader.load_hf_tokenizer(
297 model_dir,
298 trust_remote_code=self.llm_args.trust_remote_code,
299 use_fast=self.llm_args.tokenizer_mode != 'slow')
300 if tokenizer is not None:
301 tokenizer.save_pretrained(engine_dir)
302
303 def _download_hf_model(self):
304 ''' Download HF model from third-party model hub like www.modelscope.cn or huggingface. '''

Callers 1

__call__Method · 0.95

Calls 2

load_hf_tokenizerMethod · 0.80
save_pretrainedMethod · 0.80

Tested by

no test coverage detected