Add PyTorch 1.11 support for lazy loader

This commit is contained in:
Gnome Ann
2022-03-17 12:51:41 -04:00
parent 9235754eb9
commit eaf190469d
4 changed files with 27 additions and 8 deletions

View File

@@ -961,7 +961,7 @@ def load_model(path: str, driver_version="tpu_driver0.1_dev20210607", hf_checkpo
# the least possible memory usage, we create them as meta
# tensors, which don't take up any actual CPU or TPU memory.
if key not in model_spec:
model_dict[key] = torch.empty(model_dict[key].shape, dtype=model_dict[key].storage_type(0).dtype, device="meta")
model_dict[key] = torch.empty(model_dict[key].shape, dtype=model_dict[key].dtype, device="meta")
continue
storage_key = model_dict[key].key