-
Notifications
You must be signed in to change notification settings - Fork 96
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
Integrate chunked prefill into t3k Llama3-70B #15921
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cglagovichTT
force-pushed
the
cglagovich/model_chunked_prefill
branch
from
December 12, 2024 19:09
d0f1c15
to
813e5c2
Compare
cglagovichTT
requested review from
uaydonat,
johanna-rock-tt,
djordje-tt,
kpaigwar and
a team
as code owners
December 12, 2024 19:54
skhorasganiTT
approved these changes
Dec 12, 2024
cglagovichTT
changed the title
Cglagovich/model chunked prefill
Integrate chunked prefill into t3k Llama3-70B
Dec 12, 2024
tt-rkim
approved these changes
Dec 12, 2024
…for long sequences
cglagovichTT
requested review from
ayerofieiev-tt,
dmakoviichuk-tt,
cfjchu and
TT-BrianLiu
as code owners
December 13, 2024 20:43
cglagovichTT
force-pushed
the
cglagovich/model_chunked_prefill
branch
from
December 16, 2024 14:18
4b6878a
to
f66a5f8
Compare
johanna-rock-tt
approved these changes
Dec 16, 2024
djordje-tt
approved these changes
Dec 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ticket
#15873
Problem description
Llama3-7-B on T3K supports up to 128k context length with batch=1. However, it is limited such that the maximum prompt length is 32k. That means that the full 128k context can be used by prefill len + decode len only if prefill len <= 32k.
This constraint is caused by the fact that prefill activations for long sequences become large, leading to OOM on device DRAM. For example, the activations are 128k * 8k * 2B = 2 GB for input len 128k.
What's changed
The solution to this problem is to implement chunked prefill. Given some prompt_len and a chunk_size (<= 32k), the prompt is split into prompt_len / chunk_size chunks and iteratively prefilled. Chunked prefill will reduce the size of the activations which should solve the OOM error.
This PR uses the new
chunked_scaled_dot_product_attention
kernel in Llama to enable chunked prefill. It modifies the attention and model tests, and creates a new test in the T3K demo pipeline which tests chunked prefill as used byllama_generation
, which is the entrypoint that vLLM will use.Note that this functionality was added to the "old" Llama codebase since it was an urgent request. I expect we will be adding chunked prefill to the llama family folder sometime soon.
Checklist