nnsight.envoy#

class nnsight.envoy.Envoy(module: Module, module_path: str = '')[source]#

Envoy object act as proxies for torch modules within a model’s module tree in order to add nnsight functionality. Proxies of the underlying module’s output and input are accessed by .output and .input respectively.

_module_path#

String representing the attribute path of this Envoy’s module relative the the root model. Separated by ‘.’ e.x (‘transformer.h.0.mlp’). Set by NNsight on initialization of meta model.

Type:

str

_fake_outputs#

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.

Type:

List[torch.Tensor]

_fake_inputs#

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.

Type:

List[torch.Tensor]

output#

Proxy object representing the output of this Envoy’s module. Reset on forward pass.

Type:

nnsight.intervention.InterventionProxy

input#

Proxy object representing the input of this Envoy’s module. Reset on forward pass.

Type:

nnsight.intervention.InterventionProxy

_call_iter#

Integer representing the current iteration of this Envoy’s module’s inputs/outputs.

Type:

int

_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.

Type:

nnsight.context.Tracer.Tracer

property input: InterventionProxy#

Calling denotes the user wishes to get the input of the underlying module and therefore we create a Proxy of that request. Only generates a proxy the first time it is references otherwise return the already set one.

Returns:

Input proxy.

Return type:

InterventionProxy

property output: InterventionProxy#

Calling denotes the user wishes to get the output of the underlying module and therefore we create a Proxy of that request. Only generates a proxy the first time it is references otherwise return the already set one.

Returns:

Output proxy.

Return type:

InterventionProxy