MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / full

Method full

deepspeed/runtime/utils.py:715–732  ·  view source on GitHub ↗
(self, device=None)

Source from the content-addressed store, hash-verified

713 return tensor_part, partition
714
715 def full(self, device=None):
716 if device is None:
717 device = self.orig_device
718
719 # Allocate the full tensor as a flat buffer.
720 full_numel = prod(self.full_size())
721 flat_tensor = torch.zeros([full_numel], dtype=self.local_data.dtype, device=device)
722 if self.even_split:
723 # Collect the full tensor
724 dist.all_gather_into_tensor(flat_tensor, self.local_data, group=self.group)
725 else:
726 for part_id in range(self.num_parts):
727 part_size = self.partition[part_id + 1] - self.partition[part_id]
728 buf = flat_tensor.narrow(0, start=self.partition[part_id], length=part_size)
729 if part_id == self.rank:
730 buf.copy_(self.local_data)
731 dist.broadcast(buf, part_id, self.group)
732 return flat_tensor.view(self.full_size()).clone().detach()
733
734 def to_meta(self):
735 """Returns a torch.LongTensor that encodes partitioning information.

Callers 15

testMethod · 0.95
testMethod · 0.95
multi_output_dataloaderFunction · 0.80
test_moe_gatherFunction · 0.80
test_layer_inheritanceFunction · 0.80
fake_reduce_scatterMethod · 0.80

Calls 4

full_sizeMethod · 0.95
copy_Method · 0.80
broadcastMethod · 0.45