MCPcopy
hub / github.com/InternLM/InternLM / save

Method save

internlm/utils/storage_manager.py:483–501  ·  view source on GitHub ↗
(self, save_path: str, saved_obj: Any, *args, async_upload=None, **kwargs)

Source from the content-addressed store, hash-verified

481 return meta.client.get_fns(*unpack_meta(meta))
482
483 def save(self, save_path: str, saved_obj: Any, *args, async_upload=None, **kwargs):
484 meta = self._get_client(path=save_path)
485
486 if async_upload is None:
487 async_upload = self.async_mode
488 if async_upload:
489 assert (
490 self.tmp_local_folder
491 ), "StorageManager is not setted tmp_local_folder, so async save cannot be performed."
492 tmp_step_file = meta.local_nvme_path
493 self._to_be_del_files.append(tmp_step_file)
494 with open(tmp_step_file, "wb") as f:
495 torch.save(saved_obj, f, pickle_protocol=pickle.HIGHEST_PROTOCOL)
496 self.async_executor(meta.async_upload_fn, *unpack_meta(meta))
497 os.chmod(tmp_step_file, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
498 self.async_task_peeding = True
499 else:
500 meta.client.sync_upload_fileobj(*unpack_meta(meta), *args, saved_obj=saved_obj, **kwargs)
501 self.upload_count += 1
502
503 def load(self, load_path: str, *args, **kwargs) -> Any:
504 self.wait()

Callers 7

waitMethod · 0.95
dump_bin_meta_binFunction · 0.80
prepare_metaFunction · 0.80
convert2hfFunction · 0.80
llm_saveFunction · 0.80
sync_upload_fileobjMethod · 0.80
sync_upload_fileobjMethod · 0.80

Calls 4

_get_clientMethod · 0.95
async_executorMethod · 0.95
unpack_metaFunction · 0.85
sync_upload_fileobjMethod · 0.45

Tested by

no test coverage detected