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

stateless.functional_call doesn't work with nn.DataParallel #77576

Open
Chillee opened this issue May 16, 2022 · 3 comments
Open

stateless.functional_call doesn't work with nn.DataParallel #77576

Chillee opened this issue May 16, 2022 · 3 comments
Labels
actionable module: data parallel module: nn Related to torch.nn triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@Chillee
Copy link
Contributor

Chillee commented May 16, 2022

🐛 Describe the bug

Encountered in #77137 (comment)

import torch
import torch.nn as nn
import torch.nn.utils.stateless as stateless

class Foo(nn.Module):
    def __init__(self):
        super().__init__()
        self.weight = nn.Parameter(torch.ones(5))

    def forward(self, x):
        return self.weight + x

mod = Foo().cuda()
mod = nn.DataParallel(mod, [0, 1])
print(stateless.functional_call(mod, {'module.weight': torch.zeros(5, device='cuda')}, (torch.ones(2, 5, device='cuda'),)))

errors with
``
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1!


### Versions

Nightly

cc @ezyang @gchanan @zou3519 @albanD @mruberry @jbschlosser @walterddr @kshitij12345
@albanD
Copy link
Collaborator

albanD commented May 16, 2022

I think this should at least be a loud error as it is unlikely we're going to fix it right now.

@albanD albanD added module: nn Related to torch.nn triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module module: data parallel labels May 16, 2022
@jbschlosser
Copy link
Contributor

Actionable to add a loud error.

@kurtamohler
Copy link
Collaborator

I've added the error. Should we remove the high priority label, or is fixing it also high priority?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable module: data parallel module: nn Related to torch.nn triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

5 participants