(self, save_dir, tag, client_state={}, exclude_frozen_parameters=False)
| 5478 | return success |
| 5479 | |
| 5480 | def _save_checkpoint(self, save_dir, tag, client_state={}, exclude_frozen_parameters=False): |
| 5481 | |
| 5482 | save_path = self._get_ckpt_name(save_dir, tag) |
| 5483 | |
| 5484 | zero_optimizer_state = self.zero_optimization() |
| 5485 | |
| 5486 | save_frozen_param = self.zero_optimization_partition_gradients() and not exclude_frozen_parameters |
| 5487 | |
| 5488 | # A hack to save the checkpointing directory. Pipeline parallelism overrides |
| 5489 | # module_state_dict() and uses this path to save the model. module_state_dict() |
| 5490 | # then instead just returns None. The module_state_dict() implementation in |
| 5491 | # PipelineEngine expects the save path to be set in self._curr_ckpt_path. |
| 5492 | self._curr_ckpt_path = os.path.join(save_dir, tag) |
| 5493 | module = self.module_state_dict(exclude_frozen_parameters=exclude_frozen_parameters) |
| 5494 | self._curr_ckpt_path = None |
| 5495 | |
| 5496 | state = self._common_checkpoint_state(module, zero_optimizer_state, save_frozen_param) |
| 5497 | autotp_uc_info = getattr(self.module, UNIVERSAL_CHECKPOINT_INFO, None) |
| 5498 | if autotp_uc_info is not None: |
| 5499 | state[UNIVERSAL_CHECKPOINT_INFO] = autotp_uc_info |
| 5500 | if CHECKPOINT_PARALLEL_DIMS in client_state: |
| 5501 | raise KeyError(f"client_state contains reserved checkpoint key: {CHECKPOINT_PARALLEL_DIMS}. " |
| 5502 | "This key is used internally by DeepSpeed checkpoint metadata.") |
| 5503 | state.update(client_state) |
| 5504 | log_dist(message=f'Saving model checkpoint: {save_path}', ranks=[0]) |
| 5505 | |
| 5506 | if self.save_non_zero_checkpoint: |
| 5507 | self.checkpoint_engine.save(state_dict=state, path=save_path) |
| 5508 | |
| 5509 | def _get_buffer_names(self): |
| 5510 | buffer_names = [] |
no test coverage detected