Skip to content

Commit

Permalink
fix unexpected keyword argument 'device' (intel#9982)
Browse files Browse the repository at this point in the history
* add device for chatglm3 only

* add comment for this change

* fix style

* fix style

* fix style again..

* finally fixed style
  • Loading branch information
Chen, Zhentao authored Jan 24, 2024
1 parent 6134098 commit 7ef898f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion python/llm/src/bigdl/llm/transformers/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,15 @@ def load_low_bit(cls,

if bigdl_lcmu_enabled:
with ContextManagers(init_contexts):
kwargs["device"] = "meta"
if config.architectures is not None and config.architectures[0] in \
["ChatGLMModel", "ChatGLMForConditionalGeneration"]:

"""
ChatGLMModel uses skip_init by default, which will force modules placed on cpu
if the device is not specified. This will further cause replaced linear
allocating memory on cpu.
"""
kwargs["device"] = "meta"
model = model_class(config, *model_args, **kwargs)
else:
model = model_class(config, *model_args, **kwargs)
Expand Down

0 comments on commit 7ef898f

Please sign in to comment.