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

Commit

Permalink
fixed qwen convert issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhenzhong1 committed Mar 6, 2024
1 parent 3d9a9bd commit b817c56
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions neural_speed/convert/convert_qwen.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ def main(args_in: Optional[List[str]] = None) -> None:
fout.write(struct.pack("i", hparams["num_attention_heads"]))
fout.write(struct.pack("i", 0)) # multi-query attention
fout.write(struct.pack("i", hparams["num_hidden_layers"]))
fout.write(struct.pack("i", hparams["kv_channels"] if "kv_channels" in hparams
else int(hparams["hidden_size"]/hparams["num_attention_heads"])))
fout.write(
struct.pack(
"i", hparams["kv_channels"] if "kv_channels" in hparams else int(hparams["hidden_size"] /
hparams["num_attention_heads"])))
fout.write(struct.pack("i", ftype))
fout.write(struct.pack("i", hparams["seq_length"] if "seq_length" in hparams
else hparams["max_position_embeddings"]))
fout.write(
struct.pack("i", hparams["seq_length"] if "seq_length" in hparams else hparams["max_position_embeddings"]))
fout.write(struct.pack("f", 0.0))
fout.write(struct.pack("f", 0.0))
fout.write(struct.pack("i", 0))
Expand All @@ -120,13 +122,15 @@ def main(args_in: Optional[List[str]] = None) -> None:
fout.write(struct.pack("f", 10000.0)) # freq_base
fout.write(struct.pack("f", 1.0)) # rope_factor

fout.write(struct.pack("f", 0.0)) # config.json "rope_scaling.factor", not enabled
fout.write(struct.pack("i", 0)) # rope_scaling.original_max_position_embeddings
fout.write(struct.pack("i", 0)) # params["rope_scaling"]["type"] =="yarn" else 0))
fout.write(struct.pack("i", hparams["bos_token_id"] if hparams["bos_token_id"]
else tokenizer.special_tokens['<|endoftext|>']))
fout.write(struct.pack("i", hparams["eos_token_id"] if hparams["eos_token_id"]
else tokenizer.special_tokens['<|endoftext|>']))
fout.write(struct.pack("f", 0.0)) # config.json "rope_scaling.factor", not enabled
fout.write(struct.pack("i", 0)) # rope_scaling.original_max_position_embeddings
fout.write(struct.pack("i", 0)) # params["rope_scaling"]["type"] =="yarn" else 0))
fout.write(
struct.pack(
"i", hparams["bos_token_id"] if "bos_token_id" in hparams else tokenizer.special_tokens['<|endoftext|>']))
fout.write(
struct.pack(
"i", hparams["eos_token_id"] if "eos_token_id" in hparams else tokenizer.special_tokens['<|endoftext|>']))
fout.write(struct.pack("i", tokenizer.pad_token_id if tokenizer.pad_token_id is not None else -1))
fout.write(struct.pack("i", tokenizer.sep_token_id if tokenizer.sep_token_id is not None else -1))

Expand Down

0 comments on commit b817c56

Please sign in to comment.