Skip to content

Commit

Permalink
Updates @clement
Browse files Browse the repository at this point in the history
  • Loading branch information
JadenFiotto-Kaufman committed Dec 7, 2024
1 parent 9350d53 commit 42500f5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/nnsight/intervention/envoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class Envoy(Generic[InterventionProxyType, InterventionNodeType]):
_children (List[Envoy]): Immediate Envoy children of this Envoy.
_fake_outputs (List[torch.Tensor]): List of 'meta' tensors built from the outputs most recent _scan. Is list as there can be multiple shapes for a module called more than once.
_fake_inputs (List[torch.Tensor]): List of 'meta' tensors built from the inputs most recent _scan. Is list as there can be multiple shapes for a module called more than once.
_rename (Optional[Dict[str,str]]): Optional mapping of (regex string -> new name).
For example to rename all gpt 'attn' modules to 'attention' you would: rename={r"\.transformer\.h\.\d+.attn": "attention"}
_rename (Optional[Dict[str,str]]): Optional mapping of (old name -> new name).
For example to rename all gpt 'attn' modules to 'attention' you would: rename={r"attn": "attention"}
Not this does not actually change the underlying module names, just how you access its envoy. Renaming will replace Envoy.path but Envoy._path represents the pre-renamed true attribute path.
_tracer (nnsight.context.Tracer.Tracer): Object which adds this Envoy's module's output and input proxies to an intervention graph. Must be set on Envoys objects manually by the Tracer.
"""
Expand Down Expand Up @@ -346,10 +346,8 @@ def _add_envoy(self, module: torch.nn.Module, name: str) -> None:

for key, value in self._rename.items():

match = re.match(key, module_path)

if match is not None:

if name == key:

name = value

alias_path = f"{self.path}.{name}"
Expand Down

0 comments on commit 42500f5

Please sign in to comment.