-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[NPU] Add Optimized Support for Llama3.2-1B/3B on NPU #12339
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d34ce57
Add initial support for llama3.2-1b/3b
sgwhat 631e482
revert mp_base unexpected changes
sgwhat 7137df0
move llama3.2 support into current llama_mp impl
sgwhat a95c128
fix code style
sgwhat c978885
update
sgwhat cdf5467
add llama3.2 document
sgwhat 502957e
update doc style
sgwhat 0794aee
simplify position_ids logics
sgwhat b2eca18
check transformers version instead and fix code style
sgwhat 426e641
fix code style only
sgwhat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,7 +173,8 @@ def convert_llama( | |
intra_pp=None, | ||
transpose_value_cache=True, | ||
): | ||
from ipex_llm.transformers.npu_models.llama_mp import gen_llama_fused_model_forward | ||
from ipex_llm.transformers.npu_models.llama_mp import gen_llama_fused_model_forward,\ | ||
gen_llama_32_fused_model_forward | ||
from ipex_llm.transformers.npu_models.llama_mp import DecodeRunner, PrefillRunner | ||
from transformers.models.llama.modeling_llama import LlamaModel | ||
|
||
|
@@ -193,9 +194,15 @@ def convert_llama( | |
max_prompt_len=max_prompt_len, | ||
transpose_value_cache=transpose_value_cache, | ||
) | ||
llama_model_forward = gen_llama_fused_model_forward( | ||
prefill_runner=prefill_runner, decode_runner=decode_runner | ||
) | ||
if model.config.num_hidden_layers == 28 or model.config.num_hidden_layers == 16: | ||
# llama-3.2-3B & llama-3.2-1B | ||
llama_model_forward = gen_llama_32_fused_model_forward( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel we could also add transformers version check here. |
||
prefill_runner=prefill_runner, decode_runner=decode_runner | ||
) | ||
else: | ||
llama_model_forward = gen_llama_fused_model_forward( | ||
prefill_runner=prefill_runner, decode_runner=decode_runner | ||
) | ||
convert_forward(model, LlamaModel, llama_model_forward) | ||
from transformers.models.llama.modeling_llama import LlamaForCausalLM | ||
from ipex_llm.transformers.npu_models.llama_mp import llama2_casullm_forward | ||
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could merge to one line?