Fix HookedTransformerConfig rotary_base types#1231
Open
brendanlong wants to merge 1 commit intoTransformerLensOrg:mainfrom
Open
Fix HookedTransformerConfig rotary_base types#1231brendanlong wants to merge 1 commit intoTransformerLensOrg:mainfrom
brendanlong wants to merge 1 commit intoTransformerLensOrg:mainfrom
Conversation
Contributor
Author
|
I'm tempted to add a TypedDict for the configs so this kind of mismatch would be caught by mypy instead of being a runtime error during tests, and I also noticed that there's a bunch of missing type annotations on function return types in loading_from_pretrained.py but wanted to avoid making a massive PR and wasn't sure if those improvements would actually be helpful. |
ccce13e to
6fec5c4
Compare
rotary_base is frequently set to floats in the code but was typed as an int, causing beartype errors if the configs get loaded in a test: https://github.com/TransformerLensOrg/TransformerLens/blob/9c5a2a81674d5bcefa641c816b66e9827ccdf637/transformer_lens/loading_from_pretrained.py#L1984 HF confgs' allegedly always have rope_theta as a float: https://github.com/huggingface/transformers/blob/c38b2fb78eaedd4261a0e446f7976345cd1c7f1b/src/transformers/modeling_rope_utils.py#L645 But sometimes they're actually ints, and beartype doesn't consider int to be a subtype of float: beartype/beartype#66 This updates the type to Union[float, int] to be accurate while keeping beartype happy.
6fec5c4 to
a36e7c9
Compare
Contributor
Author
|
I could change the type to just |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
rotary_base is frequently set to floats in the code but was typed as
an int, causing beartype errors if the configs get loaded in a test:
TransformerLens/transformer_lens/loading_from_pretrained.py
Line 1984 in 9c5a2a8
HF confgs' allegedly always have rope_theta as a float:
https://github.com/huggingface/transformers/blob/c38b2fb78eaedd4261a0e446f7976345cd1c7f1b/src/transformers/modeling_rope_utils.py#L645
But sometimes they're actually ints, and beartype doesn't consider int
to be a subtype of float:
beartype/beartype#66
This updates the type to Union[float, int] to be accurate while keeping
beartype happy.
See:
Type of change
Please delete options that are not relevant.
Checklist: