Background
Deleting shared parameters means that the disk file is deleted twice, leading to an error
def test_shared_tensors_delete(tmp_path):
offload_dir = tmp_path / "offload_dir"
os.mkdir(offload_dir)
A = torch.nn.Linear(3, 5, bias=False)
B = torch.nn.Linear(3, 5, bias=False)
offload_module(A, "cuda", "disk", offload_dir=str(offload_dir))
with disable_onloading():
B.weight = A.weight
offload_module(B, "cuda", "disk", offload_dir=str(offload_dir))
assert len(os.listdir(offload_dir)) == 1
delattr(A, "weight")
assert len(os.listdir(offload_dir)) == 1
delattr(B, "weight")
assert len(os.listdir(offload_dir)) == 0
Proposed Changes
- Design a solution to allow for deletion of shared tensors when using the disk cache
Background
Deleting shared parameters means that the disk file is deleted twice, leading to an error
Proposed Changes