Ascend-SACT/Ling-2.6-flash
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Ling-2.6-flash SGlang补丁运行手册

1. 简介

本目录提供的是本次 patch 交付物:

  • Ling-2.6-flash-sglang-v4.0.patch
  • Ling-2.6-flash-sglang-v0.5.13.patch

其中:

  • Ling-2.6-flash-sglang-v4.0.patch 本补丁面向灵镜昇腾统一容器镜像 V4.0 + SGLang 0.5.11,将 Ling-2.6-flash适配到 Ascend,覆盖三类修复:解码正确性、基线启动适配、MTP/NextN 投机解码使能。

  • Ling-2.6-flash-sglang-v0.5.13.patch 本补丁面向 SGLang v0.5.13.post1-cann9.0.0 镜像,将 Ling-2.6-flash适配到 Ascend,修复 MLA 解码 w_vc非连续导致 npu.batch_matmul_transpose 静默出错、长链解码退化的问题。

2. 应用补丁

2.1 补丁版本一

基础镜像:

  • A3:docker pull swr.cn-north-4.myhuaweicloud.com/ascend-sact/ascend-a3-ubuntu:v4.0
  • A2:docker pull swr.cn-north-4.myhuaweicloud.com/ascend-sact/ascend-a2-ubuntu:v4.0

准备变量

PATCH_DIR=/path/to/patches
MODEL_ROOT=/models
#下载权重参考:https://www.modelscope.cn/models/inclusionAI/Ling-2.6-flash

应用补丁:

conda activate ascend-infer
cd /opt/mamba/envs/ascend-infer/lib/python3.13/site-packages
git apply --check "$PATCH_DIR"/Ling-2.6-flash-sglang-v4.0.patch
git apply  "$PATCH_DIR"/Ling-2.6-flash-sglang-v4.0.patch

2.2 补丁版本二

基础镜像

  • A3: docker pull quay.io/ascend/sglang:v0.5.13.post1-cann9.0.0-a3
  • A2: docker pull quay.io/ascend/sglang:v0.5.13.post1-cann9.0.0-910b

准备变量

PATCH_DIR=/path/to/patches
MODEL_ROOT=/models
#下载权重参考:https://www.modelscope.cn/models/inclusionAI/Ling-2.6-flash

应用补丁:

cd /sgl-workspace/sglang
git apply --check "$PATCH_DIR"/Ling-2.6-flash-sglang-v0.5.13.patch
git apply "$PATCH_DIR"/Ling-2.6-flash-sglang-v0.5.13.patch

4. 启动服务

基线模式

cd /workspace
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3
export HCCL_OP_EXPANSION_MODE=AIV
exec python3 -m sglang.launch_server \
  --model-path "$MODEL_ROOT"/Ling-2.6-flash \
  --served-model-name Ling-2.6-flash \
  --tp-size 4 \
  --model-impl sglang --trust-remote-code \
  --disable-radix-cache \
  --device npu --attention-backend ascend --sampling-backend ascend \
  --tool-call-parser qwen \
  --mem-fraction-static 0.9 \
  --context-length 32768 \
  --max-running-requests 8 \
  --port 8000

MTP/NextN 模式

cd /workspace
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3
export HCCL_OP_EXPANSION_MODE=AIV
exec python -m sglang.launch_server \
  --model-path "$MODEL_ROOT"/Ling-2.6-flash \
  --served-model-name Ling-2.6-flash \
  --tp-size 4 \
  --model-impl sglang --trust-remote-code \
  --device npu --attention-backend ascend --sampling-backend ascend \
  --disable-radix-cache \
  --tool-call-parser qwen \
  --mem-fraction-static 0.85 \
  --context-length 32768 \
  --max-running-requests 8 \
  --speculative-algorithm NEXTN \
  --speculative-num-steps 1 \
  --speculative-eagle-topk 1 \
  --speculative-num-draft-tokens 2 \
  --port 8000

备注:针对补丁版本二中的镜像,启动服务时需要额外添加 export PATH="/usr/local/python3.11.15/bin:$PATH" 或者用 /usr/local/python3.11.15/bin/python3 -m sglang.launch_server来启动。

5. 验证

5.1 服务就绪检查

curl -s http://127.0.0.1:8000/v1/models -o /dev/null -w "HTTP %{http_code}\n"   # 期望 200

5.2 文本生成验证

curl -s http://127.0.0.1:8000/v1/chat/completions -H 'Content-Type: application/json' \
  -d '{"model":"Ling-2.6-flash","messages":[{"role":"user","content":"What is the capital of France?"}],"max_tokens":32,"temperature":0}'

期望:HTTP 200,内容非空且连贯(返回 "Paris")。

# 40 位周期-10 复制:应原样复现 3 0 7 4 1 8 5 2 9 6 ×4,不得退化为循环/乱码
curl -s http://127.0.0.1:8000/v1/chat/completions -H 'Content-Type: application/json' \
  -d '{"model":"Ling-2.6-flash","messages":[{"role":"user","content":"Repeat the following sequence of digits exactly, separated by single spaces, and output nothing else:\n3 0 7 4 1 8 5 2 9 6 3 0 7 4 1 8 5 2 9 6 3 0 7 4 1 8 5 2 9 6 3 0 7 4 1 8 5 2 9 6"}],"temperature":0,"max_tokens":200}'

5.3 工具调用验证

curl -s http://127.0.0.1:8000/v1/chat/completions -H 'Content-Type: application/json' \
  -d '{"model":"Ling-2.6-flash","messages":[{"role":"user","content":"What is the weather in Beijing?"}],"tools":[{"type":"function","function":{"name":"get_weather","description":"Get weather","parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}}],"temperature":0}'

期望:返回结构化 tool_calls,JSON 参数合法,finish_reason=tool_calls;无工具请求不误触发。

6. 注意事项

  • 环境前提 使用swr.cn-north-4.myhuaweicloud.com/ascend-sact/ascend-a2-ubuntu:v4.0镜像时需要先通过conda activate ascend-infer进入sglang环境下。
  • 长上下文:实测可用至 128K(needle-in-haystack 40K/80K/120K/128K 精确检索);线上默认 32768。提至 131072 时 KV 池占满 HBM(~61GB/device),需在并发与上下文长度间权衡。
  • 工具调用结构化输出需启动参数 --tool-call-parser qwen。