MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / _get_buffer_names

Method _get_buffer_names

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

Source from the content-addressed store, hash-verified

3115 self.checkpoint_engine.save(state, save_path)
3116
3117 def _get_buffer_names(self):
3118 buffer_names = []
3119
3120 # we save buffer names so that we could extract later the real buffers from the saved
3121 # state_dict["module"] in the non-zero checkpoint - the buffers are already there but they
3122 # are intermixed with param placeholders
3123
3124 # have to traverse the tree to be able to skip non-persistent buffers
3125 def get_layer_named_buffers(module, prefix=""):
3126 for name, buf in module.named_buffers(recurse=False):
3127 if buf is not None and name not in module._non_persistent_buffers_set:
3128 buffer_names.append(prefix + name)
3129
3130 for name, child in module.named_children():
3131 if child is not None:
3132 get_layer_named_buffers(child, prefix + name + ".")
3133
3134 get_layer_named_buffers(self.module, prefix="")
3135
3136 return buffer_names
3137
3138 def _get_param_shape_func(self, param):
3139 return param.ds_shape if hasattr(param, 'ds_id') else param.shape

Callers 1

_save_checkpointMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected