MindSpore 백엔드

MindSpore 백엔드 (Mindspore backend)

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

출처: 문서

본문

소개 (Introduction)

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

요구 사항 (Requirements)

MindSpore는 현재 Ascend NPU 장치만 지원해요. 사용자는 먼저 Ascend CANN 소프트웨어 패키지를 설치해야 합니다. CANN 소프트웨어 패키지는 Ascend 공식 웹사이트에서 다운로드할 수 있고, 권장 버전은 8.3.RC2예요.

지원 모델 (Supported Models)

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

  • Qwen3: Dense 및 MoE 모델
  • DeepSeek V3/R1
  • 더 많은 모델이 곧 추가될 예정...

설치 (Installation)

현재 MindSpore 모델은 독립 패키지 `sgl-mindspore`로 제공돼요. MindSpore 지원은 현재 SGLang의 Ascend NPU 플랫폼 지원 위에 구축되어 있어요. 먼저 [Ascend NPU용 SGLang 설치](./getting-started/installation)를 한 뒤 `sgl-mindspore`를 설치하세요: ```shell Install theme={null} 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)

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

```python Offline Inference theme={null} 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("---")

</CodeGroup>

### 서버 시작하기 (Start server)

MindSpore 백엔드로 서버를 실행해요:

<CodeGroup>
```bash Launch Server theme={null}
# 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

여러 노드의 분산 서버라면:

```bash Multi-node Distributed theme={null} # 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 디버그 로깅을 활성화하세요.

```bash Debug Mode theme={null} 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와 debug 로깅을 활성화하세요.

```bash Set Log Level theme={null} export GLOG_v=1 # INFO export GLOG_v=0 # DEBUG ```

장치 명시적으로 선택하기

다음 환경 변수로 사용할 장치를 명시적으로 선택하세요.

```shell Select Devices theme={null} export ASCEND_RT_VISIBLE_DEVICES=4,5,6,7 # to set device ```

일부 통신 환경 문제

특수한 통신 환경에서는 사용자가 일부 환경 변수를 설정해야 해요.

```shell Disable LCCL theme={null} export MS_ENABLE_LCCL=off # current not support LCCL communication mode in SGLang-MindSpore ```

protobuf 의존성 문제

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

```shell Fix Protobuf theme={null} export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python # to avoid protobuf binary version mismatch ```

지원 (Support)

MindSpore 관련 문제가 있다면:

더 알아보기 (Learn more)