Skip to content

[Bug] Disk Offloading and Deletion of Shared Tensors #638

Description

@kylesayrs

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions