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

Method _recursive_getattr

deepspeed/runtime/pipe/module.py:447–452  ·  view source on GitHub ↗

Allow getting an attribute like "linear.weight

(module: torch.nn.Module, attr_name: str)

Source from the content-addressed store, hash-verified

445
446 @staticmethod
447 def _recursive_getattr(module: torch.nn.Module, attr_name: str) -> torch.Tensor:
448 '''Allow getting an attribute like "linear.weight"'''
449 weight = module
450 for item in attr_name.split("."):
451 weight = getattr(weight, item)
452 return weight
453
454 def allreduce_tied_weight_gradients(self):
455 '''All reduce the gradients of the tied weights between tied stages'''

Calls

no outgoing calls

Tested by

no test coverage detected