MCPcopy Index your code
hub / github.com/InternLM/InternLM / dump

Method dump

internlm/utils/simple_memory_profiler.py:140–156  ·  view source on GitHub ↗

Dump the memory state of the model and sub-models. Args: prefix (str, optional): The prefix to add to the layer names. Defaults to "". Returns: str: The memory state information.

(self, prefix: str = "")

Source from the content-addressed store, hash-verified

138 return current_node
139
140 def dump(self, prefix: str = "") -> str:
141 """
142 Dump the memory state of the model and sub-models.
143
144 Args:
145 prefix (str, optional): The prefix to add to the layer names. Defaults to "".
146
147 Returns:
148 str: The memory state information.
149 """
150 cur_prefix = prefix + "." + self.layer_name if prefix != "" else self.layer_name
151 res = f"layer: {cur_prefix}, layer_mem: {self.layer_mem / mb:.2f} MB, total_mem: {self.total_mem / mb:.2f} MB\n"
152
153 for sub_layer in self.sub_model_stats.values():
154 res += sub_layer.dump(cur_prefix)
155
156 return res
157
158 def to_json(self, base: int = 1024 * 1024) -> dict:
159 """

Callers 3

convert2hf.pyFile · 0.45
dumpMethod · 0.45
pointMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected