(checkpoint_dir: Union[str, bytes, os.PathLike],
rank: int)
| 189 | |
| 190 | |
| 191 | def _load_by_rank(checkpoint_dir: Union[str, bytes, os.PathLike], |
| 192 | rank: int) -> Dict[str, torch.Tensor]: |
| 193 | checkpoint_name = _CHECKPOINT_FORMAT.replace('XX', f'{rank:02d}') |
| 194 | state_dict = torch.load( |
| 195 | os.path.join(checkpoint_dir, checkpoint_name), |
| 196 | map_location=lambda storage, loc: storage, |
| 197 | weights_only=True) |
| 198 | return state_dict['module'] if 'module' in state_dict else state_dict |
| 199 | |
| 200 | |
| 201 | def _split_tensor(tensor: torch.Tensor, num_partitions: int, |
no test coverage detected
searching dependent graphs…