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

fix num_assistant_tokens with heuristic schedule #28759

Merged
merged 17 commits into from
Feb 16, 2024

Conversation

jmamou
Copy link
Contributor

@jmamou jmamou commented Jan 29, 2024

What does this PR do?

We have defined 2 different num_assistant_tokens_schedule values:

  • heuristic: When all speculative tokens are correct, increase num_assistant_tokens by 2 else reduce by 1. num_assistant_tokens value is persistent over multiple generation calls with the same assistant model.
  • heuristic_transient: Same as "heuristic but num_assistant_tokens is reset to its initial value after each generation call.

Fixes # (issue)
#27979 (comment)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@gante @amyeroberts

Copy link
Member

@gante gante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix and the tests 💛

src/transformers/generation/configuration_utils.py Outdated Show resolved Hide resolved
src/transformers/generation/candidate_generator.py Outdated Show resolved Hide resolved
jmamou and others added 3 commits February 7, 2024 23:06
check that candidate_generator.assistant_model exists since some some speculations (like ngram and PLD) don't have assistant_model attribute
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

src/transformers/generation/candidate_generator.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!

For the code quality checks, you'll need to run make fixup and push the changes.

From the docstring, it mentions behaviour about `"heuristic_transient" being reset, but I don't see logic relating to it in this diff. Does this already happen?

tests/generation/test_utils.py Outdated Show resolved Hide resolved
tests/generation/test_utils.py Outdated Show resolved Hide resolved
@jmamou
Copy link
Contributor Author

jmamou commented Feb 8, 2024

Thanks for adding this!

For the code quality checks, you'll need to run make fixup and push the changes.

From the docstring, it mentions behaviour about `"heuristic_transient" being reset, but I don't see logic relating to it in this diff. Does this already happen?

I just fixed docstring

@amyeroberts
Copy link
Collaborator

@jmamou Let's try and make the CI green :) You'll need to resolve the quality checks by running make fixup and pushing the changes.

For the other failing tests, you'll need to try rebasing on main.

@jmamou
Copy link
Contributor Author

jmamou commented Feb 12, 2024

@amyeroberts
tests_torch failed.
Are you familiar with the error?

@amyeroberts
Copy link
Collaborator

@jmamou Tbh, I'm not sure what the cause of these failures are. I would first suggest rebasing on main to make sure you have all of the most recent commits. This will trigger a re-run of the CI too.

@jmamou
Copy link
Contributor Author

jmamou commented Feb 14, 2024

@amyeroberts
same test still fails 👎

@gante
Copy link
Member

gante commented Feb 15, 2024

@jmamou Our apologies, this PR fixed it. Could you try rebasing again please? 🤗

@gante
Copy link
Member

gante commented Feb 15, 2024

@amyeroberts both CI failures seem unrelated to this PR, including check_repository_consistency 👀 do you have an idea of what might be causing it?

@amyeroberts
Copy link
Collaborator

@jmamou Apologies for all of the current issues you've been experiencing with unrelated failures on this PR.

The two current batches of failing tests should have been resolved with #29037, #29043

Could you try one (final 🤞) rebase to get this CI green 🟢 ?

@jmamou
Copy link
Contributor Author

jmamou commented Feb 16, 2024

@amyeroberts
tests passed on CI 👍

@amyeroberts amyeroberts merged commit 258da40 into huggingface:main Feb 16, 2024
21 checks passed
@amyeroberts
Copy link
Collaborator

@jmamou Thanks for this contribution and your patience with our misbehaving CI!

@HuggingFaceDocBuilderDev

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.

@jmamou jmamou deleted the fix_num_assistant_tokens branch February 18, 2024 12:37
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request Feb 19, 2024
* fix heuristic num_assistant_tokens_schedule

* Update src/transformers/generation/configuration_utils.py

Co-authored-by: Joao Gante <[email protected]>

* Update src/transformers/generation/candidate_generator.py

Co-authored-by: Joao Gante <[email protected]>

* Update utils.py

check that candidate_generator.assistant_model exists since some some speculations (like ngram and PLD) don't have assistant_model attribute

* Update src/transformers/generation/candidate_generator.py

Co-authored-by: Arthur <[email protected]>

* Update tests/generation/test_utils.py

Co-authored-by: amyeroberts <[email protected]>

* make fixup

* merge conflict

* fix docstring

* make fixup

---------

Co-authored-by: Joao Gante <[email protected]>
Co-authored-by: Arthur <[email protected]>
Co-authored-by: amyeroberts <[email protected]>
itazap pushed a commit that referenced this pull request May 14, 2024
* fix heuristic num_assistant_tokens_schedule

* Update src/transformers/generation/configuration_utils.py

Co-authored-by: Joao Gante <[email protected]>

* Update src/transformers/generation/candidate_generator.py

Co-authored-by: Joao Gante <[email protected]>

* Update utils.py

check that candidate_generator.assistant_model exists since some some speculations (like ngram and PLD) don't have assistant_model attribute

* Update src/transformers/generation/candidate_generator.py

Co-authored-by: Arthur <[email protected]>

* Update tests/generation/test_utils.py

Co-authored-by: amyeroberts <[email protected]>

* make fixup

* merge conflict

* fix docstring

* make fixup

---------

Co-authored-by: Joao Gante <[email protected]>
Co-authored-by: Arthur <[email protected]>
Co-authored-by: amyeroberts <[email protected]>
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

Successfully merging this pull request may close these issues.

5 participants