Closed AdamBelfki3 closed 3 weeks ago
NNsight syntactic change!
Envoy.input now points directly to the first positional argument of a module, i.e. the first tensor input.
Envoy.input
from nnsight import LanguageModel model = LanguageModel("openai-community/gpt2", device_map="auto") with model.trace("Hello World"): hs = model.transformer.h[6].input.save() print("Tensor: ", hs)
""" Tensor: tensor([[[ 0.9839, -2.3671, 0.9822, ..., -1.1355, -0.6406, -1.1865], [-0.6150, -0.0651, 2.2578, ..., -0.2923, -1.8130, 2.8994]]], device='mps:0', grad_fn=<AddBackward0>) """
If you still wish to access to full module input, you can use Envoy.inputs:
Envoy.inputs
from nnsight import LanguageModel model = LanguageModel("openai-community/gpt2", device_map="auto") with model.trace("Hello World"): hs = model.transformer.h[6].inputs.save() print("Input: ", hs)
""" Input: ((tensor([[[ 0.9839, -2.3671, 0.9822, ..., -1.1355, -0.6406, -1.1865], [-0.6150, -0.0651, 2.2578, ..., -0.2923, -1.8130, 2.8994]]], device='mps:0', grad_fn=<AddBackward0>),), {'layer_past': None, 'attention_mask': None, 'head_mask': None, 'encoder_hidden_states': None, 'encoder_attention_mask': None, 'use_cache': True, 'output_attentions': False}) """
NNsight syntactic change!
Envoy.input
now points directly to the first positional argument of a module, i.e. the first tensor input.If you still wish to access to full module input, you can use
Envoy.inputs
: