-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
adding positional encoder changes and tests #32600
base: main
Are you sure you want to change the base?
Conversation
@amyeroberts I have included the interpolation of positional embeddings in all the following models, and their respective tests:
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding - looks great!
Just a handful of small nits. Before merge, we'll need to run the slow tests for the models affected. Could you trigger this by running git commit --allow-empty -m "[run_slow] altclip, bridgetower, chinese_clip, clip, clipseg, git, kosmos2, x_clip"
model(**inputs, interpolate_pos_encoding=False) | ||
# forward pass | ||
with torch.no_grad(): | ||
outputs = model(**inputs, interpolate_pos_encoding=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice :)
@unittest.skip(reason="GitForCausalLM does not support inputs_embeds in generate method") | ||
def test_inputs_embeds_matches_input_ids_with_generate(self): | ||
pass | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this as this logic is independent of this PR
@unittest.skip(reason="GitForCausalLM does not support inputs_embeds in generate method") | |
def test_inputs_embeds_matches_input_ids_with_generate(self): | |
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove this, I will get the following error from the CI pipeline:
FAILED tests/models/git/test_modeling_git.py::GitModelTest::test_inputs_embeds_matches_input_ids_with_generate - ValueError: You passed `inputs_embeds` to `.generate()`, but the model class GitForCausalLM doesn't have its forwarding implemented. See the GPT2 implementation for an example (https://github.com/huggingface/transformers/pull/21405), and feel free to open a PR with it!
as shown here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rebase on main? I believe this has been resolved upstream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should still be removed as this tests is unrelated to this PR
return_dict (`bool`, *optional*): | ||
Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -512,6 +526,8 @@ def _init_weights(self, module): | |||
output_hidden_states (`bool`, *optional*): | |||
Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for | |||
more detail. | |||
interpolate_pos_encoding (`bool`, *optional*): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interpolate_pos_encoding (`bool`, *optional*): | |
interpolate_pos_encoding (`bool`, *optional*, defaults to `False`): |
@@ -549,6 +565,8 @@ def _init_weights(self, module): | |||
output_hidden_states (`bool`, *optional*): | |||
Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for | |||
more detail. | |||
interpolate_pos_encoding (`bool`, *optional*): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interpolate_pos_encoding (`bool`, *optional*): | |
interpolate_pos_encoding (`bool`, *optional*, defaults to `False`): |
OK, I've:
Please don't merge yet, just need some time to check and potentially fix the tests. |
GIT model test still requires to be fixed. Getting this error:
due to Still on it. |
@manuelsh Have you included the most recent updates from |
Did it and still getting the same error. These two tokens (49406 and 49407) are special tokens added by the processor, they are I will do further debugging once I find time. In the meantime any suggestion is appreciated. |
@amyeroberts I found the source of the issue: the pre-trained model for GIT needed to be updated to the correct one. I think this should make it! However, now I am getting the following integration error coming from
|
Hi @amyeroberts I update main again with all changes and now it seems that all tests are passed, so it's ready to merge! |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
@manuelsh Great! As there's been a few changes since the last slow run, we'll need to do another |
…here is no vision_model_output
@amyeroberts I did a couple of fixes (one in another non related test, |
Hi @amyeroberts , I wonder if there is something missing or we can merge it. |
@manuelsh Thanks for all the work so far on this! Yes, there's a final iteration we'll need to do -- otherwise the code all looks good. Last week we merged in #33226. This fixed an issue in a lot of our vision models, which were using Could you update the interpolate functions to use this updated logic flow? The tests shouldn't be affected. |
@amyeroberts done, all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful - thanks for adding this capability to our models and for iterating on a solution!
@manuelsh Just the failing slow tests to address! |
@amyeroberts , I think it is not just substituting I believe I can make them work with
but now all my tests are crashing for different reasons (different tensors outputs for example) and this will take longer. Why not getting back to the previous working commit (d44e070), merge it, and then open another PR like #33226 but for the clip family models? I would be happy to contribute to it. |
@amyeroberts I was able to fix all tests with the new function, so no need to do an additional PR. Please review. |
@amyeroberts as there were some conflicts with merging with main on #31900 (possibly due to the
make
scripts), I have reimplemented all the changes of #30783 in a new branch, which is rebased to main.