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

Method _recursive_getattr

deepspeed/runtime/pipe/module.py:450–455  ·  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

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

Calls

no outgoing calls

Tested by

no test coverage detected