-
Notifications
You must be signed in to change notification settings - Fork 322
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
(v2) Draft PR: add Pyright static typing to hook_points.py #590
Conversation
Co-authored-by: Alan <41682961+alan-cooney@users.noreply.github.com>
Cumulative changes made to transformer lens recently
(fixing the extra bugs right now - should be done soon) |
I've changed added assertion statements to deal with some of these issues - though, I'm recalling that alan sent a message here about using if statements instead of assertions. is that important for our purpose (and should I go through and change all instances?)
^ Edit: nevermind, i think i figured it out, I've replaced those with |
I saw that you merged main into your branch. We are actually going to be targeting dev as this will either be worked into our 2.0 release, or it will come quickly after that. I don't think there will be any new issues caused by the branch difference, but if you may want to update your branch to dev, that would probably be a good idea. For the asserts, from a personal preference, I do prefer having errors being checked with an if, and then thrown. Assert is for testing. It really should only be used in testing. It is pretty common to use it in the research world, but throwing errors is typically the preferred way to handle things. It allows you to be specific with your errors, and it's a lot easier to read when glancing at the code. You have to be fairly vigilant to see an assert on what is most of the time a single line as opposed to an |
For Hooked SAE stuff, don't worry about that. We are removing that in 2.0 in favor of sending people over to SAELens. If you want to wait until tomorrow, I can have it removed, so you can merge agains the pending 2.0 with it about 98% ready for release. |
Okay sounds good, I can wait until the HookedSAE gets removed and then I'll make these changes |
Everything pending for 2.0 is in the |
I'll have the hooked SAE stuff removed tomorrow, but you can just ignore it if it's still there. |
I reverted the change to I think I'm being a git noob herem but I can't figure out how to merge the dev branch into this, all I can do is merge main into it |
I left the other ones alone for now, I want to get this PR done first. I might be able to do a second pass-through and clean them all up down the line. |
If you can rename your pr branch, I can get dev merged into your branch, and wrap up the last minute details on this. |
did that, thanks |
* Initial Commit (add pyright + test by adding few annotations) * Slightly more typing added * more typing * Additional typing * Completed typing for hook_points.py file * todo clarifications * formatting changes to hook_points.py * Apply some suggestions from code review Co-authored-by: Alan <41682961+alan-cooney@users.noreply.github.com> * Added typing for Literals and changed some assertions to if statements * formatting * update to accout for merged code * small typing issue * changing hookfunction protocol + more assertions * change the slice input * change from isinstance to callable checks * fix: Update Gemma to reflect upstream HF changes (#596) * update activation function to tanh approximation * keep RMSNorm calcs in float32 and match cfg dtype for embedding scaling * formatting * keep mypy happy * formatting * allow user to force trust_remote_code=true via from_pretrained kwargs (#597) * change + revert HookFunctionProtocol * format * module_output is now just a tensor * set module ouput to be any type --------- Co-authored-by: Alan <41682961+alan-cooney@users.noreply.github.com> Co-authored-by: Bryce Meyer <bryce13950@gmail.com> Co-authored-by: cmathw <108584265+cmathw@users.noreply.github.com> Co-authored-by: Clement Dumas <clement.dumas@ens-paris-saclay.fr>
Description
This is a copy of PR #464 , but just remade so that @bryce13950 can close it.
This draft PR adds Pyright static typing to hook_points.py. See Alan's message on the slack for motivation/background. Specifically, this PR:
It's not entirely complete, but is in a state to where it would benefit from some review/assistance. Before being PR ready, we should:
Type of change
Please delete options that are not relevant.
Checklist:
I have made corresponding changes to the documentationI have added tests that prove my fix is effective or that my feature works