Skip to content

Commit 0de4aed

Browse files
committed
NOCOMMIT: log peak mem usage and swapouts to debug test-llava-runner
Attempting to test my theory that the timestamp gaps in #8180 are caused by swapping. ghstack-source-id: 0bc03bc ghstack-comment-id: 2634969596 Pull Request resolved: #8192
1 parent 8ec08f9 commit 0de4aed

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

examples/models/llama/source_transformation/quantized_kv_cache.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,15 @@ def replace_kv_cache_with_quantized_kv_cache(module):
202202
torch.ops.load_library(libs[0])
203203
op = torch.ops.quantized_decomposed.quantize_per_token.out
204204
assert op is not None
205+
import gc
206+
import resource
207+
205208
# This is needed to ensure that custom ops are registered
206209
from executorch.extension.llm.custom_ops import custom_ops # noqa: F401
207210

211+
rusage = resource.getrusage(resource.RUSAGE_SELF)
208212
logging.warning(
209-
"Replacing KVCache with QuantizedKVCache. This modifies the model in place."
213+
f"Replacing KVCache with QuantizedKVCache. This modifies the model in place. (HACK: rusage: {rusage} gc stats: {gc.get_stats()})"
210214
)
211215
for name, child in module.named_children():
212216
if isinstance(child, KVCache) or isinstance(child, CustomKVCache):
@@ -270,8 +274,12 @@ def replace_kv_cache_with_custom_kv_cache(module):
270274
This is because the custom op treats second dim as sequence dim.
271275
Future work: support [B, H, S, D]
272276
"""
277+
import gc
278+
import resource
279+
280+
rusage = resource.getrusage(resource.RUSAGE_SELF)
273281
logging.warning(
274-
"Replacing KVCache with CustomKVCache. This modifies the model in place."
282+
f"Replacing KVCache with CustomKVCache. This modifies the model in place. (HACK: rusage: {rusage} gc stats: {gc.get_stats()})"
275283
)
276284
for name, child in module.named_children():
277285
if isinstance(child, KVCache):

extension/llm/export/builder.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,13 @@ def source_transform(
156156

157157
if self.verbose:
158158
logging.info(f"Applied source transforms: {self.applied_source_transforms}")
159-
logging.info(f"Model after source transforms: {self.model}")
159+
import gc
160+
import resource
161+
162+
rusage = resource.getrusage(resource.RUSAGE_SELF)
163+
logging.info(
164+
f"Model after source transforms: {self.model} (HACK: rusage: {rusage} gc_stats: {gc.get_stats()})"
165+
)
160166
return self
161167

162168
def _get_dynamic_shape(self) -> Any:

0 commit comments

Comments
 (0)