> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sglang.io/llms.txt
> Use this file to discover all available pages before exploring further.

# GLM-5.2

## Introduction

GLM-5.2 is a large language model in the GLM (General Language Model) series, jointly developed by the KEG Laboratory
of Tsinghua University and Zhipu AI. GLM-5.2 adopts the DeepSeek-V3/V3.2 architecture, including DeepSeek Sparse
Attention (DSA) and multi-token prediction (MTP), and supports high-throughput inference with SGLang on Ascend NPUs.

This document demonstrates the deployment of GLM-5.2 on Ascend NPUs using SGLang, including single-node deployment,
multi-node deployment, prefill-decode disaggregation, feature configuration, and performance optimization.

## Supported features

| Feature | Example usage |
| - | - |
| Tensor Parallelism | `--tp-size 16` |
| Data Parallelism | `--dp-size 16` |
| Expert Parallelism | `--ep-size 16 \` `--moe-a2a-backend deepep \` `--deepep-mode auto` |
| PD Disaggregation | `--disaggregation-mode prefill \` `--disaggregation-transfer-backend ascend` |
| Quantization | `--quantization modelslim` |
| Chunked Prefill | auto based on device memory, or set explicit value; disable with `--chunked-prefill-size -1`; e.g., `--chunked-prefill-size 16384` |
| NPU Graph | enabled by default; disable with `--disable-cuda-graph`; control range via `--cuda-graph-bs-decode` or `--cuda-graph-max-bs-decode`; e.g., `--cuda-graph-bs-decode 16` |
| Speculative Decoding | `--speculative-algorithm NEXTN \` `--speculative-num-steps 3 \` `--speculative-eagle-topk 1 \` `--speculative-num-draft-tokens 4 \` `--speculative-draft-model-quantization unquant` |
| Overlap Schedule | `export SGLANG_ENABLE_OVERLAP_PLAN_STREAM=1` |
| DP LM Head | `--enable-dp-lm-head` |

> [!NOTE]
>
> The values in the **Example usage** column are for illustration only. Adjust them according to your hardware, deployment
> mode, and workload. For parameter details, see
> [Parameter Reference](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/optimization/parameter_tuning.md#parameter-reference); for
> recommended configurations for each deployment scenario, see [Best practices](#best-practices).

For feature compatibility and conflict information between features,
see [Feature Compatibility](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/optimization/parameter_tuning.md#feature-compatibility).

## Prerequisites

### Environment

Before following this tutorial, complete the environment setup in the documents below:

* [Ascend NPU Quickstart](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/getting-started/quick_start.md) — the fastest way to get started.
  It walks you through launching the official container image, starting the SGLang server, and sending a test request.
  Recommended if you are new to SGLang on Ascend.
* [SGLang Installation with NPU Support](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/getting-started/installation.md) — the full installation guide.
  It covers the component version mapping (CANN, TorchNPU, Triton, kernels, etc.), building from source or from a
  Dockerfile, and recommended system settings (CPU power scheme, NUMA, swap). Use it when you need to install or customize
  the environment instead of using the official image.

### Model weights

Before downloading model weights, check the model size to reserve enough disk space.
For multi-node deployment, download the weights to a shared directory accessible to all nodes.

* [GLM-5.2](https://www.modelscope.cn/models/ZhipuAI/GLM-5.2) (BF16, 1.51TB)
* [GLM-5.2-w8a8](https://www.modelscope.cn/models/Eco-Tech/GLM-5.2-w8a8/) (Quantized version without MTP, 774.08GB)
* [GLM-5.2-w4a8](https://www.modelscope.cn/models/Eco-Tech/GLM-5.2-w4a8) (W4A8 quantized version, 377.19GB)
* You can use [msmodelslim](https://gitcode.com/Ascend/msmodelslim) to quantize the model naively.

> [!NOTE]
>
> We recommend deploying the W8A8 variant for reduced resource usage and higher throughput.
> It (774.08GB) can be deployed on 16 × 64GB of device memory (`--tp-size 16`), which corresponds to one full A3 Series node (8 cards, 16 dies).

This is the minimum recommended configuration. For optimized configurations,
see [Best practices](#best-practices), which may require additional cards or nodes.

For the hardware specifications (memory per die and dies per card),
see [Ascend NPU Reference — Hardware](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/reference/glossary.md#hardware).

## Installation

> [!WARNING]
>
> Ensure sufficient disk space before pulling images. The Docker image requires at least **30GB** of free space.

The dependencies required for the NPU runtime environment have been integrated into a Docker image and uploaded to the
online platform. You can directly pull it.

Both **stable releases** and **daily builds** are available. CANN 9.1.0 has no stable release yet, so the following
command uses the validated build tag `cann9.1.0-a3-B105`.
For details, see [Docker image versions](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/faq.md#8-docker-image-versions-stable-release-vs-daily-build).

```bash Command theme={null}
docker pull swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:cann9.1.0-a3-B105

docker run -itd --shm-size=16g --name ${NAME} \
--privileged=true --net=host \
-v /var/queue_schedule:/var/queue_schedule \
-v /etc/ascend_install.info:/etc/ascend_install.info \
-v /usr/local/sbin:/usr/local/sbin \
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
-v /usr/local/Ascend/firmware:/usr/local/Ascend/firmware \
--device=/dev/davinci0:/dev/davinci0  \
--device=/dev/davinci1:/dev/davinci1  \
--device=/dev/davinci2:/dev/davinci2  \
--device=/dev/davinci3:/dev/davinci3  \
--device=/dev/davinci4:/dev/davinci4  \
--device=/dev/davinci5:/dev/davinci5  \
--device=/dev/davinci6:/dev/davinci6  \
--device=/dev/davinci7:/dev/davinci7  \
--device=/dev/davinci8:/dev/davinci8  \
--device=/dev/davinci9:/dev/davinci9  \
--device=/dev/davinci10:/dev/davinci10  \
--device=/dev/davinci11:/dev/davinci11  \
--device=/dev/davinci12:/dev/davinci12  \
--device=/dev/davinci13:/dev/davinci13  \
--device=/dev/davinci14:/dev/davinci14  \
--device=/dev/davinci15:/dev/davinci15  \
--device=/dev/davinci_manager:/dev/davinci_manager \
--device=/dev/hisi_hdc:/dev/hisi_hdc \
--entrypoint=bash \
swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:cann9.1.0-a3-B105
```

> [!TIP]
>
> * If the model weights have already been downloaded to a shared directory, use `-v` to mount the model path into the
>   container, for example: `-v /path/to/models:/models`.
> * Replace `${NAME}` with your own container name or remove `--name` to use default name.

## Online service deployment

### Single-node deployment

Quantized GLM-5.2 models can be deployed on one Ascend A3 Series node. Select the tab for the quantized weights you
downloaded, then run the script to execute online inference.

> [tab] W8A8
>
> Use the `GLM-5.2-w8a8` checkpoint on one A3 Series node.
>
> ```shell theme={null}
> # ============================================================
> # Before running, update the following variables:
> #   MODEL_PATH: path to the model weights directory
> # ============================================================
>
> # high performance cpu
> echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
> sysctl -w vm.swappiness=0
> sysctl -w kernel.numa_balancing=0
> sysctl -w kernel.sched_migration_cost_ns=50000
> # bind cpu
> export SGLANG_SET_CPU_AFFINITY=1
>
> unset https_proxy
> unset http_proxy
> unset HTTPS_PROXY
> unset HTTP_PROXY
> unset ASCEND_LAUNCH_BLOCKING
> # cann
> source /usr/local/Ascend/ascend-toolkit/set_env.sh
> source /usr/local/Ascend/nnal/atb/set_env.sh
>
> export STREAMS_PER_DEVICE=32
> export SGLANG_DISAGGREGATION_BOOTSTRAP_TIMEOUT=600
> # MTP OVERLAP
> export SGLANG_ENABLE_OVERLAP_PLAN_STREAM=1
> export SGLANG_NPU_USE_MULTI_STREAM=1
>
> export HCCL_BUFFSIZE=1000
> export HCCL_OP_EXPANSION_MODE=AIV
> export HCCL_SOCKET_IFNAME=lo
> export GLOO_SOCKET_IFNAME=lo
> # DEEPEP
> export DEEPEP_NORMAL_LONG_SEQ_ROUND=72
> export DEEPEP_NORMAL_LONG_SEQ_PER_ROUND_TOKENS=1024
> export DEEPEP_NORMAL_COMBINE_ENABLE_LONG_SEQ=1
> export DEEP_NORMAL_MODE_USE_INT8_QUANT=1
>
> MODEL_PATH=/path/to/model-weights
>
> python3 -m sglang.launch_server \
>         --model-path $MODEL_PATH \
>         --attention-backend ascend \
>         --device npu \
>         --tp-size 16 \
>         --chunked-prefill-size 16384 --max-prefill-tokens 280000 \
>         --trust-remote-code \
>         --host 127.0.0.1 \
>         --mem-fraction-static 0.7 \
>         --port 8000 \
>         --served-model-name glm-5 \
>         --cuda-graph-bs-decode 16 \
>         --quantization modelslim \
>         --speculative-draft-model-quantization unquant \
>         --speculative-algorithm NEXTN --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4  \
>         --moe-a2a-backend deepep --deepep-mode auto
> ```

> [tab] W4A8
>
> Use the `GLM-5.2-w4a8` checkpoint on one A3 Series node.
>
> ```shell theme={null}
> # ============================================================
> # Before running, update the following variables:
> #   MODEL_PATH: path to the model weights directory
> # ============================================================
>
> # high performance cpu
> echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
> sysctl -w vm.swappiness=0
> sysctl -w kernel.numa_balancing=0
> sysctl -w kernel.sched_migration_cost_ns=50000
> # bind cpu
> export SGLANG_SET_CPU_AFFINITY=1
>
> unset https_proxy
> unset http_proxy
> unset HTTPS_PROXY
> unset HTTP_PROXY
> unset ASCEND_LAUNCH_BLOCKING
> # cann
> source /usr/local/Ascend/ascend-toolkit/set_env.sh
> source /usr/local/Ascend/nnal/atb/set_env.sh
>
> export STREAMS_PER_DEVICE=32
> export SGLANG_ENABLE_SPEC_V2=1
> export SGLANG_ENABLE_OVERLAP_PLAN_STREAM=1
> export DEEPEP_HCCL_BUFFSIZE=1000
> export HCCL_OP_EXPANSION_MODE=AIV
> export HCCL_SOCKET_IFNAME=lo
> export GLOO_SOCKET_IFNAME=lo
> # DEEPEP
> export DEEPEP_NORMAL_LONG_SEQ_ROUND=72
> export DEEPEP_NORMAL_LONG_SEQ_PER_ROUND_TOKENS=1024
> export DEEPEP_NORMAL_COMBINE_ENABLE_LONG_SEQ=1
> export DEEP_NORMAL_MODE_USE_INT8_QUANT=1
> export SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK=16
> export DEEPEP_HYBRID_DEPLOYMENT=1
>
> MODEL_PATH=/path/to/model-weights
>
> python3 -m sglang.launch_server \
>         --model-path $MODEL_PATH \
>         --attention-backend ascend \
>         --device npu \
>         --tp-size 16 \
>         --disable-shared-experts-fusion \
>         --chunked-prefill-size 8192 \
>         --max-prefill-tokens 280000 \
>         --trust-remote-code \
>         --mem-fraction-static 0.78 \
>         --served-model-name GLM-5.2-w4a8 \
>         --max-running-requests 16 \
>         --cuda-graph-max-bs-decode 16 \
>         --quantization modelslim \
>         --moe-a2a-backend deepep --deepep-mode auto \
>         --speculative-algorithm NEXTN --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4 \
>         --load-balance-method round_robin \
>         --host 127.0.0.1 --port 8000
> ```

### Multi-node deployment

Quantized model `GLM-5.2-w8a8` can be deployed on two Ascend A3 Series nodes.

Modify the IP addresses of the two nodes, then run the same script on both nodes.

```shell theme={null}
# ============================================================
# Before running, update the following variables:
#   IPS: IP addresses of each node in the cluster
#   IP_MASTER: rank 0 node IP address with port
#   MODEL_PATH: path to the model weights directory
#   HCCL_SOCKET_IFNAME: network interface name for HCCL
#   GLOO_SOCKET_IFNAME: network interface name for Gloo
# ============================================================

echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
sysctl -w vm.swappiness=0
sysctl -w kernel.numa_balancing=0
sysctl -w kernel.sched_migration_cost_ns=50000
# bind cpu
export SGLANG_SET_CPU_AFFINITY=1

unset https_proxy
unset http_proxy
unset HTTPS_PROXY
unset HTTP_PROXY
unset ASCEND_LAUNCH_BLOCKING
# cann
source /usr/local/Ascend/ascend-toolkit/set_env.sh
source /usr/local/Ascend/nnal/atb/set_env.sh

export STREAMS_PER_DEVICE=32
export SGLANG_DISAGGREGATION_BOOTSTRAP_TIMEOUT=600
# MTP OVERLAP
export SGLANG_ENABLE_OVERLAP_PLAN_STREAM=1

export SGLANG_NPU_USE_MULTI_STREAM=1
export HCCL_BUFFSIZE=1000
export HCCL_OP_EXPANSION_MODE=AIV

# Run command ifconfig on two nodes, find out which inet addr has same IP with your node IP. That is your public interface, which should be added here
export HCCL_SOCKET_IFNAME=<network-interface>
export GLOO_SOCKET_IFNAME=<network-interface>

# DEEPEP
export DEEPEP_NORMAL_LONG_SEQ_ROUND=72
export DEEPEP_NORMAL_LONG_SEQ_PER_ROUND_TOKENS=1024
export DEEPEP_NORMAL_COMBINE_ENABLE_LONG_SEQ=1
export DEEP_NORMAL_MODE_USE_INT8_QUANT=1


IPS=('<your node1 ip>' '<your node2 ip>')
IP_MASTER="${IPS[0]}:5000"

MODEL_PATH=/path/to/model-weights

LOCAL_HOST1=`hostname -I|awk -F " " '{print$1}'`
LOCAL_HOST2=`hostname -I|awk -F " " '{print$2}'`
for i in "${!IPS[@]}";
do
    if [[ "$LOCAL_HOST1" == "${IPS[$i]}" || "$LOCAL_HOST2" == "${IPS[$i]}" ]];
    then
        echo "${IPS[$i]}"
        python3 -m sglang.launch_server \
        --model-path $MODEL_PATH \
        --attention-backend ascend \
        --device npu \
        --tp-size 32 --nnodes 2 --node-rank $i --dist-init-addr $IP_MASTER \
        --chunked-prefill-size 16384 --max-prefill-tokens 131072 \
        --trust-remote-code \
        --host 127.0.0.1 \
        --mem-fraction-static 0.8 \
        --port 8000 \
        --served-model-name glm-5 \
        --cuda-graph-max-bs-decode 32 \
        --moe-a2a-backend deepep \
        --deepep-mode auto \
        --speculative-draft-model-quantization unquant \
        --speculative-algorithm NEXTN --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4  \
        --disable-radix-cache
        NODE_RANK=$i
        break
    fi
done
```

### Prefill-decode disaggregation deployment

PD disaggregation splits the prefill and decode stages onto separate nodes, reducing interference and improving
throughput for high-concurrency scenarios.

```shell theme={null}
# ============================================================
# Before running, update the following variables:
#   ASCEND_MF_STORE_URL: prefill master IP address with port
#   P_IP: prefill node IP address
#   D_IP: decode node IP address
#   MODEL_PATH: path to the model weights directory
#   HCCL_SOCKET_IFNAME: network interface name for HCCL
#   GLOO_SOCKET_IFNAME: network interface name for Gloo
# ============================================================

echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
sysctl -w vm.swappiness=0
sysctl -w kernel.numa_balancing=0
sysctl -w kernel.sched_migration_cost_ns=50000

export SGLANG_SET_CPU_AFFINITY=1

unset https_proxy
unset http_proxy
unset HTTPS_PROXY
unset HTTP_PROXY
unset ASCEND_LAUNCH_BLOCKING
source /usr/local/Ascend/ascend-toolkit/set_env.sh
source /usr/local/Ascend/nnal/atb/set_env.sh

export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True
export STREAMS_PER_DEVICE=32
# pd transfer, prefill master IP
export ASCEND_MF_STORE_URL="tcp://<your prefill ip>:24707"
export SGLANG_DISAGGREGATION_BOOTSTRAP_TIMEOUT=600

P_IP=('<your prefill ip>')
D_IP=('<your decode ip>')

MODEL_PATH=/path/to/model-weights

export TRANSFORMERS_VERBOSITY=error

LOCAL_HOST1=`hostname -I|awk -F " " '{print$1}'`
LOCAL_HOST2=`hostname -I|awk -F " " '{print$2}'`
echo "${LOCAL_HOST1}"
echo "${LOCAL_HOST2}"

# prefill
for i in "${!P_IP[@]}";
do
    if [[ "$LOCAL_HOST1" == "${P_IP[$i]}" || "$LOCAL_HOST2" == "${P_IP[$i]}" ]];
    then
        echo "${P_IP[$i]}"
        export DEEPEP_NORMAL_LONG_SEQ_ROUND=72
        export DEEPEP_NORMAL_LONG_SEQ_PER_ROUND_TOKENS=1024
        export DEEPEP_NORMAL_COMBINE_ENABLE_LONG_SEQ=1
        export DEEP_NORMAL_MODE_USE_INT8_QUANT=1
        export TASK_QUEUE_ENABLE=2
        export HCCL_SOCKET_IFNAME=<network-interface>
        export GLOO_SOCKET_IFNAME=<network-interface>

        # prefill node
        python -m sglang.launch_server --model-path ${MODEL_PATH}  --disaggregation-mode prefill --host ${P_IP[$i]} \
        --port 8000 --disaggregation-bootstrap-port 8998 --trust-remote-code --nnodes 1 --node-rank $i \
        --tp-size 16 --mem-fraction-static 0.8 --attention-backend ascend --device npu --quantization modelslim \
        --disaggregation-transfer-backend ascend --max-running-requests 64 \
        --served-model-name glm-5 --chunked-prefill-size 524288 --max-prefill-tokens 180000 --moe-a2a-backend deepep --deepep-mode normal \
        --disable-shared-experts-fusion --disable-cuda-graph --dtype bfloat16 \
        --dp-size 4 --enable-dp-attention \
        --load-balance-method round_robin \
        --enable-dp-lm-head --moe-dense-tp 1 \
        --speculative-draft-model-quantization unquant \
        --speculative-algorithm NEXTN --speculative-num-steps 1 --speculative-eagle-topk 1 --speculative-num-draft-tokens 2

        # cp
        #--enable-prefill-cp \
        #--cp-strategy zigzag \
        #--attn-cp-size 4 \
        NODE_RANK=$i
        break
    fi
done

# decode
for i in "${!D_IP[@]}";
do
    if [[ "$LOCAL_HOST1" == "${D_IP[$i]}" || "$LOCAL_HOST2" == "${D_IP[$i]}" ]];
    then
        echo "${D_IP[$i]}"

        export SGLANG_ENABLE_OVERLAP_PLAN_STREAM=1
        export HCCL_BUFFSIZE=650

        export SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK=32
        export TASK_QUEUE_ENABLE=0

        export HCCL_SOCKET_IFNAME=<network-interface>
        export GLOO_SOCKET_IFNAME=<network-interface>

        export SGLANG_NPU_USE_MULTI_STREAM=1

        python -m sglang.launch_server --model-path ${MODEL_PATH} --disaggregation-mode decode --host ${D_IP[$i]} \
        --port 8003 --trust-remote-code --nnodes 1 --node-rank $i --tp-size 16 --dp-size 16 --enable-dp-attention --ep-size 16 \
        --mem-fraction-static 0.8 --max-running-requests 128 --attention-backend ascend --device npu --quantization modelslim \
        --served-model-name glm-5 --moe-a2a-backend deepep --deepep-mode low_latency \
        --cuda-graph-max-bs-decode 4 --disaggregation-transfer-backend ascend --watchdog-timeout 9000 --context-length 180000 \
        --tokenizer-worker-num 4 --disable-shared-experts-fusion --dtype bfloat16  --load-balance-method round_robin \
        --speculative-draft-model-quantization unquant \
        --speculative-algorithm NEXTN --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4
        NODE_RANK=$i
        break
    fi
done
```

Launch the router after the prefill and decode services are ready.

```shell theme={null}
# ============================================================
# Before running, update the following variables:
#   P_MASTER_IP: prefill master IP address
#   D_MASTER_IP: decode master IP address
#   ROUTER_HOST_IP: router node IP address
# ============================================================

P_MASTER_IP="<your prefill ip>"
D_MASTER_IP="<your decode ip>"
ROUTER_HOST_IP="<your router ip>"

python3 -m sglang_router.launch_router \
--pd-disaggregation \
--policy round_robin \
--prefill http://${P_MASTER_IP}:8000 8998 \
--decode http://${D_MASTER_IP}:8003 \
--host ${ROUTER_HOST_IP} \
--port 6688
```

## Functional verification

After the service is started, you can invoke the model by sending a prompt:

```shell theme={null}
# ============================================================
# Before running, update the following variables:
#   HOST: the server host address (e.g., localhost)
#   PORT: the server port number (e.g., 8000)
# ============================================================

curl http://${HOST}:${PORT}/generate \
    -H "Content-Type: application/json" \
    -d '{
        "text": "What is the capital of France?",
        "sampling_params": {
            "max_new_tokens": 64,
            "temperature": 0
        }
    }'
```

Expected result: an HTTP 200 response with the generated text containing "Paris".

Once the server prints `The server is fired up and ready to roll!` in the logs, it is ready to accept requests. For more
testing examples (Health Check, Generate, Chat Completions, and port usage guidance),
see [Testing the Service](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/getting-started/installation.md#testing-the-service).

## Accuracy evaluation

For accuracy evaluation methods and datasets, see [Accuracy Evaluation on Ascend NPU](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/evaluation/accuracy_evaluation.md).

## Performance

For performance data and benchmark commands, see [Performance Testing on Ascend NPU](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/evaluation/performance_testing.md).

## Best practices

### Best practice configuration reference

For complete optimal configurations with deployment scripts and benchmark commands, see the
[GLM-5.2 Best Practice](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/model-deployment/best-practices/glm_5_2.md) page.

## Performance tuning

For the full list of supported features, see [Supported features](#supported-features). For detailed optimization
guidance, see [Optimization on Ascend NPU](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/optimization/parameter_tuning.md).

## FAQ

For common environment, installation, and general parameter issues, please refer to the [Ascend NPU FAQ](https://docs.sglang.io/docs/hardware-platforms/ascend-npus/faq.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.