Skip to content

Commit c70280b

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: 45e7e64 ghstack-comment-id: 2634969596 Pull Request resolved: #8192
1 parent a3455d9 commit c70280b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

examples/models/llama/source_transformation/quantized_kv_cache.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,11 @@ def replace_kv_cache_with_quantized_kv_cache(module):
205205
# This is needed to ensure that custom ops are registered
206206
from executorch.extension.llm.custom_ops import custom_ops # noqa: F401
207207

208+
import resource
209+
maxrss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
210+
nswap = resource.getrusage(resource.RUSAGE_SELF).ru_nswap
208211
logging.warning(
209-
"Replacing KVCache with QuantizedKVCache. This modifies the model in place."
212+
f"Replacing KVCache with QuantizedKVCache. This modifies the model in place. (HACK: maxrss: {maxrss} nswap: {nswap})"
210213
)
211214
for name, child in module.named_children():
212215
if isinstance(child, KVCache) or isinstance(child, CustomKVCache):
@@ -270,8 +273,11 @@ def replace_kv_cache_with_custom_kv_cache(module):
270273
This is because the custom op treats second dim as sequence dim.
271274
Future work: support [B, H, S, D]
272275
"""
276+
import resource
277+
maxrss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
278+
nswap = resource.getrusage(resource.RUSAGE_SELF).ru_nswap
273279
logging.warning(
274-
"Replacing KVCache with CustomKVCache. This modifies the model in place."
280+
f"Replacing KVCache with CustomKVCache. This modifies the model in place. (HACK: maxrss: {maxrss} nswap: {nswap})"
275281
)
276282
for name, child in module.named_children():
277283
if isinstance(child, KVCache):

extension/llm/export/builder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ 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 resource
160+
maxrss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
161+
nswap = resource.getrusage(resource.RUSAGE_SELF).ru_nswap
162+
logging.info(f"Model after source transforms: {self.model} (HACK: maxrss: {maxrss} nswap: {nswap})")
160163
return self
161164

162165
def _get_dynamic_shape(self) -> Any:

0 commit comments

Comments
 (0)