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

Decoder: fix performance regression #755

Merged
merged 5 commits into from
Jan 7, 2025
Merged

Decoder: fix performance regression #755

merged 5 commits into from
Jan 7, 2025

Conversation

dacorvo
Copy link
Collaborator

@dacorvo dacorvo commented Jan 6, 2025

What does this PR do?

With transformers >= 4.46.0 the top-k, top-p and temperature logits processors have been included in the common logits processors lists, where they were previously included in a logits warpers list used only when sampling.

This defeated the optimization previously introduced in optimum-neuron to replace the logits warpers by a single fused warper. This led to a huge increase of the sampling latency.

This pull-request removes the superfluous transformers sampling warpers and restores the optimized processing.

@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.

The logits warpers used for sampling are now included in the list of
processors obtained when calling GenerationMixin._get_logits_processor.
We need to remove them explicitly because we use instead a fused logits
warper (which is 10x faster).
@dacorvo dacorvo force-pushed the fix_perf_regression branch from cd6ebb6 to d4084a3 Compare January 6, 2025 18:22
@dacorvo dacorvo marked this pull request as draft January 7, 2025 08:52
@dacorvo dacorvo marked this pull request as ready for review January 7, 2025 12:45
@dacorvo dacorvo requested a review from tengomucho January 7, 2025 12:47
Copy link
Collaborator

@JingyaHuang JingyaHuang left a comment

Choose a reason for hiding this comment

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

LGTM!

@dacorvo dacorvo merged commit 6639b1d into main Jan 7, 2025
9 of 10 checks passed
@dacorvo dacorvo deleted the fix_perf_regression branch January 7, 2025 13:06
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.

3 participants