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

Function z3_leaf_module

deepspeed/utils/z3_leaf_module.py:15–23  ·  view source on GitHub ↗

Returns whether a module in `model` has been flagged as a 'leaf' module. See `set_z3_leaf_modules` for more details. Args: model (torch.nn.Module): The model to which the leaf module flag will be applied. Returns: bool: Whether the module has been flag

(model: torch.nn.Module)

Source from the content-addressed store, hash-verified

13
14
15def z3_leaf_module(model: torch.nn.Module) -> bool:
16 """Returns whether a module in `model` has been flagged as a 'leaf' module.
17 See `set_z3_leaf_modules` for more details.
18 Args:
19 model (torch.nn.Module): The model to which the leaf module flag will be applied.
20 Returns:
21 bool: Whether the module has been flagged as a 'leaf' module.
22 """
23 return hasattr(model, '_z3_leaf') and model._z3_leaf
24
25
26def z3_leaf_parameter(model: torch.nn.Parameter) -> bool:

Calls

no outgoing calls