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

Method __deepcopy__

deepspeed/module_inject/layers.py:627–640  ·  view source on GitHub ↗
(self, memo)

Source from the content-addressed store, hash-verified

625 return torch.cat([shards[i].narrow(dim, 0, size) for i, size in enumerate(partition_sizes)], dim=dim)
626
627 def __deepcopy__(self, memo):
628 # This function is designed for
629 # 'mp_group' (a 'ProcessGroup') cannot be pickled during deepcopy in some usage.
630 cls = self.__class__
631 new_obj = cls.__new__(cls)
632
633 for key, value in vars(self).items():
634 if key == 'mp_group':
635 new_obj.mp_group = self.mp_group
636 else:
637 setattr(new_obj, key, deepcopy(value, memo))
638
639 memo[id(self)] = new_obj
640 return new_obj
641
642 def extra_repr(self):
643 out_features, in_features = None, None

Callers

nothing calls this directly

Calls 1

__new__Method · 0.45

Tested by

no test coverage detected