Skip to content

Commit 0af6ea3

Browse files
Merge branch 'flagos-ai:main' into gcu_fix
2 parents 74031c7 + fa3e117 commit 0af6ea3

32 files changed

Lines changed: 1580 additions & 7 deletions

.github/configs/metax.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
# MetaX Hardware Configuration
16+
# This file defines CI/CD settings for MetaX C550 testing
17+
18+
platform: metax
19+
20+
# Docker image for this hardware.
21+
ci_image: harbor.baai.ac.cn/flagos-dev/vllm-plugin-fl:v0.20.2-metax-ci
22+
23+
# Runner labels for this hardware.
24+
# Keep this aligned with the MetaX C550 runner label.
25+
runner_labels:
26+
- metax-c550-124
27+
28+
# Container volumes (hardware-specific paths).
29+
container_volumes:
30+
- /data:/data
31+
32+
# Container options (hardware-specific settings).
33+
container_options: >-
34+
--hostname vllm-plugin-fl
35+
--ipc=host
36+
--shm-size=64g
37+
--device /dev/dri:/dev/dri:rwm
38+
--device /dev/mxcd:/dev/mxcd:rwm
39+
--env GEMS_VENDOR=metax
40+
--env VLLM_PLUGINS=fl
41+
--env MACA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7

.github/configs/platforms.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ platforms:
2626
enabled: false
2727
hygon:
2828
enabled: true
29+
metax:
30+
enabled: true

.github/scripts/metax/check.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# Copyright (c) 2025 BAAI. All rights reserved.
3+
# Check MetaX C550 availability.
4+
set -euo pipefail
5+
6+
echo "Current time: $(date '+%Y-%m-%d %H:%M:%S')"
7+
echo "=== Checking MetaX C550 availability ==="
8+
9+
MX_SMI_BIN=""
10+
if command -v mx-smi >/dev/null 2>&1; then
11+
MX_SMI_BIN="$(command -v mx-smi)"
12+
fi
13+
14+
if [[ -n "${MX_SMI_BIN}" ]]; then
15+
echo "Using mx-smi: ${MX_SMI_BIN}"
16+
"${MX_SMI_BIN}" || true
17+
else
18+
echo "::warning::mx-smi not found in PATH; skipping SMI output."
19+
fi
20+
21+
test -d /dev/dri
22+
test -e /dev/mxcd

.github/scripts/metax/setup.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# Copyright (c) 2025 BAAI. All rights reserved.
3+
# Setup script for MetaX C550 CI environment.
4+
set -euo pipefail
5+
6+
export PATH="/opt/conda/bin:${PATH}"
7+
8+
: "${GEMS_VENDOR:?GEMS_VENDOR is not set}"
9+
: "${VLLM_PLUGINS:?VLLM_PLUGINS is not set}"
10+
: "${MACA_VISIBLE_DEVICES:?MACA_VISIBLE_DEVICES is not set}"
11+
12+
git config --global --add safe.directory "$(pwd)"
13+
14+
if [[ -n "${GITHUB_ENV:-}" ]]; then
15+
for name in \
16+
PATH \
17+
GEMS_VENDOR \
18+
VLLM_PLUGINS \
19+
MACA_VISIBLE_DEVICES; do
20+
echo "${name}=${!name}" >> "${GITHUB_ENV}"
21+
done
22+
fi
23+
24+
# vLLM, FlagGems, and test dependencies are provided by the CI image.
25+
# Only install the checked-out plugin source for this workflow run.
26+
python -m pip install --no-build-isolation --no-deps -e .
27+
28+
python - <<'PY'
29+
import flag_gems
30+
import torch
31+
import vllm
32+
import vllm_fl
33+
34+
print(f"vLLM import ok: {vllm.__version__}")
35+
print(f"vLLM-FL import ok: {vllm_fl.__file__}")
36+
print(f"FlagGems import ok: {getattr(flag_gems, '__version__', 'unknown')}")
37+
print(f"Torch import ok: {torch.__version__}")
38+
print(f"Accelerator available: {torch.cuda.is_available()}")
39+
print(f"Accelerator count: {torch.cuda.device_count()}")
40+
PY

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,14 @@ jobs:
133133
with:
134134
platform: hygon
135135
secrets: inherit
136+
137+
# ============================================================
138+
# Job 4d: MetaX platform testing
139+
# ============================================================
140+
test-metax:
141+
needs: discover
142+
if: contains(fromJson(needs.discover.outputs.platforms), 'metax')
143+
uses: ./.github/workflows/_platform_test.yml
144+
with:
145+
platform: metax
146+
secrets: inherit

docker/build.sh

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ UBUNTU_VERSION="${UBUNTU_VERSION:-22.04}"
3131
VLLM_VERSION="${VLLM_VERSION:-0.19.0}"
3232
CANN_VERSION="${CANN_VERSION:-8.5.1}"
3333
CANN_CHIP="${CANN_CHIP:-910b}"
34+
METAX_BASE_IMAGE="${METAX_BASE_IMAGE:-harbor.baai.ac.cn/flagos-dev/vllm-plugin-fl:vllm-metax-0.20.0-maca.ai3.7.0.107-torch2.8-py312-ubuntu22.04-amd64}"
35+
METAX_PYTHON_VERSION="${METAX_PYTHON_VERSION:-3.12}"
36+
METAX_PYTHON_TAG="${METAX_PYTHON_TAG:-py312}"
37+
METAX_MACA_VERSION="${METAX_MACA_VERSION:-3.7.0.107}"
38+
METAX_VLLM_VERSION="${METAX_VLLM_VERSION:-0.20.2}"
3439
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}"
3540
HYGON_VLLM_VERSION="${HYGON_VLLM_VERSION:-0.20.2}"
3641
HYGON_DTK_VERSION="${HYGON_DTK_VERSION:-26.04}"
@@ -137,7 +142,7 @@ Usage: $(basename "$0") [OPTIONS]
137142
Build the vllm-plugin-FL Docker image.
138143
139144
OPTIONS:
140-
--platform PLATFORM Platform to build: cuda, ascend, hygon (default: ${PLATFORM})
145+
--platform PLATFORM Platform to build: cuda, ascend, hygon, metax (default: ${PLATFORM})
141146
--target TARGET Build target: dev, ci, release (default: ${TARGET})
142147
--image-name NAME Image name (default: ${IMAGE_NAME})
143148
--image-tag TAG Image tag (default: auto-generated)
@@ -157,6 +162,12 @@ VERSIONS (override via environment variables):
157162
Ascend:
158163
CANN_VERSION CANN version (default: ${CANN_VERSION})
159164
CANN_CHIP CANN chip: 910b, a3 (default: ${CANN_CHIP})
165+
MetaX:
166+
METAX_BASE_IMAGE Base image (default: ${METAX_BASE_IMAGE})
167+
METAX_MACA_VERSION MACA version used in generated image tag (default: ${METAX_MACA_VERSION})
168+
METAX_PYTHON_VERSION Python version used in generated image tag (default: ${METAX_PYTHON_VERSION})
169+
METAX_PYTHON_TAG Python tag fragment used in generated image tag (default: ${METAX_PYTHON_TAG})
170+
METAX_VLLM_VERSION vLLM version installed in empty mode (default: ${METAX_VLLM_VERSION})
160171
Hygon:
161172
HYGON_BASE_IMAGE Base image (default: ${HYGON_BASE_IMAGE})
162173
HYGON_VLLM_VERSION vLLM version installed in empty mode (default: ${HYGON_VLLM_VERSION})
@@ -180,6 +191,9 @@ EXAMPLES:
180191
# Build Hygon CI image
181192
./build.sh --platform hygon --target ci
182193
194+
# Build MetaX CI image
195+
./build.sh --platform metax --target ci --image-name harbor.baai.ac.cn/flagos-dev/vllm-plugin-fl
196+
183197
# Build with custom PyPI mirror
184198
./build.sh --target dev --index-url https://pypi.tuna.tsinghua.edu.cn/simple
185199
@@ -284,8 +298,21 @@ elif [[ "${PLATFORM}" == "hygon" ]]; then
284298
if [[ -z "${IMAGE_TAG}" ]]; then
285299
IMAGE_TAG="hygon-vllm${VLLM_VERSION}-dtk${HYGON_DTK_VERSION}-py${HYGON_PYTHON_VERSION}-${TARGET}"
286300
fi
301+
elif [[ "${PLATFORM}" == "metax" ]]; then
302+
PYTHON_VERSION="${METAX_PYTHON_VERSION}"
303+
VLLM_VERSION="${METAX_VLLM_VERSION}"
304+
if [[ "${IMAGE_NAME}" == "harbor.baai.ac.cn/flagscale/vllm-plugin-fl" ]]; then
305+
IMAGE_NAME="harbor.baai.ac.cn/flagos-dev/vllm-plugin-fl"
306+
fi
307+
BUILD_ARGS+=(
308+
--build-arg "METAX_BASE_IMAGE=${METAX_BASE_IMAGE}"
309+
--build-arg "VLLM_VERSION=${METAX_VLLM_VERSION}"
310+
)
311+
if [[ -z "${IMAGE_TAG}" ]]; then
312+
IMAGE_TAG="vllm-metax-${METAX_VLLM_VERSION}-maca.ai${METAX_MACA_VERSION}-torch2.8-${METAX_PYTHON_TAG}-ubuntu22.04-amd64-ci-git"
313+
fi
287314
else
288-
err "Unknown platform '${PLATFORM}'. Must be 'cuda', 'ascend', or 'hygon'."
315+
err "Unknown platform '${PLATFORM}'. Must be 'cuda', 'ascend', 'hygon', or 'metax'."
289316
fi
290317

291318
FULL_IMAGE="${IMAGE_NAME}:${IMAGE_TAG}"
@@ -305,6 +332,10 @@ elif [[ "${PLATFORM}" == "hygon" ]]; then
305332
msg " Runtime libs: ${HYGON_RUNTIME_LIB_DIR}"
306333
msg " FlagGems: ${FLAGGEMS_VERSION}"
307334
msg " Plugin: ${VLLM_PLUGIN_FL_VERSION}"
335+
elif [[ "${PLATFORM}" == "metax" ]]; then
336+
msg " MACA: ${METAX_MACA_VERSION}"
337+
msg " MetaX Python: ${METAX_PYTHON_VERSION}"
338+
msg " Base image: ${METAX_BASE_IMAGE}"
308339
fi
309340
msg " Ubuntu: ${UBUNTU_VERSION}"
310341
msg " Python: ${PYTHON_VERSION}"

docker/metax/Dockerfile

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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+
ARG METAX_BASE_IMAGE=harbor.baai.ac.cn/flagos-dev/vllm-plugin-fl:vllm-metax-0.20.0-maca.ai3.7.0.107-torch2.8-py312-ubuntu22.04-amd64
16+
17+
# ---------- base stage ----------
18+
FROM ${METAX_BASE_IMAGE} AS base
19+
20+
ARG METAX_BASE_IMAGE
21+
ARG VLLM_VERSION=0.20.2
22+
ARG FLAGGEMS_REF=3123859968915e361e8452dd796dc6b27c956324
23+
ARG BUILD_DATE=unknown
24+
ARG VCS_REF=unknown
25+
ARG IMAGE_VERSION=unknown
26+
ARG IMAGE_STAGE=dev
27+
ARG SOURCE_URL=https://github.com/flagos-ai/vllm-plugin-FL
28+
29+
LABEL org.opencontainers.image.title="vllm-plugin-fl" \
30+
org.opencontainers.image.description="MetaX CI image for vllm-plugin-FL" \
31+
org.opencontainers.image.source="${SOURCE_URL}" \
32+
org.opencontainers.image.created="${BUILD_DATE}" \
33+
org.opencontainers.image.revision="${VCS_REF}" \
34+
org.opencontainers.image.version="${IMAGE_VERSION}" \
35+
org.opencontainers.image.base.name="${METAX_BASE_IMAGE}" \
36+
io.flagos.accelerator.backend="metax" \
37+
io.flagos.image.stage="${IMAGE_STAGE}" \
38+
io.flagos.vllm.version="${VLLM_VERSION}" \
39+
io.flagos.flaggems.revision="${FLAGGEMS_REF}"
40+
41+
ENV DEBIAN_FRONTEND=noninteractive \
42+
GEMS_VENDOR=metax \
43+
VLLM_PLUGINS=fl \
44+
PATH="/opt/conda/bin:${PATH}"
45+
46+
# actions/checkout requires git before any platform setup script runs. Build
47+
# tools are installed here because both vLLM empty mode and FlagGems are fixed
48+
# parts of the MetaX runtime rather than per-job CI dependencies.
49+
RUN apt-get update \
50+
&& apt-get install -y --no-install-recommends \
51+
build-essential \
52+
ca-certificates \
53+
curl \
54+
git \
55+
&& rm -rf /var/lib/apt/lists/*
56+
57+
RUN python -m pip install --no-cache-dir \
58+
wheel \
59+
setuptools-scm \
60+
scikit-build-core==0.11 \
61+
pybind11 \
62+
ninja \
63+
cmake
64+
65+
# Replace the vLLM Python package from the vendor image with official vLLM in
66+
# empty mode. The MetaX kernels and torch runtime remain provided by the base
67+
# image. Install non-editably so /workspace mounts cannot hide the package.
68+
RUN python -m pip uninstall -y vllm || true; \
69+
python -m pip cache remove vllm || true; \
70+
SITE_PACKAGES="$(python -c 'import site; print(site.getsitepackages()[0])')"; \
71+
find "${SITE_PACKAGES}" -maxdepth 1 \
72+
\( -name "vllm" -o -name "vllm-*.dist-info" -o -name "vllm-*.egg-info" \) \
73+
-exec rm -rf {} + 2>/dev/null || true; \
74+
rm -rf /tmp/vllm \
75+
&& git clone --depth 1 --branch "v${VLLM_VERSION}" \
76+
https://github.com/vllm-project/vllm.git /tmp/vllm \
77+
&& VLLM_TARGET_DEVICE=empty python -m pip install --no-cache-dir \
78+
--no-build-isolation --no-deps /tmp/vllm \
79+
&& rm -rf /tmp/vllm
80+
81+
# FlagGems is pinned to the source revision already validated on MetaX C550.
82+
RUN rm -rf /tmp/FlagGems \
83+
&& rm -f /tmp/FlagGems.tar.gz \
84+
&& mkdir -p /tmp/FlagGems \
85+
&& curl --fail --location --retry 5 --retry-all-errors \
86+
--retry-delay 5 --connect-timeout 30 --max-time 1200 \
87+
"https://codeload.github.com/FlagOpen/FlagGems/tar.gz/${FLAGGEMS_REF}" \
88+
--output /tmp/FlagGems.tar.gz \
89+
&& tar -xzf /tmp/FlagGems.tar.gz --strip-components=1 -C /tmp/FlagGems \
90+
&& python -m pip install --no-cache-dir \
91+
-r /tmp/FlagGems/requirements/requirements_metax.txt \
92+
&& GEMS_VENDOR=metax python -m pip install --no-cache-dir \
93+
--no-build-isolation /tmp/FlagGems \
94+
&& rm -rf /tmp/FlagGems /tmp/FlagGems.tar.gz \
95+
&& python -m pip install --no-cache-dir \
96+
numpy==1.26.4 \
97+
opencv-python-headless==4.11.0.86 \
98+
outlines-core==0.2.14
99+
100+
WORKDIR /workspace
101+
102+
# ---------- dev stage ----------
103+
FROM base AS dev
104+
105+
RUN python -m pip install --no-cache-dir \
106+
pytest \
107+
pytest-cov \
108+
pytest-timeout \
109+
pytest-json-report \
110+
pre-commit \
111+
ruff
112+
113+
WORKDIR /workspace
114+
115+
# ---------- ci stage ----------
116+
FROM base AS ci
117+
118+
# Keep project-independent CI dependencies in the image. setup.sh only needs
119+
# to install the checked-out vllm-plugin-FL package.
120+
RUN python -m pip install --no-cache-dir \
121+
pytest \
122+
pytest-cov \
123+
pytest-timeout \
124+
pytest-json-report \
125+
requests \
126+
openai \
127+
decorator \
128+
pyyaml \
129+
sqlalchemy \
130+
"modelscope>=1.18.1"
131+
132+
WORKDIR /workspace
133+
134+
# ---------- release stage ----------
135+
FROM base AS release
136+
137+
WORKDIR /workspace
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
serve:
16+
- name: serve_smoke_dummy
17+
model: qwen3
18+
case: 06b_tp2
19+
server_parameters:
20+
served_model_name: smoke-model
21+
tensor_parallel_size: 1
22+
max_model_len: 1024
23+
gpu_memory_utilization: 0.7
24+
enforce_eager: true
25+
load_format: dummy
26+
startup_retries: 180
27+
poll_interval: 10
28+
client_parameters:
29+
model: smoke-model
30+
backend: openai-chat
31+
endpoint: /v1/chat/completions
32+
dataset_name: random
33+
random_input_len: 32
34+
random_output_len: 4
35+
num_prompts: 5
36+
percentile_metrics: ttft,tpot,itl,e2el
37+
goodput: e2el:10000

tests/benchmarks/test_benchmark_serve.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def test_benchmark_serve(tmp_path):
2020
model = server_params.pop("model")
2121
served_model_name = server_params.pop("served_model_name", "")
2222
tp_size = int(server_params.pop("tensor_parallel_size", 1))
23+
startup_retries = int(server_params.pop("startup_retries", 60))
24+
poll_interval = int(server_params.pop("poll_interval", 10))
2325
server_extra_args = to_cli_args(server_params)
2426

2527
result_json = tmp_path / "serve_result.json"
@@ -28,6 +30,8 @@ def test_benchmark_serve(tmp_path):
2830
model=model,
2931
tp_size=tp_size,
3032
served_model_name=served_model_name,
33+
max_retries=startup_retries,
34+
poll_interval=poll_interval,
3135
extra_args=server_extra_args,
3236
) as server:
3337
command = [

0 commit comments

Comments
 (0)