From 3cbbf378b2280baa336bbee8f417ef7a1e05afb6 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Tue, 4 Feb 2025 12:16:31 -0800 Subject: [PATCH 1/3] Update [ghstack-poisoned] --- .../llama/source_transformation/quantized_kv_cache.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/models/llama/source_transformation/quantized_kv_cache.py b/examples/models/llama/source_transformation/quantized_kv_cache.py index 023fc6800ff..8dcb5c0d995 100644 --- a/examples/models/llama/source_transformation/quantized_kv_cache.py +++ b/examples/models/llama/source_transformation/quantized_kv_cache.py @@ -205,8 +205,11 @@ def replace_kv_cache_with_quantized_kv_cache(module): # This is needed to ensure that custom ops are registered from executorch.extension.llm.custom_ops import custom_ops # noqa: F401 + import resource + maxrss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss + nswap = resource.getrusage(resource.RUSAGE_SELF).ru_nswap logging.warning( - "Replacing KVCache with QuantizedKVCache. This modifies the model in place." + f"Replacing KVCache with QuantizedKVCache. This modifies the model in place. (HACK: maxrss: {maxrss} nswap: {nswap})" ) for name, child in module.named_children(): if isinstance(child, KVCache) or isinstance(child, CustomKVCache): @@ -270,8 +273,11 @@ def replace_kv_cache_with_custom_kv_cache(module): This is because the custom op treats second dim as sequence dim. Future work: support [B, H, S, D] """ + import resource + maxrss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss + nswap = resource.getrusage(resource.RUSAGE_SELF).ru_nswap logging.warning( - "Replacing KVCache with CustomKVCache. This modifies the model in place." + f"Replacing KVCache with CustomKVCache. This modifies the model in place. (HACK: maxrss: {maxrss} nswap: {nswap})" ) for name, child in module.named_children(): if isinstance(child, KVCache): From f3ec03c0a73f20a45a547cd5bd08bde1a07f062c Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Tue, 4 Feb 2025 15:09:14 -0800 Subject: [PATCH 2/3] Update [ghstack-poisoned] --- extension/llm/export/builder.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extension/llm/export/builder.py b/extension/llm/export/builder.py index be6977b639c..d860a0307f6 100644 --- a/extension/llm/export/builder.py +++ b/extension/llm/export/builder.py @@ -156,7 +156,10 @@ def source_transform( if self.verbose: logging.info(f"Applied source transforms: {self.applied_source_transforms}") - logging.info(f"Model after source transforms: {self.model}") + import resource + maxrss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss + nswap = resource.getrusage(resource.RUSAGE_SELF).ru_nswap + logging.info(f"Model after source transforms: {self.model} (HACK: maxrss: {maxrss} nswap: {nswap})") return self def _get_dynamic_shape(self) -> Any: From a293784f8902150acf133f4fa290d86d1ad736e4 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Thu, 6 Feb 2025 14:08:19 -0800 Subject: [PATCH 3/3] Update [ghstack-poisoned] --- examples/models/llava/test/test_llava.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/models/llava/test/test_llava.py b/examples/models/llava/test/test_llava.py index 5fd60399415..aeea0bb964a 100644 --- a/examples/models/llava/test/test_llava.py +++ b/examples/models/llava/test/test_llava.py @@ -24,6 +24,8 @@ logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) +import gc +gc.set_debug(gc.DEBUG_STATS | gc.DEBUG_COLLECTABLE) class TestLlava(unittest.TestCase): def setUp(self):