Inkling-Small 是 Thinking Machines Lab 推出的一款拥有 276B 参数的混合专家(MoE)模型,包含 256 个路由专家和 2 个共享专家,每层激活 top-6 路由。模型采用 BF16 精度,原生支持最大 1M token 上下文。模型支持多模态输入——文本、图像和音频,输出目前仅限文本。视觉编码器为自研的 hmlp(4 层),音频编码器为自研的 dmel 方案。本补丁实现在 Ascend NPU A3(16 NPU,每 NPU 64 GB HBM)上通过 vLLM-Ascend 进行推理服务部署,支持 MTP1 推测解码、FlashComm1 序列并行、专家并行(EP16)和 FULL_DECODE_ONLY graph 加速。
| 项目 | 说明 |
|---|---|
| 基础镜像 | quay.io/ascend/vllm-ascend:v0.23.0rc1-a3 |
| vLLM 路径 | /vllm-workspace/vllm |
| vllm-ascend 路径 | /vllm-workspace/vllm-ascend |
| 模型目录 | /models/Inkling-Small |
| vLLM 补丁文件 | 0001-vllm-inkling.patch |
| vllm-ascend 补丁文件 | 0002-vllm-ascend-inkling.patch |
在当前仓库根目录执行:
export PATCH_DIR=/path/to/this/patch
export VLLM_DIR=/vllm-workspace/vllm
export VLLM_ASCEND_DIR=/vllm-workspace/vllm-ascend
export MODEL_DIR=/models/Inkling-Small
# apply vLLM 补丁
cd "$VLLM_DIR"
git apply --check $PATCH_DIR/0001-vllm-inkling.patch
git apply $PATCH_DIR/0001-vllm-inkling.patch
# apply vLLM-Ascend 补丁
cd "$VLLM_ASCEND_DIR"
git apply --check $PATCH_DIR/0002-vllm-ascend-inkling.patch
git apply $PATCH_DIR/0002-vllm-ascend-inkling.patch说明:
source /usr/local/Ascend/ascend-toolkit/set_env.sh。0001-vllm-inkling.patch:Inkling 模型注册与加载;多模态 image/audio 前处理;reasoning/tool parser;MTP 推测解码框架适配。0002-vllm-ascend-inkling.patch:Inkling 专用模型实现(inkling.py);FlashComm1 序列并行 + FP32 reduction;shared-expert DP;MC2 跨 DP all-to-all dispatch/combine(EP16);FULL_DECODE_ONLY graph;fused_short_conv / fused_residual_norm / fused_graph_attention_prepare 等融合优化。推荐使用 DP2 + TP8 + EP16 + MTP1 + FULL_DECODE_ONLY graph + FlashComm1 + shared-expert DP 组合启动,MTP1 的 draft model 使用 enforce_eager=true(消除 draft FULL graph replay 非确定性):
export PYTHONHASHSEED=1
vllm serve $MODEL_DIR \
--served-model-name Inkling-Small \
--dtype bfloat16 \
--tensor-parallel-size 8 \
--data-parallel-size 2 \
--enable-expert-parallel \
--max-model-len 70000 \
--max-num-seqs 4 \
--max-num-batched-tokens 4608 \
--gpu-memory-utilization 0.95 \
--block-size 128 \
--enable-prefix-caching \
--enable-chunked-prefill \
--reasoning-parser inkling \
--seed 1 \
--compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY","cudagraph_capture_sizes":[8]}' \
--additional-config '{"enable_flashcomm1":true,"enable_shared_expert_dp":true}' \
--speculative-config '{"method":"mtp","num_speculative_tokens":1,"draft_tensor_parallel_size":8,"enforce_eager":true}' \
--host 0.0.0.0 \
--port 8000说明:
enable_flashcomm1:true)启用序列并行,attention/MLP reduction 在 FP32 精度下做 all-reduce,reduction 本地化仅在 FULL graph decode 路径生效。PYTHONHASHSEED=1 配合 --enable-prefix-caching 使用:DP2 下两个 DP engine 需要相同的 hash seed 才能使 prefix caching 的 block hash 一致,否则相同 prefix 在不同 DP rank 上生成不同 hash 无法命中。# 健康检查
curl -sf http://127.0.0.1:8000/health
# 模型列表
curl -sf http://127.0.0.1:8000/v1/models
# 简单推理
curl -sf http://127.0.0.1:8000/v1/completions \
-H 'Content-Type: application/json' \
-d '{"model":"Inkling-Small","prompt":"What is 2+3? Answer briefly.","max_tokens":32,"temperature":0,"seed":42}'curl -sf http://127.0.0.1:8000/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model":"Inkling-Small",
"messages":[{"role":"user","content":"Solve step by step: Find all positive integers n such that n^2 + 6n + 5 is a perfect square."}],
"max_tokens":65536,
"temperature":0,
"seed":1,
"reasoning_effort":"max"
}'响应中 message.reasoning 为思维链内容,message.content 为最终回复。
reasoning_effort 参数控制思维链强度,支持 low / high / max 等多档。reasoning_effort 时默认启用思维链。max_tokens=65536 配合长思维链使用,确保推理不被截断。模型支持图片和音频输入,通过 /v1/chat/completions 接口以 base64 编码发送。社区提供测试样本 test_image.png 和 test_audio_cn_16k.wav,可与 patch 一并获取。
图片输入:
curl -sf http://127.0.0.1:8000/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model":"Inkling-Small",
"messages":[{"role":"user","content":[
{"type":"image_url","image_url":{"url":"data:image/png;base64,$(base64 -w0 <test_image.png路径>)"}},
{"type":"text","text":"请描述这张图片的内容。"}
]}],
"max_tokens":256,
"temperature":0,
"seed":1
}'音频输入:
curl -sf http://127.0.0.1:8000/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model":"Inkling-Small",
"messages":[{"role":"user","content":[
{"type":"input_audio","input_audio":{"data":"$(base64 -w0 <test_audio_cn_16k.wav路径>)","format":"wav"}},
{"type":"text","text":"请听这段音频,告诉我音频里说了什么内容。"}
]}],
"max_tokens":256,
"temperature":0,
"seed":1
}'image_url.url 为 data:image/png;base64, 前缀 + base64 编码。input_audio 的 data 字段为纯 base64 编码(不含 data:audio/wav;base64, 前缀),format 字段指定音频格式。| 评测集 | 分数 | 官方参考 | 说明 |
|---|---|---|---|
| AIME2026 | 29/30 = 96.67% | 95.5% | 0 截断,唯一错题为模型答案错误(非截断) |