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

Optimize HF text generation #4814

Merged
merged 1 commit into from
Dec 5, 2023
Merged

Optimize HF text generation #4814

merged 1 commit into from
Dec 5, 2023

Conversation

oobabooga
Copy link
Owner

@oobabooga oobabooga commented Dec 5, 2023

First change: Decode only the new tokens as they are generated during streaming instead of the entire sequence. This makes a difference when the context is large (like 40,000 tokens).

Here is a test with ExLlama_HF and a 13b model. The prompt is cached to make the difference more pronounced.

Before:

Output generated in 10.28 seconds (48.56 tokens/s, 499 tokens, context 3550, seed 1197861167)
Output generated in 10.27 seconds (48.59 tokens/s, 499 tokens, context 3550, seed 1463481238)
Output generated in 10.30 seconds (48.43 tokens/s, 499 tokens, context 3550, seed 1587775594)

After:

Output generated in 9.69 seconds (51.50 tokens/s, 499 tokens, context 3550, seed 909082919)
Output generated in 9.71 seconds (51.41 tokens/s, 499 tokens, context 3550, seed 221584078)
Output generated in 9.72 seconds (51.36 tokens/s, 499 tokens, context 3550, seed 105310110)

Second change: Restrict the UI streaming updates to 5 per second when --listen or --share are provided. I find that this makes the UI a lot more responsive over a network.

@oobabooga oobabooga merged commit 9edb193 into dev Dec 5, 2023
@oobabooga oobabooga deleted the optimize branch December 5, 2023 03:16
oobabooga added a commit that referenced this pull request Dec 6, 2023
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.

1 participant