-
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
LLM: unify memory optimization env variables. #11549
LLM: unify memory optimization env variables. #11549
Conversation
else: | ||
optimize_lm_head = False |
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.
no need this? default to be false in Line 327?
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.
fixed.
if os.environ.get("IPEX_LLM_LAST_LM_HEAD", None) is not None: | ||
optimize_lm_head = os.environ.get("IPEX_LLM_LAST_LM_HEAD", None) == "1" | ||
elif os.environ.get("IPEX_LLM_LOW_MEM", None) is not None: | ||
optimize_lm_head = os.environ.get("IPEX_LLM_LOW_MEM", None) == "1" |
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 disable optimize_lm_head
when using speculative or lookahead.
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 already have conditions to avoid impacting speculative . But magic value 10 maybe not a good value. in
ipex-llm/python/llm/src/ipex_llm/transformers/low_bit_linear.py
Lines 343 to 346 in 51f2eff
if shape[1] > 10: | |
shape[1] = 1 | |
x = x[:, -1, :].view(shape) | |
return x |
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
* LLM: unify memory optimization env variables. * fix comments.
Description
This PR is to unify memory optimization env variables to
IPEX_LLM_LOW_MEM
for users to easily enable memory optimizations. We also keepIPEX_LLM_LAST_LM_HEAD
andIPEX_LLM_SPLIT_QKV
for compatibility and disabling the specific optimization for some situations.