-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
Fix: Mamba2 generation mismatch between input_ids and inputs_embeds #32694
Fix: Mamba2 generation mismatch between input_ids and inputs_embeds #32694
Conversation
Lmk if there's a better way to do this but I think this should be ok. At least the cause of the issue is apparent now. |
That's a nice fix, thanks! I wonder if we can use |
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.
Can you add a small test. They exist for other model in the Mixin, https://github.com/huggingface/transformers/blob/main/tests/test_modeling_common.py#L2777 should be tested for mamba models
if input_ids.shape[1] == 0: | ||
past_len = inputs_embeds.shape[1] | ||
if inputs_embeds is not None: | ||
past_len = inputs_embeds.shape[1] + input_ids.shape[1] |
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 is no longer the past length, but the current length 😉 Otherwise as this is used to create the cache positions, this is valid 😉
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.
Fair enough :p
@ArthurZucker Isn't it also tested for all mamba-related models already? I've run the mamba2 tests locally for example and the test you linked was included in them (can also be seen in the CI of this PR over here). Maybe I've misunderstood something 😅 Could you clarify the test? |
You are right I forgot that it was failing ever since we added it! |
Thanks @vasqu for maintaining mamba2 😉 |
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. |
What does this PR do?
Fixes the failing generation test in mamba2 comparing the generation between passing input ids or passing the embeds directly. The cause of the mismatch was a false calculation of
past_len
which can be solved by changing the if check slightly.Fixes #32555
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@molbap @ArthurZucker