MCPcopy Index your code
hub / github.com/zai-org/CodeGeeX / unwrap_model

Function unwrap_model

codegeex/megatron/utils.py:34–46  ·  view source on GitHub ↗
(model, module_instances=(torchDDP))

Source from the content-addressed store, hash-verified

32
33
34def unwrap_model(model, module_instances=(torchDDP)):
35 return_list = True
36 if not isinstance(model, list):
37 model = [model]
38 return_list = False
39 unwrapped_model = []
40 for model_module in model:
41 while isinstance(model_module, module_instances):
42 model_module = model_module.module
43 unwrapped_model.append(model_module)
44 if not return_list:
45 return unwrapped_model[0]
46 return unwrapped_model
47
48
49def calc_params_l2_norm(model):

Callers 3

forward_stepFunction · 0.90
train_stepFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected