rename BIGDL_OPTIMIZE_LM_HEAD to IPEX_LLM_LAST_LM_HEAD and add qwen2 (#11418)

This commit is contained in:
Xin Qiu 2024-06-24 18:42:37 +08:00 committed by GitHub
parent 75f836f288
commit 9e4ee61737
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -328,8 +328,8 @@ def _replace_with_low_bit_linear(model, qtype, modules_to_not_convert=None,
optimize_lm_head = False
if is_lm_head(name, model_config, out_features):
model_type = getattr(model_config, "model_type", None)
if model_type in ["gptj", "llama"] and os.environ.get("BIGDL_OPTIMIZE_LM_HEAD",
None) == "1":
if model_type in ["gptj", "llama", "qwen2"] and \
os.environ.get("IPEX_LLM_LAST_LM_HEAD", None) == "1":
optimize_lm_head = True
with init_empty_weights():
new_linear = None