MindSpore 모델

MindSpore 모델 (MindSpore Models)

이 페이지는 SGLang에서 MindSpore 모델을 실행하는 방법을 설명해요. MindSpore는 Ascend NPU에 최적화된 고성능 AI 프레임워크예요. 현재 Qwen3(밀집 및 MoE), DeepSeek V3/R1 모델을 지원해요.

출처: 문서

본문

소개 (Introduction)

MindSpore는 Ascend NPU에 최적화된 고성능 AI 프레임워크예요. 이 문서는 SGLang에서 MindSpore 모델을 실행하는 방법을 안내해요.

요구 사항 (Requirements)

MindSpore는 현재 Ascend NPU 디바이스만 지원해요. 사용자는 먼저 Ascend CANN 8.5를 설치해야 해요. CANN 소프트웨어 패키지는 Ascend 공식 웹사이트에서 다운로드할 수 있어요.

지원 모델 (Supported Models)

현재 다음 모델이 지원돼요:

  • Qwen3: 밀집 및 MoE 모델
  • DeepSeek V3/R1
  • 더 많은 모델 곧 제공 예정...

설치 (Installation)

Note: 현재 MindSpore 모델은 독립 패키지 sgl-mindspore로 제공돼요. MindSpore 지원은 현재 SGLang의 Ascend NPU 플랫폼 지원을 기반으로 구축됐어요. 먼저 SGLang for Ascend NPU를 설치한 다음 sgl-mindspore를 설치하세요:

git clone https://github.com/mindspore-lab/sgl-mindspore.git
cd sgl-mindspore
pip install -e .

모델 실행 (Run Model)

현재 SGLang-MindSpore는 Qwen3와 DeepSeek V3/R1 모델을 지원해요. 이 문서는 Qwen3-8B를 예시로 사용해요.

오프라인 추론 (Offline inference)

오프라인 추론에는 다음 스크립트를 사용해요:

import sglang as sgl

# Initialize the engine with MindSpore backend
llm = sgl.Engine(
    model_path="/path/to/your/model",  # Local model path
    device="npu",                      # Use NPU device
    model_impl="mindspore",            # MindSpore implementation
    attention_backend="ascend",        # Attention backend
    tp_size=1,                         # Tensor parallelism size
    dp_size=1                          # Data parallelism size
)

# Generate text
prompts = [
    "Hello, my name is",
    "The capital of France is",
    "The future of AI is"
]

sampling_params = {"temperature": 0, "top_p": 0.9}
outputs = llm.generate(prompts, sampling_params)

for prompt, output in zip(prompts, outputs):
    print(f"Prompt: {prompt}")
    print(f"Generated: {output['text']}")
    print("---")

서버 시작 (Start server)

MindSpore 백엔드로 서버 실행:

# Basic server startup
python3 -m sglang.launch_server \
    --model-path /path/to/your/model \
    --host 0.0.0.0 \
    --device npu \
    --model-impl mindspore \
    --attention-backend ascend \
    --tp-size 1 \
    --dp-size 1

여러 노드의 분산 서버:

# Multi-node distributed server
python3 -m sglang.launch_server \
    --model-path /path/to/your/model \
    --host 0.0.0.0 \
    --device npu \
    --model-impl mindspore \
    --attention-backend ascend \
    --dist-init-addr 127.0.0.1:29500 \
    --nnodes 2 \
    --node-rank 0 \
    --tp-size 4 \
    --dp-size 2

문제 해결 (Troubleshooting)

디버그 모드 (Debug Mode)

log-level 인자로 sglang 디버그 로깅을 활성화해요.

python3 -m sglang.launch_server \
    --model-path /path/to/your/model \
    --host 0.0.0.0 \
    --device npu \
    --model-impl mindspore \
    --attention-backend ascend \
    --log-level DEBUG

환경 변수 설정으로 mindspore info 및 디버그 로깅 활성화:

export GLOG_v=1  # INFO
export GLOG_v=0  # DEBUG

디바이스 명시적 선택 (Explicitly select devices)

다음 환경 변수로 사용할 디바이스를 명시적으로 선택해요.

export ASCEND_RT_VISIBLE_DEVICES=4,5,6,7  # to set device

일부 통신 환경 문제 (Some communication environment issues)

특수한 통신 환경의 경우 일부 환경 변수를 설정해야 해요.

export MS_ENABLE_LCCL=off # current not support LCCL communication mode in SGLang-MindSpore

일부 protobuf 의존성 (Some dependencies of protobuf)

특수한 protobuf 버전의 환경에서는 바이너리 버전 불일치를 피하기 위해 일부 환경 변수를 설정해야 해요.

export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python  # to avoid protobuf binary version mismatch

지원 (Support)

MindSpore 특정 문제의 경우:

더 알아보기