-
Notifications
You must be signed in to change notification settings - Fork 24.3k
DTensor does not support nn.init.eye_
#136946
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
Labels
module: dtensor
distributed tensor tag
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Comments
cc: @wanchaol |
# Modified from https://github.com/pytorch/pytorch/tree/main/torch/distributed/_tensor
# to run this file (i.e. dtensor_example.py):
# torchrun --standalone --nnodes=1 --nproc-per-node=1 dtensor_example.py
import os
import torch
from torch.distributed._tensor import DTensor, init_device_mesh, Shard, distribute_tensor
def eye_(t: DTensor) -> None:
diag = torch.arange(0, min(t.shape), device=t.device)
diag = distribute_tensor(diag, t.device_mesh, t.placements)
fill_value = torch.tensor([1.0], dtype=t.dtype, device=t.device)
fill_value = distribute_tensor(fill_value, t.device_mesh, t.placements)
t.fill_(0.0)
t[diag, diag] = fill_value
tensor = torch.rand((3, 3))
mesh = init_device_mesh("cuda", (int(os.environ["WORLD_SIZE"]),))
my_dtensor = distribute_tensor(tensor, mesh, [Shard(dim=0)])
eye_(my_dtensor) I was going to try to do something like this as a workaround but I'm getting an unexpected error about
|
Workaround (I have not tested this exact code because mine handles modules instead):
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
module: dtensor
distributed tensor tag
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Uh oh!
There was an error while loading. Please reload this page.
🐛 Describe the bug
Related:
nn.init.eye_
is not supported onDTensor
s. I wonder what other inplacenn.init
functions are not supported?Versions
cc @wanchaol @tianyu-l @wz337 @XilunWu @d4l3k
The text was updated successfully, but these errors were encountered: