Skip to content

Commit bc2c3df

Browse files
Merge pull request #126 from johnmarktaylor91/perf/model-prep-session-refactor
2 parents fd67742 + b63a4fa commit bc2c3df

File tree

3 files changed

+147
-119
lines changed

3 files changed

+147
-119
lines changed

torchlens/data_classes/model_log.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,15 @@ def __init__(
232232
self.total_params_frozen: int = 0
233233
self.total_params_fsize: int = 0
234234

235+
# Session-scoped per-module tracking dicts (keyed by id(module)).
236+
# These replace the old tl_* attrs that were set directly on nn.Module
237+
# instances. Lives on ModelLog so they're GC'd with the log — no cleanup
238+
# iteration over modules needed.
239+
self._mod_pass_num: Dict[int, int] = {} # id(module) -> pass count
240+
self._mod_pass_labels: Dict[int, list] = {} # id(module) -> [(addr, pass_num), ...]
241+
self._mod_entered: Dict[int, list] = {} # id(module) -> [raw_label, ...]
242+
self._mod_exited: Dict[int, list] = {} # id(module) -> [raw_label, ...]
243+
235244
# Transient module build data (consumed by _build_module_logs, then cleared):
236245
self._module_build_data: Dict = _init_module_build_data()
237246

0 commit comments

Comments
 (0)