GLM-5.2

GLM-5.2

GLM-5.2는 Tsinghua 대학 KEG 연구실과 Zhipu AI가 공동 개발한 GLM(General Language Model) 시리즈의 대규모 언어 모델이에요. 이 문서는 Ascend NPU에서 SGLang으로 GLM-5.2를 배포하는 방법을 안내합니다.

출처: 문서

본문

소개 (Introduction)

GLM-5.2는 Tsinghua 대학 KEG 연구실(Key Laboratory)과 Zhipu AI가 공동 개발한 GLM(General Language Model) 시리즈의 대규모 언어 모델이에요. GLM-5.2는 DeepSeek Sparse Attention(DSA)과 다중 토큰 예측(MTP, Multi-token Prediction)을 포함한 DeepSeek-V3/V3.2 아키텍처를 채택하며, Ascend NPU에서 SGLang으로 고처리량 추론을 지원합니다.

이 문서는 SGLang을 사용하여 Ascend NPU에서 GLM-5.2를 배포하는 방법을 보여줘요. 단일 노드 배포, 다중 노드 배포, prefill-decode disaggregation, 기능 구성, 성능 최적화를 포함합니다.

지원 기능 (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 디바이스 메모리에 따라 자동 설정, 또는 명시적 값 설정;
--chunked-prefill-size -1로 비활성화; 예: --chunked-prefill-size 16384
NPU Graph 기본 활성화됨; --disable-cuda-graph로 비활성화;
범위는 --cuda-graph-bs-decode 또는 --cuda-graph-max-bs-decode로 제어; 예: --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

Example usage 열의 값은 설명을 위한 예시일 뿐이에요. 하드웨어, 배포 모드, 워크로드에 맞게 조정하세요. 파라미터 세부 사항은 기능 설명을, 각 배포 시나리오의 권장 구성은 모범 사례를 참고하세요.

기능 간 호환성과 충돌 정보는 기능 호환성 (Feature Compatibility)을 참고하세요.

사전 요구사항 (Prerequisites)

환경 (Environment)

이 튜토리얼을 따르기 전에 아래 문서에서 환경 설정을 완료하세요:

  • Ascend NPU 퀵스타트 — 가장 빠르게 시작하는 방법이에요. 공식 컨테이너 이미지 실행, SGLang 서버 시작, 테스트 요청 전송을 안내합니다. Ascend에서 SGLang이 처음이라면 추천해요.
  • NPU 지원 SGLang 설치 — 전체 설치 가이드예요. 컴포넌트 버전 매핑(CANN, TorchNPU, Triton, kernels 등), 소스 또는 Dockerfile에서 빌드, 권장 시스템 설정(CPU 전원 구성, NUMA, swap)을 다룹니다. 공식 이미지 대신 설치하거나 커스터마이즈해야 할 때 사용하세요.

모델 가중치 (Model weights)

모델 가중치를 다운로드하기 전에 모델 크기를 확인해서 충분한 디스크 공간을 확보하세요. 다중 노드 배포 시에는 모든 노드가 접근 가능한 공유 디렉터리에 가중치를 다운로드하세요.

  • GLM-5.2 (BF16, 1.51TB)
  • GLM-5.2-w8a8 (MTP 없는 양자화 버전, 774.08GB)
  • msmodelslim을 사용해 모델을 나이브하게 양자화할 수 있어요.

자원 사용량을 줄이고 처리량을 높이려면 W8A8 변형 배포를 권장해요. W8A8(774.08GB)은 16 × 64GB 디바이스 메모리(--tp-size 16)에 배포할 수 있어요. 이는 A3 시리즈 전체 1노드(8장 카드, 16개 die) 또는 A2 시리즈 2노드에 해당합니다.

이는 최소 권장 구성이에요. 최적화된 구성은 모범 사례를 확인하세요. 추가 카드나 노드가 필요할 수 있어요.

하드웨어 사양(카드당 die당 메모리, 사이즈, A2 시리즈와 A3 시리즈의 차이)은 Ascend NPU 참조 — 하드웨어를 확인하세요.

설치 (Installation)

NPU 런타임 환경에 필요한 종속성은 Docker 이미지에 통합되어 온라인 플랫폼에 업로드되어 있어서, 바로 pull할 수 있어요. GLM-5.2-w8a8 양자화 모델은 하나의 Ascend A3 시리즈 노드에 배포할 수 있어요.

Ascend A3 시리즈:

docker pull quay.io/ascend/sglang:cann9.0.0-a3-v0.5.16

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 \
quay.io/ascend/sglang:cann9.0.0-a3-v0.5.16

Ascend A2 시리즈:

docker pull quay.io/ascend/sglang:cann9.0.0-910b-v0.5.16

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/davinci_manager:/dev/davinci_manager \
--device=/dev/hisi_hdc:/dev/hisi_hdc \
--entrypoint=bash \
quay.io/ascend/sglang:cann9.0.0-910b-v0.5.16
  • 모델 가중치가 이미 공유 디렉터리에 다운로드되어 있다면 -v로 모델 경로를 컨테이너에 마운트하세요. 예: -v /path/to/models:/models.
  • ${NAME}을 자신의 컨테이너 이름으로 바꾸거나, --name을 제거해서 기본 이름을 사용하세요.

온라인 서비스 배포 (Online service deployment)

단일 노드 배포 (Single-node deployment)

양자화 모델 GLM-5.2-w8a8은 하나의 Ascend A3 시리즈 노드에 배포할 수 있어요. 온라인 추론을 실행하려면 다음 스크립트를 실행하세요.

# ============================================================
# 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 --nnodes 1 --node-rank 0 \
        --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

다중 노드 배포 (Multi-node deployment)

양자화 모델 GLM-5.2-w8a8은 두 개의 Ascend A3 시리즈 노드에 배포할 수 있어요. 두 노드의 IP 주소를 수정한 뒤 양쪽 노드에서 같은 스크립트를 실행하세요.

기능 검증 (Functional verification)

서비스가 시작된 후 prompt를 보내서 모델을 호출할 수 있어요:

# ============================================================
# 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
        }
    }'

기대 결과: "Paris"를 포함한 생성 텍스트가 들어있는 HTTP 200 응답이에요.

서버가 로그에 The server is fired up and ready to roll!를 출력하면 요청을 받을 준비가 된 거예요. 더 많은 테스트 예시(Health Check, Generate, Chat Completions, 포트 사용 안내)는 서비스 테스트를 참고하세요.

정확도 평가 (Accuracy evaluation)

정확도 평가 방법과 데이터셋은 Ascend NPU에서 정확도 평가를 참고하세요.

성능 (Performance)

성능 데이터와 벤치마크 명령은 Ascend NPU에서 성능 테스트를 참고하세요.

모범 사례 (Best practices)

모범 사례 구성 참조 (Best practice configuration reference)

GLM-5.2는 아직 튜닝 파라미터가 확정되지 않아 별도의 모범 사례 페이지가 없어요. 대신 위의 온라인 서비스 배포 섹션이 단일 노드, 다중 노드, PD disaggregation에 사용할 수 있는 스크립트를 제공하며, 각각 권장 기능 조합과 튜닝 파라미터(예: DeepEP 모드, speculative decoding, overlap schedule)를 내장하고 있습니다. 최적화 기능 전체 목록과 파라미터·호환성 세부 사항은 Ascend NPU 최적화를 참고하세요.

성능 튜닝 (Performance tuning)

지원되는 기능의 전체 목록은 지원 기능을, 자세한 최적화 안내는 Ascend NPU 최적화를 참고하세요.

FAQ

일반적인 환경, 설치, 파라미터 문제는 Ascend NPU FAQ를 참고하세요.

더 알아보기 (Learn more)