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

Method _get_buffer_names

deepspeed/runtime/engine.py:5509–5528  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5507 self.checkpoint_engine.save(state_dict=state, path=save_path)
5508
5509 def _get_buffer_names(self):
5510 buffer_names = []
5511
5512 # we save buffer names so that we could extract later the real buffers from the saved
5513 # state_dict["module"] in the non-zero checkpoint - the buffers are already there but they
5514 # are intermixed with param placeholders
5515
5516 # have to traverse the tree to be able to skip non-persistent buffers
5517 def get_layer_named_buffers(module, prefix=""):
5518 for name, buf in module.named_buffers(recurse=False):
5519 if buf is not None and name not in module._non_persistent_buffers_set:
5520 buffer_names.append(prefix + name)
5521
5522 for name, child in module.named_children():
5523 if child is not None:
5524 get_layer_named_buffers(child, prefix + name + ".")
5525
5526 get_layer_named_buffers(self.module, prefix="")
5527
5528 return buffer_names
5529
5530 def _get_param_shape_func(self, param):
5531 return param.ds_shape if hasattr(param, 'ds_id') else param.shape

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected