Repository: pytorch
Issue: Issue with loading similar checkpoints in a distributed fashion 
Labels: module: serialization,triaged

### 🐛 Describe the bug

I am trying to load a model which is partitioned in 32 files on 128 GPU, for which each 4-GPU loads the same checkpoint and takes a portion of the parameters. However, I am running into ` PytorchStreamReader failed reading zip archive: failed finding central directory` on just some ranks. I have also verified that I can load the same checkpoint which gives such error one process alone. Here is part of the stack trace:
```
node-12:   File "/.../deepspeed/runtime/engine.py", line 2765, in _load_zero_checkpoint
node-12:     zero_sd_list = self._get_all_zero_checkpoints(load_dir, tag, self.loaded_checkpoint_dp_world_size)
node-12:   File "/.../deepspeed/runtime/engine.py", line 2861, in _get_all_zero_checkpoints
node-12:     return self._get_all_zero_checkpoint_state_dicts(zero_ckpt_names, ckp_dp_size)
node-12:   File "/.../deepspeed/runtime/engine.py", line 2840, in _get_all_zero_checkpoint_state_dicts
node-12:     _state = self.checkpoint_engine.load(
node-12:   File "/.../deepspeed/runtime/checkpoint_engine/torch_checkpoint_engine.py", line 28, in load
node-12:     partition = torch.load(path, map_location=map_location)
node-12:   File "/opt/conda/envs/ptca/lib/python3.8/site-packages/torch/serialization.py", line 777, in load
node-12:     with _open_zipfile_reader(opened_file) as opened_zipfile:
node-12:   File "/opt/conda/envs/ptca/lib/python3.8/site-packages/torch/serialization.py", line 282, in __init__
node-12:     super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
node-12: RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory
node-12: [2023-06-20 09:11:11,157] [INFO] [torch_checkpoint_engine.py:27:load] [Torch] Loading checkpoint from /checkpoint_path/iter_0000340/bf16_zero_pp_rank_25_mp_rank_00_optim_states.pt...
```
Strangely enough, if I am loading the same files on 64 GPUs and spliting it 2-way, I don't run into the same problem!!
My suspicion is that this has to do with the CPU-memory, and how the file is loaded on its memory for the distributed case. Here is the part of the code on DeepSpeed side that triggers this issue: https://github.com/microsoft/DeepSpeed/blob/master/deepspeed/runtime/engine.py#L2815
I am happy to helpt resolve the issue if it is on the DeepSpeed side, however, the logic over there is very simple!
Can anyone help me to narrow down the source of this problem?

Thanks,
Reza

### Versions

Collecting environment information...
PyTorch version: 1.13.0
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: version 3.23.0
Libc version: glibc-2.31

Python version: 3.8.16 (default, Mar  2 2023, 03:21:46)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.4.0-1101-azure-x86_64-with-glibc2.17
Is CUDA available: True
CUDA runtime version: 11.7.99
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA A100-SXM4-80GB
GPU 1: NVIDIA A100-SXM4-80GB
GPU 2: NVIDIA A100-SXM4-80GB
GPU 3: NVIDIA A100-SXM4-80GB
GPU 4: NVIDIA A100-SXM4-80GB
GPU 5: NVIDIA A100-SXM4-80GB
GPU 6: NVIDIA A100-SXM4-80GB
GPU 7: NVIDIA A100-SXM4-80GB

Nvidia driver version: 510.85.02
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.5.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.5.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   48 bits physical, 48 bits virtual
CPU(s):                          96
On-line CPU(s) list:             0-95
Thread(s) per core:              1
Core(s) per socket:              48
Socket(s):                       2
NUMA node(s):                    4
Vendor ID:                       AuthenticAMD
CPU family:                      23
Model:                           49
Model name:                      AMD EPYC 7V12 64-Core Processor
Stepping:                        0
CPU MHz:                         3296.887
BogoMIPS:                        4890.89
Hypervisor vendor:               Microsoft
Virtualization type:             full
L1d cache:                       3 MiB
L1i cache:                       3 MiB
L2 cache:                        48 MiB
L3 cache:                        384 MiB
NUMA node0 CPU(s):               0-23
NUMA node1 CPU(s):               24-47
NUMA node2 CPU(s):               48-71
NUMA node3 CPU(s):               72-95
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Mmio stale data:   Not affected
Vulnerability Retbleed:          Vulnerable
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Retpolines, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl tsc_reliable nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext perfctr_core ssbd vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves clzero xsaveerptr arat umip rdpid

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.22.2
[pip3] pytorch-lightning==1.9.3
[pip3] torch==1.13.0
[pip3] torch-nebula==0.16.2
[pip3] torch-ort==1.14.0
[pip3] torch-tb-profiler==0.4.1
[pip3] torchmetrics==0.11.3
[pip3] torchsnapshot==0.1.0
[pip3] torchvision==0.14.0+cu117
[conda] magma-cuda117             2.6.1                         1    pytorch
[conda] mkl                       2021.4.0                 pypi_0    pypi
[conda] mkl-include               2021.4.0                 pypi_0    pypi
[conda] numpy                     1.22.2                   pypi_0    pypi
[conda] pytorch-lightning         1.9.3                    pypi_0    pypi
[conda] torch                     1.13.0                   pypi_0    pypi
[conda] torch-nebula              0.16.2                   pypi_0    pypi
[conda] torch-ort                 1.14.0                   pypi_0    pypi
[conda] torch-tb-profiler         0.4.1                    pypi_0    pypi
[conda] torchmetrics              0.11.3                   pypi_0    pypi
[conda] torchsnapshot             0.1.0                    pypi_0    pypi
[conda] torchvision               0.14.0+cu117             pypi_0    pypi


cc @mruberry @mikaylagawarecki