File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed
llama/source_transformation Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff 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 ):
Original file line number Diff line number Diff line change 2424logging .basicConfig (level = logging .INFO )
2525logger = logging .getLogger (__name__ )
2626
27+ import gc
28+ gc .set_debug (gc .DEBUG_STATS | gc .DEBUG_COLLECTABLE )
2729
2830class TestLlava (unittest .TestCase ):
2931 def setUp (self ):
Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments