Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] functorch.dim breaks split of big tensors #26

Open
vmoens opened this issue Nov 7, 2022 · 2 comments
Open

[BUG] functorch.dim breaks split of big tensors #26

vmoens opened this issue Nov 7, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@vmoens
Copy link
Contributor

vmoens commented Nov 7, 2022

Describe the bug

For some reason (probably unrealted to tensordict), functorch dims fails with big tensors.

import torch
from tensordict import TensorDict

# build splits
total = 0
l = []
while total < 6400:
    l.append(torch.randint(2, 10, (1,)).item())
    total += l[-1]

# build td
tensordict = TensorDict({"x": torch.randn(6401, 1), "y": torch.randn(6401, 1)}, [])

# split
for k, x in tensordict.items():
    x.split(l, 0)

This should result in an error like this:

libc++abi: terminating with uncaught exception of type c10::Error: allocated_ <= ARENA_MAX_SIZE INTERNAL ASSERT FAILED at "/stuff/pytorch/pytorch/pytorch/functorch/csrc/dim/arena.h":227, please report a bug to PyTorch. 
@vmoens vmoens added the bug Something isn't working label Nov 7, 2022
@vmoens vmoens self-assigned this Nov 7, 2022
@tcbegley
Copy link
Contributor

tcbegley commented Nov 7, 2022

I don't understand this yet, but can confirm that this appears to be unrelated to tensordict.

import torch

t = torch.rand(6401, 1)

# build splits
total = 0
l = []
while total < 6400:
    l.append(torch.randint(2, 10, (1,)).item())
    total += l[-1]

# could get RuntimeError if `sum(l) != 6401`
l[-1] = 6401 - sum(l[:-1])

# this is fine
_ = t.split(l, 0)

But now, if we import functorch.dim it will fail

import functorch.dim

_ = t.split(l, 0)

So something is happening at import with functorch that results in this bad behaviour. I'll try to pin it down a bit more but seems clear it's an issue upstream.

@vmoens vmoens changed the title [BUG] [BUG] functorch.dim breaks split of big tensors Nov 7, 2022
@vmoens
Copy link
Contributor Author

vmoens commented Nov 7, 2022

see this bug for ref

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants