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

Method _recursive_getattr

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

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

Calls

no outgoing calls

Tested by

no test coverage detected