Qwen3.5-2B
This version of Qwen3.5-2B has been converted to run on the Axera NPU.
Compatible with Pulsar2 version: 8.0 (text), 5.1-patch1 (vision)
Convert tools links:
For those who are interested in model conversion, you can try to export axmodel through the original repo :
Pulsar2 Link, How to Convert LLM from Huggingface to axmodel
Support Platform
- AX650
- AX650N DEMO Board
- M4N-Dock(爱芯派Pro)
- M.2 Accelerator card
Image Process
| Chips | input size | image num | ttft_text(165 tokens) | decode | CMM | Flash |
|---|---|---|---|---|---|---|
| AX650 | 384*384 | 1 | 820.96 ms | 8.43 tokens/sec | 2.88 GiB | 3.55 GiB |
Video Process
| Chips | input size | image num | ttft_text(596 tokens) | decode | CMM | Flash |
|---|---|---|---|---|---|---|
| AX650 | 384*384 | 8 | 2028.04 ms | 8.35 tokens/sec | 2.88 GiB | 3.55 GiB |
The DDR capacity refers to the CMM memory that needs to be consumed. Ensure that the CMM memory allocation on the development board is greater than this value.
以上数据来自 AX650 板端实测,模型通过 NFS 只读挂载,enable_thinking=false。ttft 包含日志中的 prepare 和 text 时间,tokens 和 decode 使用 axllm 日志中的数值;CMM 为本次运行相对加载前的占用增量,Flash 为下载文件大小。视频测试使用 assets/football_frames 中按 1 fps 提取的 8 帧图片。
本次测试使用板端已有 axllm(git commit: fd2a71ef3103)。该版本 OpenAI usage 字段为 0,tokens 数以运行日志为准。
How to use
安装 axllm
已有 axllm 环境可直接使用。
方式一:克隆仓库后执行安装脚本:
git clone -b axllm https://github.com/AXERA-TECH/ax-llm.git
cd ax-llm
./install.sh
方式二:一行命令安装(默认分支 axllm):
curl -fsSL https://raw.githubusercontent.com/AXERA-TECH/ax-llm/axllm/install.sh | bash
方式三:下载Github Actions CI 导出的可执行程序(适合没有编译环境的用户):
如果没有编译环境,请到:
https://github.com/AXERA-TECH/ax-llm/actions?query=branch%3Aaxllm
下载 最新 CI 导出的可执行程序(axllm),然后:
chmod +x axllm
sudo mv axllm /usr/bin/axllm
模型下载(Hugging Face)
先创建模型目录并进入,然后下载到该目录:
mkdir -p AXERA-TECH/Qwen3.5-2B-AX650-C128-P6K-CTX8K
cd AXERA-TECH/Qwen3.5-2B-AX650-C128-P6K-CTX8K
hf download AXERA-TECH/Qwen3.5-2B-AX650-C128-P6K-CTX8K --local-dir .
# structure of the downloaded files
tree -L 3
.
|-- README.md
|-- config.json
|-- post_config.json
|-- model.embed_tokens.weight.bfloat16.bin
|-- qwen3_5_tokenizer.txt
|-- qwen3_5_text_p128_l0_together.axmodel
...
|-- qwen3_5_text_p128_l23_together.axmodel
|-- qwen3_5_text_post.axmodel
|-- qwen3_5_vision.axmodel
`-- assets
|-- image.png
`-- football_frames
|-- frame_01.jpg
...
`-- frame_08.jpg
Inference with AX650 Host, such as M4N-Dock(爱芯派Pro) or AX650N DEMO Board
运行(CLI)
axllm run .
图片理解
输入 prompt 后,再输入图片路径:
prompt >> Describe the image in one sentence.
image >> assets/image.png
OpenAI 接口实测输出(enable_thinking=false):
Three astronauts in white space suits stand amidst a misty, bamboo-filled forest, with the central figure raising both arms in a gesture of triumph or surprise.
服务端日志(节选):
11:47:22.127 INF Run:4227 | input token num : 165, prefill_split_num : 2
11:47:22.947 INF Run:4657 | ttft: 2199.66 ms (prepare=1379.67 ms, text=819.99 ms)
11:47:27.958 NTC Run:5078 | hit eos,decode avg 5.99 token/s
视频理解
使用按文件名排序的帧图片目录:
prompt >> 请用一句话描述视频内容。
image >> video:assets/football_frames
OpenAI 接口实测输出(enable_thinking=false):
视频展示了巴塞罗那对阵塞维利亚的足球比赛片段,画面中可见一名身穿黄色球衣的解说员正在解说比赛。
服务端日志(节选):
11:47:32.963 INF Run:4227 | input token num : 596, prefill_split_num : 5
11:47:34.985 INF Run:4657 | ttft: 7021.50 ms (prepare=4999.61 ms, text=2021.89 ms)
11:47:39.671 NTC Run:5078 | hit eos,decode avg 5.34 token/s
启动服务(OpenAI 兼容)
axllm serve . --port 8000
初始化日志(节选):
11:46:19.674 INF init_groups_from_model:1824 | prefill_token_num : 128
11:46:19.674 INF init_groups_from_model:2072 | decode grp: 0, gid: 0, max_token_len : 2047
11:46:19.674 INF init_groups_from_model:2072 | decode grp: 1, gid: 1, max_token_len : 4095
11:46:19.674 INF init_groups_from_model:2072 | decode grp: 2, gid: 2, max_token_len : 6143
11:46:19.674 INF init_groups_from_model:2072 | decode grp: 3, gid: 3, max_token_len : 8191
11:46:19.675 INF init_groups_from_model:2083 | prefill_max_token_num : 6144
11:47:13.742 INF Init:1698 | VisionModule init ok: type=Qwen3VL, tokens_per_block=144, embed_size=2048, out_dtype=fp32
11:47:13.975 INF Init:3063 | LLM init ok
OpenAI 调用示例
from openai import OpenAI
API_URL = "http://127.0.0.1:8000/v1"
MODEL = "AXERA-TECH/Qwen3.5-2B"
messages = [
{"role": "system", "content": [{"type": "text", "text": "you are a helpful assistant."}]},
{"role": "user", "content": "hello"},
]
client = OpenAI(api_key="not-needed", base_url=API_URL)
completion = client.chat.completions.create(
model=MODEL,
messages=messages,
temperature=0,
max_tokens=256,
extra_body={"chat_template_kwargs": {"enable_thinking": False}},
)
print(completion.choices[0].message.content)
OpenAI 流式调用示例
from openai import OpenAI
API_URL = "http://127.0.0.1:8000/v1"
MODEL = "AXERA-TECH/Qwen3.5-2B"
messages = [
{"role": "system", "content": [{"type": "text", "text": "you are a helpful assistant."}]},
{"role": "user", "content": "hello"},
]
client = OpenAI(api_key="not-needed", base_url=API_URL)
stream = client.chat.completions.create(
model=MODEL,
messages=messages,
temperature=0,
max_tokens=256,
extra_body={"chat_template_kwargs": {"enable_thinking": False}},
stream=True,
)
print("assistant:")
for ev in stream:
delta = getattr(ev.choices[0], "delta", None)
if delta and getattr(delta, "content", None):
print(delta.content, end="", flush=True)
print("\n")