Skip to content

Commit

Permalink
[Qwen2_5] support Qwen2.5-3B
Browse files Browse the repository at this point in the history
  • Loading branch information
chuxiaoyi2023 committed Nov 12, 2024
1 parent 1e05d5a commit f57aebd
Show file tree
Hide file tree
Showing 5 changed files with 1,573 additions and 13 deletions.
9 changes: 8 additions & 1 deletion models/Qwen2_5/compile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ python3 -m dfss --url=open@sophgo.com:/ext_model_information/LLM/LLM-TPU/qwen2.5

### 全流程编译脚本
以上步骤可以通过运行compile文件夹下的run_compile.sh完成,具体命令是:

迁移Qwen2.5-7B
```shell
./run_compile.sh --model_name qwen2.5-7b --seq_length 512 --model_path your_model_path --tpu_mlir_path your_tpu_mlir_path
```

迁移Qwen2.5-3B,且输入+输出最大长度为4096
``` shell
./run_compile.sh --model_name qwen2.5-7b --seq_length 512 --model_path your model path --tpu_mlir_path your tpu_mlir path
./run_compile.sh --model_name qwen2.5-3b --seq_length 4096
```
如果没有填写model_path,脚本会从modelscope下载模型;
如果没有填写tpu_mlir_path,脚本会通过dfss下载对应的tpu_mlir压缩包并解压
Expand Down
16 changes: 10 additions & 6 deletions models/Qwen2_5/compile/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,24 @@ if [[ -z "$seq_length" ]]; then
exit 1
fi

if [ "$name" = "qwen2.5-7b" ]; then
num_layers=28
hidden_size=3584
echo "Compile Qwen2.5-7B"
elif [ "$name" = "qwen2.5-14b" ]; then
if [ "$name" = "qwen2.5-14b" ]; then
num_layers=48
hidden_size=5120
echo "Compile Qwen2.5-14B"
elif [ "$name" = "qwen2.5-7b" ]; then
num_layers=28
hidden_size=3584
echo "Compile Qwen2.5-7B"
elif [ "$name" = "qwen2.5-3b" ]; then
num_layers=36
hidden_size=2048
echo "Compile Qwen2.5-3B"
elif [ "$name" = "qwen2.5-1.5b" ]; then
num_layers=28
hidden_size=1536
echo "Compile Qwen2.5-1.5B"
else
>&2 echo -e "Error: Invalid name $name, the input name must be \033[31mqwen2.5-7b|qwen2.5-1.5b|qwen2.5-14b\033[0m"
>&2 echo -e "Error: Invalid name $name, the input name must be \033[31mqwen2.5-14b|qwen2.5-7b|qwen2.5-3b|qwen2.5-1.5b\033[0m"
exit 1
fi

Expand Down
27 changes: 27 additions & 0 deletions models/Qwen2_5/compile/files/Qwen2.5-3B-Instruct/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"architectures": [
"Qwen2ForCausalLM"
],
"attention_dropout": 0.0,
"bos_token_id": 151643,
"eos_token_id": 151645,
"hidden_act": "silu",
"hidden_size": 2048,
"initializer_range": 0.02,
"intermediate_size": 11008,
"max_position_embeddings": 32768,
"max_window_layers": 70,
"model_type": "qwen2",
"num_attention_heads": 16,
"num_hidden_layers": 36,
"num_key_value_heads": 2,
"rms_norm_eps": 1e-06,
"rope_theta": 1000000.0,
"sliding_window": 32768,
"tie_word_embeddings": true,
"torch_dtype": "bfloat16",
"transformers_version": "4.43.1",
"use_cache": true,
"use_sliding_window": false,
"vocab_size": 151936
}
Loading

0 comments on commit f57aebd

Please sign in to comment.