Skip to content

In-place ops on cloned tensor propagates to the original tensor #2793

@shino16

Description

@shino16

🐛 Bug

On main 006a243

import torch, thunder

@thunder.jit
def fn(x):
    y = x.clone()
    y.sin_()
    return x + y

x = torch.randn(4, device="cuda")
x_ref = x.clone()
out = fn(x)

torch.testing.assert_close(x, x_ref)  # AssertionError: Tensor-likes are not close!
torch.testing.assert_close(out, x_ref + x_ref.sin())  # AssertionError: Tensor-likes are not close!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions