nvalchemi.training.unwrap_model#
- nvalchemi.training.unwrap_model(model)[source]#
Return the module a parallelism wrapper owns, or the model itself.
- Parameters:
model (torch.nn.Module) – A model as a strategy holds it, wrapped or bare.
- Returns:
The wrapped module, or
modelunchanged when nothing wraps it.- Return type:
Notes
A wrapper is recognized by the
moduleattribute it publishes, not by its class. A hand-rolled or FSDP wrapper therefore unwraps exactly as aDistributedDataParallelreplica does. The return type is the argument’s type, because a wrapper replaces the model at run time behind the type the caller declared.