GLM5.3 MXFP4 部署指南
更新时间:
复制 MD 格式
基于灵骏真武 M890P 实例 efg3.GP9A 部署
SGLang v0.5.23
环境准备
镜像
docker pull egslingjun-registry.cn-wulanchabu.cr.aliyuncs.com/egslingjun-tmp/sglang:v0.5.23-ppu2.2.1-20261126下载模型。
# T-HEAD量化模型
modelscope download --model T-HEAD/GLM-5.3-MoE-Quant-W-MXFP4-A-MXFP4-Dense-Quant-W-FP8-PerChannel-A-FP8-PerToken --local_dir /path/to/your/modelModelScope 地址:https://modelscope.cn/models/T-HEAD/GLM-5.3-MoE-Quant-W-MXFP4-A-MXFP4-Dense-Quant-W-FP8-PerChannel-A-FP8-PerToken
部署拓扑:采用 1P1D(各 1 节点 8 卡,共 16 卡)拓扑,可基于M890P 与 M890L 实例部署。
PD 分离部署(基于 Mooncake)
PD 分离部署采用开源 Mooncake,通过 RDMA 传输 KVCache。
部署拓扑
角色 | 节点数 | 每节点卡数 | 并行策略 |
Prefill | 1 | 8 | TP8,DSA + MegaMoE,HiCache |
Decode | 1 | 8 | TP8 / DP8,DSA + DeepEP,EAGLE |
Prefill
export MODEL_PATH=/path/to/your/model
export SERVED_MODEL_NAME=GLM-5.3
export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export SGLANG_HOST_IP=<本机 IP>
export IB_DEVICE=mlx5_bond_0,mlx5_bond_1,mlx5_bond_2,mlx5_bond_3
export NCCL_DEBUG=INFO
export MC_FORCE_HCA=1
export MC_GID_INDEX=3
export MC_LOG_LEVEL=TRACE
export MC_TE_METRIC=1
export MC_NUM_QP_PER_EP=4
export PYTHONUNBUFFERED=1
export SGLANG_CACHE_DIR=/root/.cache/sglang
export TP_SOCKET_IFNAME=eth0
export MEGA_MOE_PULL_SMS=8
export MOONCAKE_PROTOCOL=rdma
export NCCL_DEBUG_SUBSYS=INIT
export NCCL_IB_GID_INDEX=3
export GLOO_SOCKET_IFNAME=eth0
export NCCL_SOCKET_IFNAME=eth0
export SGLANG_DG_CACHE_DIR=/root/.cache/sglang/deep_gemm
export SGLANG_JIT_CACHE_DIR=/root/.cache/sglang/jit
export SGLANG_WARMUP_TIMEOUT=3600
export DEEPEP_TIMEOUT_SECONDS=3600
export DG_USE_MOE_DYNAMIC_TILE=1
export SGLANG_ENABLE_CACHELINK=0
export MEGA_MOE_TAIL_GEMM_BLOCKS=0
export MEGA_MOE_TAIL_GEMM_PERCENT=0
export SGLANG_ENABLE_JIT_DEEPGEMM=1
export HGGC_EMBEDDED_COPY_THRESHOLD=0x10000
export SGLANG_SAIL_DEEPEP_RECV_HOOK=0
export SGLANG_JIT_DEEPGEMM_PRECOMPILE=1
export SGLANG_JIT_DEEPGEMM_FAST_WARMUP=0
export SGLANG_INTERNODE_HIER_ALL_GATHER=1
export SGLANG_OPT_USE_FP4_INDEXER_CACHE=0
export SGLANG_JIT_DEEPGEMM_COMPILE_WORKERS=16
export SGLANG_HICACHE_SHARED_MLA_HOST_CACHE=0
export SGLANG_HICACHE_HOST_REGISTER_CHUNK_GB=256
export SGLANG_DISAGGREGATION_ALL_CP_RANKS_TRANSFER=1
export SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK=256
export SGLANG_OPT_DEEPGEMM_MEGA_MOE_NUM_MAX_TOKENS_PER_RANK=16384
export SERVING_PORT=8000
export SGLANG_DSA_KV_FLAT_FP8=1
export SGLANG_OPT_ULTRA_EP_PPU=1
export SGLANG_OPT_ULTRA_EP_PPU_REDUNDANT_PER_RANK=1
export SGLANG_ENABLE_HEALTH_ENDPOINT_GENERATION=false
sglang serve \
--model-path ${MODEL_PATH} \
--served-model-name ${SERVED_MODEL_NAME} \
--trust-remote-code \
--tp-size 8 \
--attention-backend dsa \
--hicache-io-backend direct \
--moe-a2a-backend megamoe \
--dsa-prefill-backend flashmla_sparse \
--dsa-decode-backend flashmla_kv \
--disaggregation-transfer-backend mooncake \
--mem-fraction-static 0.9 \
--chunked-prefill-size 16384 \
--kv-cache-dtype fp8_e4m3 \
--disable-custom-all-reduce \
--watchdog-timeout 36000 \
--dist-timeout 36000 \
--disable-cuda-graph \
--num-continuous-decode-steps 1 \
--disable-shared-experts-fusion \
--reasoning-parser glm45 \
--tool-call-parser glm47 \
--hicache-ratio 2 \
--hicache-write-policy write_back \
--hicache-mem-layout layer_first \
--enable-hierarchical-cache \
--disable-overlap-schedule \
--enable-metrics \
--enable-cache-report \
--disaggregation-mode prefill \
--disaggregation-bootstrap-port $((SERVING_PORT + 30)) \
--disaggregation-ib-device ${IB_DEVICE} \
--port ${SERVING_PORT} \
--host 0.0.0.0Decode
export MODEL_PATH=/path/to/your/model
export SERVED_MODEL_NAME=GLM-5.3
export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export SGLANG_HOST_IP=<本机 IP>
export IB_DEVICE=mlx5_bond_0,mlx5_bond_1,mlx5_bond_2,mlx5_bond_3
export NCCL_DEBUG=INFO
export MC_FORCE_HCA=1
export MC_GID_INDEX=3
export MC_LOG_LEVEL=TRACE
export MC_TE_METRIC=1
export MC_NUM_QP_PER_EP=4
export PYTHONUNBUFFERED=1
export SGLANG_CACHE_DIR=/root/.cache/sglang
export TP_SOCKET_IFNAME=eth0
export MOONCAKE_PROTOCOL=rdma
export NCCL_DEBUG_SUBSYS=INIT
export NCCL_IB_GID_INDEX=3
export GLOO_SOCKET_IFNAME=eth0
export NCCL_SOCKET_IFNAME=eth0
export SGLANG_DG_CACHE_DIR=/root/.cache/sglang/deep_gemm
export SGLANG_JIT_CACHE_DIR=/root/.cache/sglang/jit
export SGLANG_WARMUP_TIMEOUT=3600
export DEEPEP_TIMEOUT_SECONDS=3600
export DG_USE_MOE_DYNAMIC_TILE=1
export SGLANG_ENABLE_CACHELINK=0
export SGLANG_ENABLE_JIT_DEEPGEMM=1
export HGGC_EMBEDDED_COPY_THRESHOLD=0x10000
export SGLANG_SAIL_DEEPEP_RECV_HOOK=0
export SGLANG_JIT_DEEPGEMM_PRECOMPILE=1
export SGLANG_JIT_DEEPGEMM_FAST_WARMUP=0
export SGLANG_INTERNODE_HIER_ALL_GATHER=1
export SGLANG_OPT_USE_FP4_INDEXER_CACHE=0
export SGLANG_DISAGGREGATION_ALL_CP_RANKS_TRANSFER=1
export SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK=256
export SGLANG_DSV4_FLASHMLA_USE_DRAFT_EXTEND_GRAPH_SCHEDULE=1
export SERVING_PORT=8000
export SGLANG_DSA_KV_FLAT_FP8=1
sglang serve \
--model-path ${MODEL_PATH} \
--served-model-name ${SERVED_MODEL_NAME} \
--trust-remote-code \
--tp-size 8 \
--moe-dense-tp-size 1 \
--enable-dp-lm-head \
--enable-dp-attention \
--dp-size 8 \
--moe-a2a-backend deepep \
--deepep-mode auto \
--attention-backend dsa \
--dsa-prefill-backend flashmla_sparse \
--dsa-decode-backend flashmla_kv \
--disaggregation-transfer-backend mooncake \
--mem-fraction-static 0.9 \
--cuda-graph-max-bs-decode 32 \
--max-running-requests 256 \
--kv-cache-dtype fp8_e4m3 \
--speculative-algorithm EAGLE \
--speculative-num-steps 2 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 3 \
--speculative-attention-mode decode \
--decode-log-interval 1 \
--stream-interval 128 \
--disable-custom-all-reduce \
--watchdog-timeout 36000 \
--dist-timeout 36000 \
--num-continuous-decode-steps 1 \
--disable-radix-cache \
--disable-shared-experts-fusion \
--reasoning-parser glm45 \
--tool-call-parser glm47 \
--enable-metrics \
--enable-cache-report \
--disaggregation-mode decode \
--disaggregation-bootstrap-port $((SERVING_PORT + 30)) \
--disaggregation-ib-device ${IB_DEVICE} \
--port ${SERVING_PORT} \
--host 0.0.0.0启动 Router
export PREFILL0_IP=<prefill 节点 IP>
export DECODE_IP=<decode 节点 IP>
export PREFILL0_PORT=8000
export DECODE_PORT=8000
export BOOTSTRAP_PORT=8030
export SERVICE_PORT=8080
python -m sglang_router.launch_router \
--prefill http://$PREFILL0_IP:$PREFILL0_PORT $BOOTSTRAP_PORT \
--decode http://$DECODE_IP:$DECODE_PORT \
--host 0.0.0.0 \
--port $SERVICE_PORT \
--pd-disaggregation \
--disable-health-check \
--worker-startup-check-interval 1800 \
--request-timeout-secs 3600SGLang v0.5.21
环境准备
镜像
docker pull egslingjun-registry.cn-wulanchabu.cr.aliyuncs.com/egslingjun-tmp/inference-xpu-pytorch-opt:v0.5.21_1ccf267d76_20261116_175604下载模型。
# T-HEAD量化模型
modelscope download --model T-HEAD/GLM-5.3-MoE-Quant-W-MXFP4-A-MXFP4-Dense-Quant-W-FP8-PerChannel-A-FP8-PerToken --local_dir /path/to/your/model模型:https://modelscope.cn/models/T-HEAD/GLM-5.3-MoE-Quant-W-MXFP4-A-MXFP4-Dense-Quant-W-FP8-PerChannel-A-FP8-PerToken
PD分离部署(基于Mooncake)
这里PD分离部署采用开源Mooncake,通过RDMA传输KVCache。
Prefill
export MODEL_PATH=/path/to/your/model
export SERVED_MODEL_NAME=GLM-5.3
export NCCL_DEBUG=INFO
export MC_FORCE_HCA=1
export MC_GID_INDEX=3
export MC_LOG_LEVEL=TRACE
export MC_TE_METRIC=1
export MC_NUM_QP_PER_EP=4
export PYTHONUNBUFFERED=1
export TP_SOCKET_IFNAME=eth0
export MEGA_MOE_PULL_SMS=8
export MOONCAKE_PROTOCOL=rdma
export NCCL_DEBUG_SUBSYS=INIT
export NCCL_IB_GID_INDEX=3
export GLOO_SOCKET_IFNAME=eth0
export NCCL_SOCKET_IFNAME=eth0
export SGLANG_WARMUP_TIMEOUT=3600
export DEEPEP_TIMEOUT_SECONDS=3600
export DG_USE_MOE_DYNAMIC_TILE=1
export SGLANG_ENABLE_CACHELINK=0
export MEGA_MOE_TAIL_GEMM_BLOCKS=0
export MEGA_MOE_TAIL_GEMM_PERCENT=0
export SGLANG_ENABLE_JIT_DEEPGEMM=1
export HGGC_EMBEDDED_COPY_THRESHOLD=0x10000
export SGLANG_SAIL_DEEPEP_RECV_HOOK=0
export SGLANG_JIT_DEEPGEMM_PRECOMPILE=1
export SGLANG_JIT_DEEPGEMM_FAST_WARMUP=0
export SGLANG_INTERNODE_HIER_ALL_GATHER=1
export SGLANG_OPT_USE_FP4_INDEXER_CACHE=0
export SGLANG_JIT_DEEPGEMM_COMPILE_WORKERS=16
export SGLANG_HICACHE_SHARED_MLA_HOST_CACHE=0
export SGLANG_HICACHE_HOST_REGISTER_CHUNK_GB=256
export SGLANG_DISAGGREGATION_ALL_CP_RANKS_TRANSFER=1
export SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK=256
export SGLANG_OPT_DEEPGEMM_MEGA_MOE_NUM_MAX_TOKENS_PER_RANK=8192
export SGLANG_DSA_KV_FLAT_FP8=1
export SGLANG_OPT_ULTRA_EP_PPU=1
export SGLANG_OPT_ULTRA_EP_PPU_REDUNDANT_PER_RANK=1
export SGLANG_ENABLE_HEALTH_ENDPOINT_GENERATION=false
export SERVING_PORT=8000
sglang serve \
--model-path ${MODEL_PATH} \
--served-model-name ${SERVED_MODEL_NAME} \
--trust-remote-code \
--tp-size 8 \
--enable-prefill-cp \
--cp-strategy interleave \
--attention-backend dsa \
--hicache-io-backend direct \
--moe-a2a-backend megamoe \
--dsa-prefill-backend flashmla_sparse_q8 \
--dsa-decode-backend flashmla_sparse_q8 \
--disaggregation-transfer-backend mooncake \
--mem-fraction-static 0.9 \
--chunked-prefill-size 32768 \
--kv-cache-dtype fp8_e4m3 \
--disable-custom-all-reduce \
--watchdog-timeout 36000 \
--dist-timeout 36000 \
--disable-cuda-graph \
--num-continuous-decode-steps 1 \
--disable-shared-experts-fusion \
--reasoning-parser glm45 \
--tool-call-parser glm47 \
--hicache-ratio 2 \
--hicache-write-policy write_back \
--hicache-mem-layout layer_first \
--enable-hierarchical-cache \
--disable-overlap-schedule \
--enable-metrics \
--enable-cache-report \
--disaggregation-mode prefill \
--disaggregation-bootstrap-port 8030 \
--disaggregation-ib-device mlx5_bond_0,mlx5_bond_1,mlx5_bond_2,mlx5_bond_3 \
--port ${SERVING_PORT} \
--host 0.0.0.0Decode
export MODEL_PATH=/path/to/your/model
export SERVED_MODEL_NAME=GLM-5.3
export NCCL_DEBUG=INFO
export MC_FORCE_HCA=1
export MC_GID_INDEX=3
export MC_LOG_LEVEL=TRACE
export MC_TE_METRIC=1
export MC_NUM_QP_PER_EP=4
export PYTHONUNBUFFERED=1
export TP_SOCKET_IFNAME=eth0
export MOONCAKE_PROTOCOL=rdma
export NCCL_DEBUG_SUBSYS=INIT
export NCCL_IB_GID_INDEX=3
export GLOO_SOCKET_IFNAME=eth0
export NCCL_SOCKET_IFNAME=eth0
export SGLANG_WARMUP_TIMEOUT=3600
export DEEPEP_TIMEOUT_SECONDS=3600
export DG_USE_MOE_DYNAMIC_TILE=1
export SGLANG_ENABLE_CACHELINK=0
export SGLANG_ENABLE_JIT_DEEPGEMM=1
export HGGC_EMBEDDED_COPY_THRESHOLD=0x10000
export SGLANG_SAIL_DEEPEP_RECV_HOOK=0
export SGLANG_JIT_DEEPGEMM_PRECOMPILE=1
export SGLANG_JIT_DEEPGEMM_FAST_WARMUP=0
export SGLANG_INTERNODE_HIER_ALL_GATHER=1
export SGLANG_OPT_USE_FP4_INDEXER_CACHE=0
export SGLANG_DISAGGREGATION_ALL_CP_RANKS_TRANSFER=1
export SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK=256
export SGLANG_DSV4_FLASHMLA_USE_DRAFT_EXTEND_GRAPH_SCHEDULE=1
export SGLANG_DSA_KV_FLAT_FP8=1
export SERVING_PORT=8000
sglang serve \
--model-path ${MODEL_PATH} \
--served-model-name ${SERVED_MODEL_NAME} \
--trust-remote-code \
--tp-size 8 \
--moe-dense-tp-size 1 \
--enable-dp-lm-head \
--enable-dp-attention \
--dp-size 8 \
--moe-a2a-backend deepep \
--deepep-mode auto \
--attention-backend dsa \
--dsa-prefill-backend flashmla_sparse_q8 \
--dsa-decode-backend flashmla_sparse_q8 \
--disaggregation-transfer-backend mooncake \
--mem-fraction-static 0.9 \
--cuda-graph-max-bs-decode 32 \
--max-running-requests 256 \
--kv-cache-dtype fp8_e4m3 \
--speculative-algorithm EAGLE \
--speculative-num-steps 2 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 3 \
--speculative-attention-mode decode \
--decode-log-interval 1 \
--stream-interval 128 \
--disable-custom-all-reduce \
--watchdog-timeout 36000 \
--dist-timeout 36000 \
--num-continuous-decode-steps 1 \
--disable-radix-cache \
--disable-shared-experts-fusion \
--reasoning-parser glm45 \
--tool-call-parser glm47 \
--enable-metrics \
--enable-cache-report \
--disaggregation-mode decode \
--disaggregation-bootstrap-port 8030 \
--disaggregation-ib-device mlx5_bond_0,mlx5_bond_1,mlx5_bond_2,mlx5_bond_3 \
--port ${SERVING_PORT} \
--host 0.0.0.0启动Router
python -m sglang_router.launch_router \
--prefill http://$PREFILL_IP:$PREFILL_PORT $BOOTSTRAP_PORT \
--decode http://$DECODE_IP:$DECODE_PORT \
--host 0.0.0.0 \
--port $SERVICE_PORT \
--pd-disaggregation \
--disable-health-check \
--worker-startup-check-interval 1800 \
--request-timeout-secs 3600基于灵骏真武 M890L 实例 efg3.GP9AS 部署
SGLang v0.5.23
环境准备
镜像
docker pull egslingjun-registry.cn-wulanchabu.cr.aliyuncs.com/egslingjun-tmp/sglang:v0.5.23-ppu2.2.1-20261126下载模型。
# T-HEAD量化模型
modelscope download --model T-HEAD/GLM-5.3-MoE-Quant-W-MXFP4-A-MXFP4-Dense-Quant-W-FP8-PerChannel-A-FP8-PerToken --local_dir /path/to/your/modelModelScope 地址:https://modelscope.cn/models/T-HEAD/GLM-5.3-MoE-Quant-W-MXFP4-A-MXFP4-Dense-Quant-W-FP8-PerChannel-A-FP8-PerToken
部署拓扑:采用 1P1D(各 1 节点 8 卡,共 16 卡)拓扑,可基于 M890P 与 M890L 实例部署。
PD 分离部署(基于 Mooncake)
PD 分离部署采用开源 Mooncake,通过 RDMA 传输 KVCache。
部署拓扑
角色 | 节点数 | 每节点卡数 | 并行策略 |
Prefill | 1 | 8 | TP8,DSA + MegaMoE,HiCache |
Decode | 1 | 8 | TP8 / DP8,DSA + DeepEP,EAGLE |
Prefill
export MODEL_PATH=/path/to/your/model
export SERVED_MODEL_NAME=glm5.3
export IB_DEVICE=troce_bond_0,troce_bond_1,troce_bond_2,troce_bond_3
export SGLANG_CACHE_DIR=/root/.cache/sglang
export NCCL_IB_GID_INDEX=1
export SGLANG_DG_CACHE_DIR=/root/.cache/sglang/deep_gemm
export SGLANG_JIT_CACHE_DIR=/root/.cache/sglang/jit
export SERVING_PORT=8000
export MC_FORCE_MNNVL=1
export SGLANG_MOONCAKE_CUSTOM_MEM_POOL=NVLINK
export SGLANG_JIT_DEEPGEMM_COMPILE_WORKERS=16
export SGLANG_WARMUP_TIMEOUT=3600
export SGLANG_SAIL_DEEPEP_RECV_HOOK=0
export DEEPEP_TIMEOUT_SECONDS=3600
export DG_USE_MOE_DYNAMIC_TILE=1
export SGLANG_INTERNODE_HIER_ALL_GATHER=1
export SGLANG_DISAGGREGATION_ALL_CP_RANKS_TRANSFER=1
export SGLANG_OPT_DEEPGEMM_MEGA_MOE_NUM_MAX_TOKENS_PER_RANK=8192
export SGLANG_DSA_KV_FLAT_FP8=1
export MC_NUM_QP_PER_EP=4
export SGLANG_OPT_USE_FP4_INDEXER_CACHE=0
export MEGA_MOE_PULL_SMS=8
export MEGA_MOE_TAIL_GEMM_BLOCKS=0
export MEGA_MOE_TAIL_GEMM_PERCENT=0
export SGLANG_OPT_ULTRA_EP_PPU=1
export SGLANG_OPT_ULTRA_EP_PPU_REDUNDANT_PER_RANK=1
export SGLANG_HICACHE_HOST_REGISTER_CHUNK_GB=256
export SGLANG_ENABLE_HEALTH_ENDPOINT_GENERATION=false
export SGLANG_HICACHE_SHARED_MLA_HOST_CACHE=0
export SGLANG_ENABLE_JIT_DEEPGEMM=1
export SGLANG_JIT_DEEPGEMM_PRECOMPILE=1
export SGLANG_JIT_DEEPGEMM_FAST_WARMUP=0
export PYTHONUNBUFFERED=1
export SGLANG_ENABLE_CACHELINK=0
export MC_FORCE_HCA=1
export MOONCAKE_PROTOCOL=rdma
sglang serve \
--model-path ${MODEL_PATH} \
--served-model-name ${SERVED_MODEL_NAME} \
--trust-remote-code \
--tp-size 8 \
--attention-backend dsa \
--hicache-io-backend direct \
--moe-a2a-backend megamoe \
--dsa-prefill-backend flashmla_sparse \
--dsa-decode-backend flashmla_kv \
--disaggregation-transfer-backend mooncake \
--mem-fraction-static 0.9 \
--chunked-prefill-size 8192 \
--kv-cache-dtype fp8_e4m3 \
--disable-custom-all-reduce \
--watchdog-timeout 36000 \
--dist-timeout 36000 \
--disable-cuda-graph \
--num-continuous-decode-steps 1 \
--disable-shared-experts-fusion \
--reasoning-parser glm45 \
--tool-call-parser glm47 \
--hicache-ratio 2 \
--hicache-write-policy write_back \
--hicache-mem-layout layer_first \
--enable-hierarchical-cache \
--disable-overlap-schedule \
--enable-metrics \
--enable-cache-report \
--disaggregation-mode prefill \
--disaggregation-bootstrap-port $((SERVING_PORT + 30)) \
--disaggregation-ib-device ${IB_DEVICE} \
--port ${SERVING_PORT} \
--host 0.0.0.0Decode
export MODEL_PATH=/path/to/your/model
export SERVED_MODEL_NAME=glm5.3
export IB_DEVICE=troce_bond_0,troce_bond_1,troce_bond_2,troce_bond_3
export SGLANG_CACHE_DIR=/root/.cache/sglang
export NCCL_IB_GID_INDEX=1
export SGLANG_DG_CACHE_DIR=/root/.cache/sglang/deep_gemm
export SGLANG_JIT_CACHE_DIR=/root/.cache/sglang/jit
export SERVING_PORT=8000
export MC_FORCE_MNNVL=1
export SGLANG_MOONCAKE_CUSTOM_MEM_POOL=NVLINK
export SGLANG_DSV4_FLASHMLA_USE_DRAFT_EXTEND_GRAPH_SCHEDULE=1
export SGLANG_WARMUP_TIMEOUT=3600
export SGLANG_SAIL_DEEPEP_RECV_HOOK=0
export SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK=256
export DEEPEP_TIMEOUT_SECONDS=3600
export DG_USE_MOE_DYNAMIC_TILE=1
export SGLANG_INTERNODE_HIER_ALL_GATHER=1
export SGLANG_DISAGGREGATION_ALL_CP_RANKS_TRANSFER=1
export SGLANG_DSA_KV_FLAT_FP8=1
export MC_NUM_QP_PER_EP=4
export SGLANG_OPT_USE_FP4_INDEXER_CACHE=0
export SGLANG_ENABLE_JIT_DEEPGEMM=1
export SGLANG_JIT_DEEPGEMM_PRECOMPILE=1
export SGLANG_JIT_DEEPGEMM_FAST_WARMUP=0
export PYTHONUNBUFFERED=1
export SGLANG_ENABLE_CACHELINK=0
export MC_FORCE_HCA=1
export MOONCAKE_PROTOCOL=rdma
sglang serve \
--model-path ${MODEL_PATH} \
--served-model-name ${SERVED_MODEL_NAME} \
--trust-remote-code \
--tp-size 8 \
--moe-dense-tp-size 1 \
--enable-dp-lm-head \
--enable-dp-attention \
--dp-size 8 \
--moe-a2a-backend deepep \
--deepep-mode auto \
--attention-backend dsa \
--dsa-prefill-backend flashmla_sparse \
--dsa-decode-backend flashmla_kv \
--disaggregation-transfer-backend mooncake \
--mem-fraction-static 0.9 \
--cuda-graph-max-bs-decode 32 \
--max-running-requests 256 \
--kv-cache-dtype fp8_e4m3 \
--speculative-algorithm EAGLE \
--speculative-num-steps 2 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 3 \
--speculative-attention-mode decode \
--decode-log-interval 1 \
--stream-interval 128 \
--disable-custom-all-reduce \
--watchdog-timeout 36000 \
--dist-timeout 36000 \
--num-continuous-decode-steps 1 \
--disable-radix-cache \
--disable-shared-experts-fusion \
--reasoning-parser glm45 \
--tool-call-parser glm47 \
--enable-metrics \
--enable-cache-report \
--disaggregation-mode decode \
--disaggregation-bootstrap-port $((SERVING_PORT + 30)) \
--disaggregation-ib-device ${IB_DEVICE} \
--port ${SERVING_PORT} \
--host 0.0.0.0启动 Router
export PREFILL0_IP=<prefill 节点 IP>
export DECODE_IP=<decode 节点 IP>
export PREFILL0_PORT=8000
export DECODE_PORT=8000
export BOOTSTRAP_PORT=8030
export SERVICE_PORT=8080
python -m sglang_router.launch_router \
--prefill http://$PREFILL0_IP:$PREFILL0_PORT $BOOTSTRAP_PORT \
--decode http://$DECODE_IP:$DECODE_PORT \
--host 0.0.0.0 \
--port $SERVICE_PORT \
--pd-disaggregation \
--disable-health-check \
--worker-startup-check-interval 1800 \
--request-timeout-secs 3600SGLang v0.5.21
环境准备
镜像
docker pull egslingjun-registry.cn-wulanchabu.cr.aliyuncs.com/egslingjun-tmp/inference-xpu-pytorch-opt:v0.5.21_1ccf267d76_20261116_175604下载模型。
# T-HEAD量化模型
modelscope download --model T-HEAD/GLM-5.3-MoE-Quant-W-MXFP4-A-MXFP4-Dense-Quant-W-FP8-PerChannel-A-FP8-PerToken --local_dir /path/to/your/modelModelScope 地址:https://modelscope.cn/models/T-HEAD/GLM-5.3-MoE-Quant-W-MXFP4-A-MXFP4-Dense-Quant-W-FP8-PerChannel-A-FP8-PerToken
PD分离部署(基于Mooncake)
这里 PD 分离部署采用 Mooncake 传输 KVCache(RDMA)。
下列命令中的$变量请按实际环境设置:$PREFILL_IP/$PREFILL_PORT(Prefill 节点 IP 与服务端口)、$BOOTSTRAP_PORT(P/D bootstrap 端口)、$DECODE_IP/$DECODE_PORT(Decode 节点 IP 与服务端口)、$SERVICE_PORT(Router 对外端口)。
Prefill
export MODEL_PATH=/path/to/your/model
export SERVED_MODEL_NAME=glm5.3
export IB_DEVICE=troce_bond_0,troce_bond_1,troce_bond_2,troce_bond_3
export NCCL_IB_GID_INDEX=1
export MC_FORCE_MNNVL=1
export SGLANG_MOONCAKE_CUSTOM_MEM_POOL=NVLINK
export SGLANG_JIT_DEEPGEMM_COMPILE_WORKERS=16
export SGLANG_WARMUP_TIMEOUT=3600
export SGLANG_SAIL_DEEPEP_RECV_HOOK=0
export DEEPEP_TIMEOUT_SECONDS=3600
export DG_USE_MOE_DYNAMIC_TILE=1
export SGLANG_INTERNODE_HIER_ALL_GATHER=1
export SGLANG_DISAGGREGATION_ALL_CP_RANKS_TRANSFER=1
export SGLANG_OPT_DEEPGEMM_MEGA_MOE_NUM_MAX_TOKENS_PER_RANK=8192
export SGLANG_DSA_KV_FLAT_FP8=1
export MC_NUM_QP_PER_EP=4
export SGLANG_OPT_USE_FP4_INDEXER_CACHE=0
export MEGA_MOE_PULL_SMS=8
export MEGA_MOE_TAIL_GEMM_BLOCKS=0
export MEGA_MOE_TAIL_GEMM_PERCENT=0
export SGLANG_OPT_ULTRA_EP_PPU=1
export SGLANG_OPT_ULTRA_EP_PPU_REDUNDANT_PER_RANK=1
export SGLANG_HICACHE_HOST_REGISTER_CHUNK_GB=256
export SGLANG_ENABLE_HEALTH_ENDPOINT_GENERATION=false
export SGLANG_HICACHE_SHARED_MLA_HOST_CACHE=0
export SGLANG_ENABLE_JIT_DEEPGEMM=1
export SGLANG_JIT_DEEPGEMM_PRECOMPILE=1
export SGLANG_JIT_DEEPGEMM_FAST_WARMUP=0
export PYTHONUNBUFFERED=1
export SGLANG_ENABLE_CACHELINK=0
export MC_FORCE_HCA=1
export MOONCAKE_PROTOCOL=rdma
sglang serve \
--model-path ${MODEL_PATH} \
--served-model-name ${SERVED_MODEL_NAME} \
--trust-remote-code \
--tp-size 8 \
--enable-prefill-cp \
--cp-strategy interleave \
--attention-backend dsa \
--hicache-io-backend direct \
--moe-a2a-backend megamoe \
--dsa-prefill-backend flashmla_sparse_q8 \
--dsa-decode-backend flashmla_sparse_q8 \
--disaggregation-transfer-backend mooncake \
--mem-fraction-static 0.9 \
--chunked-prefill-size 32768 \
--kv-cache-dtype fp8_e4m3 \
--disable-custom-all-reduce \
--watchdog-timeout 36000 \
--dist-timeout 36000 \
--disable-cuda-graph \
--num-continuous-decode-steps 1 \
--disable-shared-experts-fusion \
--reasoning-parser glm45 \
--tool-call-parser glm47 \
--hicache-ratio 2 \
--hicache-write-policy write_back \
--hicache-mem-layout layer_first \
--enable-hierarchical-cache \
--disable-overlap-schedule \
--enable-metrics \
--enable-cache-report \
--disaggregation-mode prefill \
--disable-mla-cache-broadcast \
--disaggregation-bootstrap-port $BOOTSTRAP_PORT \
--disaggregation-ib-device $IB_DEVICE \
--port $PREFILL_PORT \
--host 0.0.0.0Decode
export MODEL_PATH=/path/to/your/model
export SERVED_MODEL_NAME=glm5.3
export IB_DEVICE=troce_bond_0,troce_bond_1,troce_bond_2,troce_bond_3
export NCCL_IB_GID_INDEX=1
export MC_FORCE_MNNVL=1
export SGLANG_MOONCAKE_CUSTOM_MEM_POOL=NVLINK
export SGLANG_DSV4_FLASHMLA_USE_DRAFT_EXTEND_GRAPH_SCHEDULE=1
export SGLANG_WARMUP_TIMEOUT=3600
export SGLANG_SAIL_DEEPEP_RECV_HOOK=0
export SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK=256
export DEEPEP_TIMEOUT_SECONDS=3600
export DG_USE_MOE_DYNAMIC_TILE=1
export SGLANG_INTERNODE_HIER_ALL_GATHER=1
export SGLANG_DISAGGREGATION_ALL_CP_RANKS_TRANSFER=1
export SGLANG_DSA_KV_FLAT_FP8=1
export MC_NUM_QP_PER_EP=4
export SGLANG_OPT_USE_FP4_INDEXER_CACHE=0
export SGLANG_ENABLE_JIT_DEEPGEMM=1
export SGLANG_JIT_DEEPGEMM_PRECOMPILE=1
export SGLANG_JIT_DEEPGEMM_FAST_WARMUP=0
export PYTHONUNBUFFERED=1
export SGLANG_ENABLE_CACHELINK=0
export MC_FORCE_HCA=1
export MOONCAKE_PROTOCOL=rdma
sglang serve \
--model-path ${MODEL_PATH} \
--served-model-name ${SERVED_MODEL_NAME} \
--trust-remote-code \
--tp-size 8 \
--moe-dense-tp-size 1 \
--enable-dp-lm-head \
--enable-dp-attention \
--dp-size 8 \
--moe-a2a-backend deepep \
--deepep-mode auto \
--attention-backend dsa \
--dsa-prefill-backend flashmla_sparse_q8 \
--dsa-decode-backend flashmla_sparse_q8 \
--disaggregation-transfer-backend mooncake \
--mem-fraction-static 0.9 \
--cuda-graph-max-bs-decode 32 \
--max-running-requests 256 \
--kv-cache-dtype fp8_e4m3 \
--speculative-algorithm EAGLE \
--speculative-num-steps 2 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 3 \
--speculative-attention-mode decode \
--decode-log-interval 1 \
--stream-interval 128 \
--disable-custom-all-reduce \
--watchdog-timeout 36000 \
--dist-timeout 36000 \
--num-continuous-decode-steps 1 \
--disable-radix-cache \
--disable-shared-experts-fusion \
--reasoning-parser glm45 \
--tool-call-parser glm47 \
--enable-metrics \
--enable-cache-report \
--disaggregation-mode decode \
--disaggregation-bootstrap-port $BOOTSTRAP_PORT \
--disaggregation-ib-device $IB_DEVICE \
--port $DECODE_PORT \
--host 0.0.0.0启动 Router
python -m sglang_router.launch_router \
--prefill http://$PREFILL_IP:$PREFILL_PORT $BOOTSTRAP_PORT \
--decode http://$DECODE_IP:$DECODE_PORT \
--host 0.0.0.0 \
--port $SERVICE_PORT \
--pd-disaggregation \
--disable-health-check \
--worker-startup-check-interval 1800 \
--request-timeout-secs 3600有多个 Prefill / Decode 实例时,重复--prefill/--decode参数列出全部端点;客户端统一访问http://<router-host>:$SERVICE_PORT。
该文章对您有帮助吗?