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 heuristic scheduling for UAG #34805

Merged
merged 7 commits into from
Nov 21, 2024

Conversation

jmamou
Copy link
Contributor

@jmamou jmamou commented Nov 19, 2024

What does this PR do?

Fix #34803

The number of matching tokens according to the draft vocabulary is missing in candidate_generator.py. To fix the issue, we propose to modify update_candidate_strategy by comparing num_matches (the number of matched tokens according to the target vocabulary) with len(scores[0]) - 1 that represents the number of tokens generated by the draft model according to the target vocabulary.

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 @ArthurZucker @zucchini-nlp

Copy link
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

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

@jmamou thanks for fixing! Quick clarification, why is there a -1, shouldn't scores reflect the length of generated tokens?

@jmamou
Copy link
Contributor Author

jmamou commented Nov 20, 2024

@jmamou thanks for fixing! Quick clarification, why is there a -1, shouldn't scores reflect the length of generated tokens?

@zucchini-nlp

scores contains also the additional token produced by the target model independently of the draft generation process as explained here

Copy link
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

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

Ah, I see, thanks for explaining. Can be merged after core maintainer's review :)

src/transformers/generation/candidate_generator.py Outdated Show resolved Hide resolved
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.

Cool! Thanks for fixing!

@ArthurZucker ArthurZucker merged commit 1887159 into huggingface:main Nov 21, 2024
24 checks passed
@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.

BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
* fix heuristic schedule

* fix style

* fix format
BernardZach pushed a commit to innovationcore/transformers that referenced this pull request Dec 6, 2024
* fix heuristic schedule

* fix style

* fix format
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.

Heuristic scheduling for UAG
4 participants