Skip to content

Conversation

@MichaelRipa
Copy link
Member

Description

This PR introduces more informative error messages when trying to access .input, .inputs or .output outside of a trace context.

@AdamBelfki3
Copy link
Member

Did you run into limitations when you tried to decorate the functions in question? Is it because they're already decorated as properties?

@MichaelRipa MichaelRipa linked an issue Mar 24, 2025 that may be closed by this pull request
@JadenFiotto-Kaufman
Copy link
Member

JadenFiotto-Kaufman commented Mar 25, 2025

@MichaelRipa Can you also make this error message better in this PR?

raise ValueError("Accessing value before it's been set.")

People have suggesting adding Did you forget to call .save()? or something

@MichaelRipa
Copy link
Member Author

@MichaelRipa Can you also make this error message better in this PR?

raise ValueError("Accessing value before it's been set.")

People have suggesting adding Did you forget to call .save()? or something

Done. I feel like there might be somewhere better upstream to catch and log this (since .save() isn't well defined with respect to the Node class) but just directly updated the error message for the time being.

@MichaelRipa
Copy link
Member Author

@JadenFiotto-Kaufman The node error message shows up in undesirable circumstances:

import nnsight
model = nnsight.LanguageModel("openai-community/gpt2")

with model.trace("ayy"):
  x = model.transformer.h[0].attn.attn_dropout.output.save()
    
print(x.shape)
ValueError: Accessing value before it's been set. Did you forget to call .save()?

Is this expected behavior (and if so would there be a better error to log) or a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More intuitive error message

4 participants