File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
examples/models/llama/source_transformation Expand file tree Collapse file tree 2 files changed +17
-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):
202
202
torch .ops .load_library (libs [0 ])
203
203
op = torch .ops .quantized_decomposed .quantize_per_token .out
204
204
assert op is not None
205
+ import gc
206
+ import resource
207
+
205
208
# This is needed to ensure that custom ops are registered
206
209
from executorch .extension .llm .custom_ops import custom_ops # noqa: F401
207
210
211
+ rusage = resource .getrusage (resource .RUSAGE_SELF )
208
212
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 () } ) "
210
214
)
211
215
for name , child in module .named_children ():
212
216
if isinstance (child , KVCache ) or isinstance (child , CustomKVCache ):
@@ -270,8 +274,12 @@ def replace_kv_cache_with_custom_kv_cache(module):
270
274
This is because the custom op treats second dim as sequence dim.
271
275
Future work: support [B, H, S, D]
272
276
"""
277
+ import gc
278
+ import resource
279
+
280
+ rusage = resource .getrusage (resource .RUSAGE_SELF )
273
281
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 () } ) "
275
283
)
276
284
for name , child in module .named_children ():
277
285
if isinstance (child , KVCache ):
Original file line number Diff line number Diff line change @@ -156,7 +156,13 @@ def source_transform(
156
156
157
157
if self .verbose :
158
158
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
+ )
160
166
return self
161
167
162
168
def _get_dynamic_shape (self ) -> Any :
You can’t perform that action at this time.
0 commit comments