Skip to content

Commit d5a5164

Browse files
authored
Support qwen 0.5 b (#13972)
Summary: Add entry point to run 0.5B model. Run with ``` buck run mode/dev-nosan //executorch/extension/llm/export:export_llm -- --config executorch/examples/models/llama/config/llama_bf16.yaml +base.model_class="qwen2_5_0_5b" +base.params="./executorch/examples/models/qwen2_5/config/0_5b_config.json" ``` Differential Revision: D81724880
1 parent 686bb71 commit d5a5164

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

examples/models/llama/export_llama_lib.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@
9393
"llama3_1",
9494
"llama3_2",
9595
"static_llama",
96-
"qwen2_5",
96+
"qwen2_5_0_5b",
97+
"qwen2_5_1_5b",
9798
"qwen3_0_6b",
9899
"qwen3_1_7b",
99100
"qwen3_4b",
@@ -102,7 +103,8 @@
102103
]
103104
TORCHTUNE_DEFINED_MODELS = ["llama3_2_vision"]
104105
HUGGING_FACE_REPO_IDS = {
105-
"qwen2_5": "Qwen/Qwen2.5-1.5B",
106+
"qwen2_5_0_5b": "Qwen/Qwen2.5-0.5B",
107+
"qwen2_5_1_5b": "Qwen/Qwen2.5-1.5B",
106108
"phi_4_mini": "microsoft/Phi-4-mini-instruct",
107109
"smollm2": "HuggingFaceTB/SmolLM-135M",
108110
"qwen3_0_6b": "Qwen/Qwen3-0.6B",
@@ -595,7 +597,7 @@ def export_llama(
595597
model_name = llm_config.base.model_class.value
596598
if not llm_config.base.checkpoint and model_name in HUGGING_FACE_REPO_IDS:
597599
repo_id = HUGGING_FACE_REPO_IDS[model_name]
598-
if model_name == "qwen2_5":
600+
if model_name.startswith("qwen2_5"):
599601
from executorch.examples.models.qwen2_5 import convert_weights
600602
elif model_name.startswith("qwen3"):
601603
from executorch.examples.models.qwen3 import convert_weights

examples/models/qwen2_5/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ Qwen 2.5 is the latest iteration of the Qwen series of large language models (LL
66
Qwen 2.5 uses the same example code as Llama, while the checkpoint, model params, and tokenizer are different. Please see the [Llama README page](../llama/README.md) for details.
77

88
All commands for exporting and running Llama on various backends should also be applicable to Qwen 2.5, by swapping the following args:
9+
910
```
10-
base.model_class="qwen2_5"
11-
base.params="examples/models/qwen2_5/config/1_5b_config.json"
11+
base.model_class=[qwen2_5_0_5b, qwen2_5_1_5b]
12+
base.params=[examples/models/qwen2_5/config/0_5b_config.json, examples/models/qwen2_5/config/1_5b_config.json]
1213
base.checkpoint=<path-to-meta-checkpoint>
1314
```
1415

@@ -34,7 +35,7 @@ QWEN_CHECKPOINT=path/to/checkpoint.pth
3435
3536
python -m extension.llm.export.export_llm \
3637
--config examples/models/qwen2_5/config/qwen2_5_xnnpack_q8da4w.yaml \
37-
+base.model_class="qwen2_5" \
38+
+base.model_class="qwen2_5_1_5b" \
3839
+base.checkpoint="${QWEN_CHECKPOINT:?}" \
3940
+base.params="examples/models/qwen2_5/config/1_5b_config.json" \
4041
+export.output_name="qwen2_5-1_5b.pte" \

extension/llm/export/config/llm_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class ModelType(str, Enum):
3737
llama3_2 = "llama3_2"
3838
llama3_2_vision = "llama3_2_vision"
3939
static_llama = "static_llama"
40-
qwen2_5 = "qwen2_5"
40+
qwen2_5_0_5b = "qwen2_5_0_5b"
41+
qwen2_5_1_5b = "qwen2_5_1_5b"
4142
qwen3_0_6b = "qwen3_0_6b"
4243
qwen3_1_7b = "qwen3_1_7b"
4344
qwen3_4b = "qwen3_4b"

0 commit comments

Comments
 (0)