-
Notifications
You must be signed in to change notification settings - Fork 117
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
refactor CPU llama inference code #728
Conversation
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. |
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.
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.
LGTM thanks @faaany
if is_transformers_version("<", _TRANSFORMERS_MIN_VERSION) or is_transformers_version( | ||
">", _TRANSFORMERS_MAX_VERSION | ||
): | ||
raise ImportError( | ||
f"Only transformers versions {_TRANSFORMERS_MIN_VERSION} ~ {_TRANSFORMERS_MAX_VERSION} are verified." |
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.
We should keep this as only the transformers versions in between are supported, but this should be moved what do you think about :
def _patch_model(model): |
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.
yes, totally agree! code updated.
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.
thanks for the detailed review! the rebase and merge conflict did bring some headache
Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com>
Hi @echarlaix , I manually-checked the changes in #725 and fixed the bugs introduced through rebasing. Now all tests passed, I think we are good to go. |
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.
Great work, thanks a lot @faaany !
What does this PR do?
This PR refactors the current CPU llama inference code to make code clean. The major changes are as follows:
_IPEXLlamaAttention
and move the attention-related OPs and attention forward code to_IPEXLlamaAttention
_IPEXLlamaMLP
and move the MLP-related OPs and forward code to_IPEXLlamaMLP
_patch_llama_model
_IPEXLlamaDecoderLayerRef
to_IPEXLlamaDecoderLayer
_IPEXLlamaAttention
intogemm
,rope
andsdpa
Please note that this PR is based on the unmerged PR #725 by Jiqing as can be seen in the commit history.