Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit d4e5289

Browse files
fix qwen convert error (#288)
* fix qwen convert error Signed-off-by: intellinjun <[email protected]> * fix chatglm2 test issue Signed-off-by: intellinjun <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: intellinjun <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent c57d25f commit d4e5289

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

neural_speed/convert/convert_quantized_qwen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def main(args_in: Optional[List[str]] = None) -> None:
6666
f.write(struct.pack("i", hparams["intermediate_size"])) # dummy data
6767
f.write(struct.pack("i", hparams["num_attention_heads"]))
6868
f.write(struct.pack("i", hparams["num_key_value_heads"] if "num_key_value_heads" in hparams
69-
else ["num_attention_heads"])) # multi-query attention
69+
else hparams["num_attention_heads"])) # multi-query attention
7070
f.write(struct.pack("i", hparams["num_hidden_layers"]))
7171
f.write(
7272
struct.pack(

neural_speed/convert/convert_qwen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def main(args_in: Optional[List[str]] = None) -> None:
104104
fout.write(struct.pack("i", hparams["intermediate_size"])) # dummy data
105105
fout.write(struct.pack("i", hparams["num_attention_heads"]))
106106
fout.write(struct.pack("i", hparams["num_key_value_heads"] if "num_key_value_heads" in hparams
107-
else ["num_attention_heads"])) # multi-query attention
107+
else hparams["num_attention_heads"])) # multi-query attention
108108
fout.write(struct.pack("i", hparams["num_hidden_layers"]))
109109
fout.write(
110110
struct.pack(

scripts/huggingface.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,12 @@ def _create_model(
592592
from neural_speed import Model
593593
self._model = Model()
594594
if init_from_bin != "default_none":
595-
self._model.init_from_bin(model_type= self.config.model_type,model_path=init_from_bin, max_request_num=batch_size)
595+
if self.config.model_type == "chatglm" and "chatglm2" in self.config._name_or_path:
596+
model_type = "chatglm2"
597+
else:
598+
model_type = self.config.model_type
599+
600+
self._model.init_from_bin(model_type=model_type,model_path=init_from_bin, max_request_num=batch_size)
596601
else:
597602
self._model.init(pretrained, weight_dtype=weight_dtype, compute_dtype=compute_dtype,
598603
alg=alg,

0 commit comments

Comments
 (0)