上级索引:sglang/README.md。
本页面向:已在昇腾机器上装好驱动与 Docker 的用户,用 SGLang 官方容器镜像 跑通 DeepSeek-V3(PD 分离模式,2×A3),尽量减少本地 Python 环境折腾。
技术细节与参数说明以 SGLang 文档 为准。
按下面顺序执行后:在 2 台 Atlas 800I A3(64G×8) 上,用 SGLang 官方镜像 拉起在线推理服务(PD 分离模式:Prefill + Decode),并用 curl 验证。
本页不解决:宿主机未装昇腾驱动、无对应机型、无 Docker——请先完成 昇腾环境准备 与 SGLang 安装说明.
在宿主机执行(有正常输出即可进入下一步):
npu-smi info
docker --version/root/.cache/。按机型二选一:
| 机型 | 镜像 |
|---|---|
| Atlas 800I A3 | docker.io/lmsysorg/sglang:main-cann8.5.0-a3 |
| Atlas 800I A2 | docker.io/lmsysorg/sglang:main-cann8.5.0-910b |
在宿主机执行(A3 示例):
export IMAGE=docker.io/lmsysorg/sglang:main-cann8.5.0-a3
export NAME=sglang-deepseek-v3-pd-disagg
docker pull $IMAGE若你是 A2,请把 IMAGE 换成上表中 A2 镜像。
模型权重来源:
| 来源 | 链接 |
|---|---|
| Modelers | DeepSeek-R1-0528-w4a8 |
推荐:在宿主机将模型下载到即将挂载给容器的目录,例如:
mkdir -p /root/.cache/huggingface
# 使用 huggingface-cli 或 git lfs 等按模型卡说明下载到本地后,在 docker run 时挂载到容器内 /root/.cache以下与 官方 Docker 示例 一致;A3 使用 davinci0–7。若你只有部分卡,请按实际修改 --device。
需要在 两台机器 上分别启动容器。
export IMAGE=docker.io/lmsysorg/sglang:main-cann8.5.0-a3
export NAME=sglang-deepseek-v3-pd-disagg
docker run --rm \
--name $NAME \
--privileged \
--network=host \
--ipc=host \
--shm-size=16g \
--device /dev/davinci0 \
--device /dev/davinci1 \
--device /dev/davinci2 \
--device /dev/davinci3 \
--device /dev/davinci4 \
--device /dev/davinci5 \
--device /dev/davinci6 \
--device /dev/davinci7 \
--device /dev/davinci_manager \
--device /dev/hisi_hdc \
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
-v /usr/local/Ascend/firmware:/usr/local/Ascend/firmware \
-v /etc/ascend_install.info:/etc/ascend_install.info \
-v /var/queue_schedule:/var/queue_schedule \
-v ~/.cache/:/root/.cache/ \
-it $IMAGE bashPD 分离模式需要在 两台机器 上分别启动 Prefill 和 Decode 服务。
在第一台机器(Prefill)执行:
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export STREAMS_PER_DEVICE=32
#memfabric config store
export ASCEND_MF_STORE_URL="tcp://<PREFILL_HOST_IP>:<PORT>"
#Deepep communication settings
export DEEP_NORMAL_MODE_USE_INT8_QUANT=1
export HCCL_BUFFSIZE=1536
#npu acceleration operator
export SGLANG_NPU_USE_MLAPO=1
export SGLANG_USE_FIA_NZ=1
export TASK_QUEUE_ENABLE=2
python -m sglang.launch_server \
--model-path ${MODEL_PATH} \
--host $PREFILL_HOST_IP \
--port 8000 \
--disaggregation-mode prefill \
--disaggregation-bootstrap-port 8996 \
--disaggregation-transfer-backend ascend \
--trust-remote-code \
--nnodes 1 \
--node-rank 0 \
--tp-size 16 \
--mem-fraction-static 0.6 \
--attention-backend ascend \
--device npu \
--quantization modelslim \
--load-balance-method round_robin \
--max-running-requests 8 \
--context-length 8192 \
--disable-radix-cache \
--chunked-prefill-size -1 \
--max-prefill-tokens 28680 \
--moe-a2a-backend deepep \
--deepep-mode normal \
--speculative-algorithm NEXTN \
--speculative-num-steps 3 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 4 \
--dp-size 2 \
--enable-dp-attention \
--disable-shared-experts-fusion \
--dtype bfloat16在第二台机器(Decode)执行:
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export STREAMS_PER_DEVICE=32
#memfabric config store
export ASCEND_MF_STORE_URL="tcp://<PREFILL_HOST_IP>:<PORT>"
#Deepep communication settings
export HCCL_BUFFSIZE=720
export SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK=88
#spec overlap
export SGLANG_ENABLE_SPEC_V2=1
export SGLANG_ENABLE_OVERLAP_PLAN_STREAM=1
#npu acceleration operator
unset TASK_QUEUE_ENABLE
export SGLANG_NPU_USE_MLAPO=1
export SGLANG_USE_FIA_NZ=1
python -m sglang.launch_server \
--model-path ${MODEL_PATH} \
--disaggregation-mode decode \
--host $DECODE_HOST_IP \
--port 8001 \
--trust-remote-code \
--nnodes 1 \
--node-rank 0 \
--tp-size 16 \
--dp-size 16 \
--mem-fraction-static 0.8 \
--max-running-requests 352 \
--attention-backend ascend \
--device npu \
--quantization modelslim \
--moe-a2a-backend deepep \
--enable-dp-attention \
--deepep-mode low_latency \
--enable-dp-lm-head \
--cuda-graph-bs 8 10 12 14 16 18 20 22 \
--disaggregation-transfer-backend ascend \
--watchdog-timeout 9000 \
--context-length 8192 \
--speculative-algorithm NEXTN \
--speculative-num-steps 3 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 4 \
--disable-shared-experts-fusion \
--dtype bfloat16 \
--tokenizer-worker-num 4启动 SGLang Model Gateway 进行负载均衡:
python -m sglang_router.launch_router \
--pd-disaggregation \
--policy cache_aware \
--prefill http://<PREFILL_HOST_IP>:8000 8996 \
--decode http://<DECODE_HOST_IP>:8001 \
--host 127.0.0.1 \
--port 6688看到服务监听 8000/8001 且日志无报错后,另开终端(或宿主机再 docker exec)做下一步。
在能访问该节点 6688 端口的机器上执行(通过 Router):
curl http://localhost:6688/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "${MODEL_PATH}",
"prompt": "The future of AI is",
"max_completion_tokens": 50,
"temperature": 0
}'若返回 JSON 且含生成文本,即表示链路打通。
| 现象 | 建议 |
|---|---|
| 拉镜像超时 | 配置镜像加速或使用代理 |
| 容器内看不到 NPU | 检查 --device 是否与宿主机 npu-smi 一致;驱动路径挂载是否完整 |
| OOM / 显存不足 | 勿随意提高 --mem-fraction-static;按官方调小 max-model-len / 并发 |
| 模型下载慢 | 宿主机预先下载并 挂载 到 /root/.cache |
| 两台机器无法通信 | 检查网络连通性,确保 ASCEND_MF_STORE_URL 地址正确 |
| 参数看不懂 | 阅读 官方文档 |
| 说明 | 链接 |
|---|---|
| SGLang · 本模型(权威步骤) | 文档 |
| SGLang 安装说明 | ascend_npu.html |
镜像版本与启动参数随 SGLang 发布更新,若与官方文档冲突,以官方为准。