Skip to content

Commit 5354dff

Browse files
committed
Merge PR MUSA S5000 support into dev-zyh
# Conflicts: # .github/configs/platforms.yml # .github/workflows/ci.yml # docker/build.sh
2 parents d7aa39b + 2fbfdda commit 5354dff

11 files changed

Lines changed: 350 additions & 2 deletions

File tree

.github/configs/musa.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2026 FlagOS Contributors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# MUSA Hardware Configuration
16+
# This file defines CI/CD settings for MUSA testing.
17+
18+
platform: musa
19+
20+
ci_image: harbor.baai.ac.cn/flagos-dev/vllm-plugin-fl:29ceebd-musa-ci
21+
22+
runner_labels:
23+
- mt-cicd-vllm-plugin
24+
25+
container_volumes:
26+
- /data:/data
27+
28+
container_options: >-
29+
--hostname vllm-plugin-fl
30+
--privileged
31+
--ipc=host
32+
--shm-size=64g
33+
--env GEMS_VENDOR=mthreads
34+
--env VLLM_PLUGINS=fl
35+
--env MTHREADS_VISIBLE_DEVICES=all

.github/configs/platforms.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ platforms:
2828
enabled: true
2929
metax:
3030
enabled: true
31+
musa:
32+
enabled: true

.github/scripts/musa/check.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# Copyright (c) 2026 BAAI. All rights reserved.
3+
# Check Moore Threads MUSA availability.
4+
set -euo pipefail
5+
6+
echo "Current time: $(date '+%Y-%m-%d %H:%M:%S')"
7+
echo "=== Checking Moore Threads MUSA availability ==="
8+
9+
if command -v mthreads-gmi >/dev/null 2>&1; then
10+
mthreads-gmi
11+
else
12+
echo "::warning::mthreads-gmi not found; checking through torch_musa."
13+
fi
14+
15+
python - <<'PY'
16+
import torch
17+
import torch_musa
18+
19+
assert torch.musa.is_available(), "MUSA accelerator is unavailable"
20+
count = torch.musa.device_count()
21+
assert count > 0, "No MUSA devices detected"
22+
23+
tensor = torch.ones((32, 32), device="musa:0")
24+
torch.musa.synchronize()
25+
26+
print(f"MUSA devices: {count}")
27+
print(f"Tensor smoke: {tensor.device} {tuple(tensor.shape)}")
28+
PY

.github/scripts/musa/setup.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# Copyright (c) 2026 BAAI. All rights reserved.
3+
# Setup script for Moore Threads MUSA CI environment.
4+
set -euo pipefail
5+
6+
git config --global --add safe.directory "$(pwd)"
7+
8+
: "${GEMS_VENDOR:?GEMS_VENDOR is not set}"
9+
: "${VLLM_PLUGINS:?VLLM_PLUGINS is not set}"
10+
: "${MTHREADS_VISIBLE_DEVICES:?MTHREADS_VISIBLE_DEVICES is not set}"
11+
12+
python -m pip install --no-build-isolation --no-deps -e .
13+
14+
python - <<'PY'
15+
import flag_gems
16+
import torch
17+
import torch_musa
18+
import vllm
19+
import vllm_fl
20+
from vllm.platforms import current_platform
21+
22+
assert torch.musa.is_available(), "MUSA accelerator is unavailable"
23+
assert torch.musa.device_count() > 0, "No MUSA devices detected"
24+
assert current_platform.device_type == "musa", current_platform.device_type
25+
26+
print(f"vLLM import ok: {vllm.__version__}")
27+
print(f"vLLM-FL import ok: {vllm_fl.__file__}")
28+
print(f"FlagGems import ok: {getattr(flag_gems, '__version__', 'unknown')}")
29+
print(f"Torch import ok: {torch.__version__}")
30+
print(f"MUSA available: {torch.musa.is_available()}")
31+
print(f"MUSA devices: {torch.musa.device_count()}")
32+
print(f"Platform: {current_platform}")
33+
PY

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,14 @@ jobs:
144144
with:
145145
platform: metax
146146
secrets: inherit
147+
148+
# ============================================================
149+
# Job 4e: MUSA platform testing
150+
# ============================================================
151+
test-musa:
152+
needs: discover
153+
if: contains(fromJson(needs.discover.outputs.platforms), 'musa')
154+
uses: ./.github/workflows/_platform_test.yml
155+
with:
156+
platform: musa
157+
secrets: inherit

docker/build.sh

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ UBUNTU_VERSION="${UBUNTU_VERSION:-22.04}"
3030
VLLM_VERSION="${VLLM_VERSION:-0.19.0}"
3131
CANN_VERSION="${CANN_VERSION:-8.5.1}"
3232
CANN_CHIP="${CANN_CHIP:-910b}"
33+
MUSA_BASE_IMAGE="${MUSA_BASE_IMAGE:-registry.mthreads.com/mcconline/inference/vllm:v0.20.2-ph1-4.3.5-torch2.7.1-v1.1.0}"
34+
MUSA_VERSION="${MUSA_VERSION:-4.3.5}"
35+
MUSA_VLLM_VERSION="${MUSA_VLLM_VERSION:-0.20.2}"
36+
MUSA_PYTHON_VERSION="${MUSA_PYTHON_VERSION:-3.10}"
37+
MUSA_TORCH_VERSION="${MUSA_TORCH_VERSION:-2.7.1}"
38+
MUSA_FLAGGEMS_VERSION="${MUSA_FLAGGEMS_VERSION:-5.0.0}"
3339
HYGON_BASE_IMAGE="${HYGON_BASE_IMAGE:-harbor.sourcefind.cn:5443/dcu/admin/base/custom:vllm0.20.0-ubuntu22.04-dtk26.04-py3.10-MiniCPM-V-4.6}"
3440
HYGON_VLLM_VERSION="${HYGON_VLLM_VERSION:-0.20.2}"
3541
HYGON_DTK_VERSION="${HYGON_DTK_VERSION:-26.04}"
@@ -141,7 +147,7 @@ Usage: $(basename "$0") [OPTIONS]
141147
Build the vllm-plugin-FL Docker image.
142148
143149
OPTIONS:
144-
--platform PLATFORM Platform to build: cuda, ascend, hygon, metax (default: ${PLATFORM})
150+
--platform PLATFORM Platform to build: cuda, ascend, hygon, metax, musa (default: ${PLATFORM})
145151
--target TARGET Build target: dev, ci, release (default: ${TARGET})
146152
--image-name NAME Image name (default: ${IMAGE_NAME})
147153
--image-tag TAG Image tag (default: auto-generated)
@@ -161,6 +167,13 @@ VERSIONS (override via environment variables):
161167
Ascend:
162168
CANN_VERSION CANN version (default: ${CANN_VERSION})
163169
CANN_CHIP CANN chip: 910b, a3 (default: ${CANN_CHIP})
170+
MUSA:
171+
MUSA_BASE_IMAGE Moore Threads base image (default: ${MUSA_BASE_IMAGE})
172+
MUSA_VERSION MUSA version used in image tag (default: ${MUSA_VERSION})
173+
MUSA_VLLM_VERSION vLLM empty-mode version (default: ${MUSA_VLLM_VERSION})
174+
MUSA_PYTHON_VERSION Python version in base image (default: ${MUSA_PYTHON_VERSION})
175+
MUSA_TORCH_VERSION PyTorch version in base image (default: ${MUSA_TORCH_VERSION})
176+
MUSA_FLAGGEMS_VERSION FlagGems version in base image (default: ${MUSA_FLAGGEMS_VERSION})
164177
Hygon:
165178
HYGON_BASE_IMAGE Base image (default: ${HYGON_BASE_IMAGE})
166179
HYGON_VLLM_VERSION vLLM version installed in empty mode (default: ${HYGON_VLLM_VERSION})
@@ -193,6 +206,9 @@ EXAMPLES:
193206
# Build MetaX CI image
194207
./build.sh --platform metax --target ci --image-name harbor.baai.ac.cn/flagos-dev/vllm-plugin-fl
195208
209+
# Build Moore Threads MUSA dev image
210+
./build.sh --platform musa --target dev
211+
196212
# Build with custom PyPI mirror
197213
./build.sh --target dev --index-url https://pypi.tuna.tsinghua.edu.cn/simple
198214
@@ -310,8 +326,18 @@ elif [[ "${PLATFORM}" == "metax" ]]; then
310326
if [[ -z "${IMAGE_TAG}" ]]; then
311327
IMAGE_TAG="vllm-metax-${METAX_VLLM_VERSION}-maca.ai${METAX_MACA_VERSION}-torch2.8-${METAX_PYTHON_TAG}-ubuntu22.04-amd64-ci-git"
312328
fi
329+
elif [[ "${PLATFORM}" == "musa" ]]; then
330+
PYTHON_VERSION="${MUSA_PYTHON_VERSION}"
331+
VLLM_VERSION="${MUSA_VLLM_VERSION}"
332+
BUILD_ARGS+=(
333+
--build-arg "MUSA_BASE_IMAGE=${MUSA_BASE_IMAGE}"
334+
--build-arg "FLAGGEMS_VERSION=${MUSA_FLAGGEMS_VERSION}"
335+
)
336+
if [[ -z "${IMAGE_TAG}" ]]; then
337+
IMAGE_TAG="musa${MUSA_VERSION}-vllm${VLLM_VERSION}-torch${MUSA_TORCH_VERSION}-py${MUSA_PYTHON_VERSION}-${TARGET}"
338+
fi
313339
else
314-
err "Unknown platform '${PLATFORM}'. Must be 'cuda', 'ascend', 'hygon', or 'metax'."
340+
err "Unknown platform '${PLATFORM}'. Must be 'cuda', 'ascend', 'hygon', 'metax', or 'musa'."
315341
fi
316342

317343
FULL_IMAGE="${IMAGE_NAME}:${IMAGE_TAG}"
@@ -335,6 +361,11 @@ elif [[ "${PLATFORM}" == "metax" ]]; then
335361
msg " MACA: ${METAX_MACA_VERSION}"
336362
msg " MetaX Python: ${METAX_PYTHON_VERSION}"
337363
msg " Base image: ${METAX_BASE_IMAGE}"
364+
elif [[ "${PLATFORM}" == "musa" ]]; then
365+
msg " MUSA: ${MUSA_VERSION}"
366+
msg " MUSA base: ${MUSA_BASE_IMAGE}"
367+
msg " MUSA PyTorch: ${MUSA_TORCH_VERSION}"
368+
msg " FlagGems: ${MUSA_FLAGGEMS_VERSION}"
338369
fi
339370
msg " Ubuntu: ${UBUNTU_VERSION}"
340371
msg " Python: ${PYTHON_VERSION}"

docker/musa/Dockerfile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
ARG MUSA_BASE_IMAGE=registry.mthreads.com/mcconline/inference/vllm:v0.20.2-ph1-4.3.5-torch2.7.1-v1.1.0
2+
3+
# ---------- base stage ----------
4+
FROM ${MUSA_BASE_IMAGE} AS base
5+
6+
ARG PYTHON_VERSION=3.10
7+
ARG VLLM_VERSION=0.20.2
8+
ARG FLAGGEMS_VERSION=5.0.0
9+
10+
ENV DEBIAN_FRONTEND=noninteractive \
11+
VLLM_PLUGINS=fl
12+
13+
# Keep the vendor runtime from the base image and add only the tools required
14+
# to build the checked-out plugin in CI.
15+
RUN apt-get update \
16+
&& apt-get install -y --no-install-recommends \
17+
build-essential \
18+
ca-certificates \
19+
curl \
20+
git \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
RUN python -m pip install --no-cache-dir \
24+
"setuptools>=77.0.3,<81.0.0" \
25+
wheel \
26+
setuptools-scm \
27+
scikit-build-core==0.11 \
28+
pybind11 \
29+
ninja \
30+
cmake
31+
32+
# Fail early when a different vendor base image is supplied accidentally.
33+
RUN python -c 'from importlib.metadata import version; \
34+
vllm = version("vllm"); \
35+
flag_gems = version("flag-gems"); \
36+
assert "empty" in vllm, vllm; \
37+
assert flag_gems == "5.0.0", flag_gems; \
38+
print("vLLM:", vllm); \
39+
print("FlagGems:", flag_gems)'
40+
41+
WORKDIR /workspace
42+
43+
# ---------- dev stage ----------
44+
FROM base AS dev
45+
46+
RUN python -m pip install --no-cache-dir \
47+
pytest==8.4.1 \
48+
pytest-cov \
49+
pytest-json-report \
50+
ruff \
51+
pre-commit
52+
53+
WORKDIR /workspace
54+
55+
# ---------- ci stage ----------
56+
FROM dev AS ci
57+
58+
RUN python -m pip install --no-cache-dir \
59+
pytest-timeout \
60+
pytest-metadata
61+
62+
WORKDIR /workspace
63+
64+
# ---------- release stage ----------
65+
FROM base AS release
66+
67+
WORKDIR /workspace
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Qwen3-4B model configuration (TP=2)
2+
3+
llm:
4+
model: "/data/models/Qwen/Qwen3-4B"
5+
tensor_parallel_size: 2
6+
max_model_len: 1024
7+
gpu_memory_utilization: 0.8
8+
trust_remote_code: true
9+
enforce_eager: true
10+
disable_custom_all_reduce: true
11+
12+
generate:
13+
prompts:
14+
- "Hello, my name is"
15+
- "The capital of France is"
16+
sampling:
17+
max_tokens: 10
18+
temperature: 0.7
19+
20+
serve:
21+
served_model_name: "qwen"
22+
endpoints: ["chat"]
23+
stream: true
24+
max_tokens: 256
25+
chat_messages:
26+
- role: "user"
27+
content: "Give me a short introduction to large language models."
28+
sampling:
29+
temperature: 0.7
30+
top_p: 0.8
31+
presence_penalty: 1.5
32+
extra_body:
33+
top_k: 20
34+
chat_template_kwargs:
35+
enable_thinking: false
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Qwen3.6-27B MUSA smoke configuration (TP=4, eager).
2+
3+
llm:
4+
model: "/data/models/Qwen/Qwen3.6-27B"
5+
tensor_parallel_size: 4
6+
pipeline_parallel_size: 1
7+
max_model_len: 8192
8+
gpu_memory_utilization: 0.90
9+
enforce_eager: true
10+
enable_prefix_caching: false
11+
trust_remote_code: false
12+
disable_custom_all_reduce: true
13+
14+
generate:
15+
prompts:
16+
- "介绍一下北京"
17+
sampling:
18+
max_tokens: 100
19+
temperature: 0.0
20+
21+
serve:
22+
served_model_name: "qwen"
23+
startup_retries: 120
24+
endpoints: ["chat"]
25+
stream: false
26+
max_tokens: 256
27+
chat_messages:
28+
- role: "user"
29+
content: "介绍一下北京"
30+
sampling:
31+
temperature: 0.7
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Qwen3.6-35B-A3B MUSA smoke configuration (TP=4, eager).
2+
3+
llm:
4+
model: "/data/models/Qwen/Qwen3.6-35B-A3B"
5+
tensor_parallel_size: 4
6+
pipeline_parallel_size: 1
7+
max_model_len: 8192
8+
gpu_memory_utilization: 0.90
9+
enforce_eager: true
10+
enable_prefix_caching: false
11+
trust_remote_code: false
12+
disable_custom_all_reduce: true
13+
14+
generate:
15+
prompts:
16+
- "介绍一下北京"
17+
sampling:
18+
max_tokens: 100
19+
temperature: 0.0
20+
21+
serve:
22+
served_model_name: "qwen"
23+
startup_retries: 120
24+
endpoints: ["chat"]
25+
stream: false
26+
max_tokens: 256
27+
chat_messages:
28+
- role: "user"
29+
content: "介绍一下北京"
30+
sampling:
31+
temperature: 0.7

0 commit comments

Comments
 (0)