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

Method load_module_recursive

deepspeed/inference/engine.py:355–367  ·  view source on GitHub ↗
(module, prefix='', level=0)

Source from the content-addressed store, hash-verified

353 }
354
355 def load_module_recursive(module, prefix='', level=0):
356 for name, child in module.named_children():
357 if child.__class__ in layer_policies:
358 checking_key = prefix + name + '.'
359 if not any(checking_key in item for item in self.key_list):
360 continue
361 if len(list(child.parameters())) > 0 and list(child.parameters())[0].numel() == 0:
362 if len(child.weight.ds_shape) == 1:
363 child = Normalize(dim=child.weight.ds_shape[-1], dtype=child.weight.dtype, eps=child.eps)
364 setattr(module, name, child)
365 load(child, self.sd, prefix + name + '.')
366 else:
367 load_module_recursive(child, prefix if level == 0 else prefix + name + '.', level + 1)
368
369 load_module_recursive(r_module)
370

Callers

nothing calls this directly

Calls 5

NormalizeClass · 0.85
load_module_recursiveFunction · 0.85
numelMethod · 0.80
loadFunction · 0.50
parametersMethod · 0.45

Tested by

no test coverage detected