Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-place editor calls repeat when the modified model is run #210

Open
mitroitskii opened this issue Aug 30, 2024 · 5 comments
Open

In-place editor calls repeat when the modified model is run #210

mitroitskii opened this issue Aug 30, 2024 · 5 comments
Assignees

Comments

@mitroitskii
Copy link
Collaborator

mitroitskii commented Aug 30, 2024

For model.edit context, when inplace=True and return_context=True, all method calls of the context object (editor) repeat when the modified model is traced. The only editor method I am aware of is .log() so I tested this behavior on it.

It looks like each call of the model.edit context with editor.log inside it adds the editor.log call with the specified argument to the intervention graph. Then, when the model, that was edited in-place, is traced, it displays all the editor.log calls added inside the model.edit contexts.

Screenshot 2024-08-30 at 4 45 06 AM
@mitroitskii mitroitskii changed the title In-place editor calls repeat the the modified model is run In-place editor calls repeat when the modified model is run Aug 30, 2024
@AdamBelfki3
Copy link
Collaborator

AdamBelfki3 commented Aug 30, 2024

Does this behavior not appear if you use nnsight.log()?

@AdamBelfki3
Copy link
Collaborator

Isn't this expected behavior since you are the cell multiple times with in_place editing?

@mitroitskii
Copy link
Collaborator Author

Same thing happens with nnsight.log().

My understanding was that the in-place is supposed to only modify the modules of the model whereas right now it looks like it just attaches literally everything within the context to the intervention graph. Is it expected?

@AdamBelfki3
Copy link
Collaborator

Yes, it is expected! It basically defines any default interventions to be ran before the newly define intervention graph in a certain context.

@mitroitskii
Copy link
Collaborator Author

mitroitskii commented Aug 30, 2024

This feels potentially tricky and error-prone as there are so many operations now that are patched in and are a part of the intervention graph - literally every built-in operation, all torch methods, all torch tensor creation operations and einsop functions.

How can we make it more obvious that the .edit() not only modifies the modules of the model but literally "remembers" everything the user specifies in the context?

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

No branches or pull requests

3 participants