|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2026 FlagOS Contributors |
| 4 | +# Licensed under the Apache License, Version 2.0. |
| 5 | + |
| 6 | +set -euo pipefail |
| 7 | + |
| 8 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 9 | +source "$SCRIPT_DIR/../utils/utils.sh" |
| 10 | +source "$SCRIPT_DIR/../utils/pkg_utils.sh" |
| 11 | +source "$SCRIPT_DIR/../utils/retry_utils.sh" |
| 12 | + |
| 13 | +PROJECT_ROOT=$(get_project_root) |
| 14 | +DEBUG="${FLAGSCALE_DEBUG:-false}" |
| 15 | +RETRY_COUNT="${FLAGSCALE_RETRY_COUNT:-3}" |
| 16 | +FLAGSCALE_HOME="${FLAGSCALE_HOME:-/opt/flagscale}" |
| 17 | +FLAGSCALE_DEPS="${FLAGSCALE_DEPS:-$FLAGSCALE_HOME/deps}" |
| 18 | +REQ_FILE="$PROJECT_ROOT/requirements/metax/inference.txt" |
| 19 | +PLUGIN_REPO="${FLAGSCALE_VLLM_PLUGIN_REPO:-https://github.com/flagos-ai/vllm-plugin-FL.git}" |
| 20 | +PLUGIN_REF="${FLAGSCALE_VLLM_PLUGIN_REF:-}" |
| 21 | + |
| 22 | +while [[ $# -gt 0 ]]; do |
| 23 | + case $1 in --debug) DEBUG=true; shift ;; *) shift ;; esac |
| 24 | +done |
| 25 | + |
| 26 | +checkout_pinned_ref() { |
| 27 | + local repo=$1 |
| 28 | + local ref=$2 |
| 29 | + local target=$3 |
| 30 | + |
| 31 | + [ -z "$ref" ] && { log_error "A pinned vllm-plugin-FL ref is required"; return 1; } |
| 32 | + retry -d "$DEBUG" "$RETRY_COUNT" "rm -rf '$target' && \ |
| 33 | + git init -q '$target' && \ |
| 34 | + git -C '$target' remote add origin '$repo' && \ |
| 35 | + git -c http.version=HTTP/1.1 -C '$target' fetch --depth 1 origin '$ref' && \ |
| 36 | + git -C '$target' checkout -q --detach FETCH_HEAD" |
| 37 | +} |
| 38 | + |
| 39 | +install_requirements() { |
| 40 | + set_step "Installing MetaX inference requirements" |
| 41 | + retry_pip_install -d "$DEBUG" "$REQ_FILE" "$RETRY_COUNT" || return 1 |
| 42 | +} |
| 43 | + |
| 44 | +install_plugin() { |
| 45 | + set_step "Installing resolved vllm-plugin-FL for MetaX" |
| 46 | + mkdir -p "$FLAGSCALE_DEPS" |
| 47 | + checkout_pinned_ref "$PLUGIN_REPO" "$PLUGIN_REF" \ |
| 48 | + "$FLAGSCALE_DEPS/vllm-plugin-FL" || return 1 |
| 49 | + |
| 50 | + local pip_cmd |
| 51 | + pip_cmd=$(get_pip_cmd) |
| 52 | + run_cmd -d "$DEBUG" bash -c \ |
| 53 | + "cd '$FLAGSCALE_DEPS/vllm-plugin-FL' && $pip_cmd install \ |
| 54 | + --root-user-action=ignore --no-deps --no-build-isolation ." || return 1 |
| 55 | +} |
| 56 | + |
| 57 | +validate_runtime() { |
| 58 | + [ "$DEBUG" = true ] && return 0 |
| 59 | + VLLM_PLUGINS=fl VLLM_FL_PLATFORM=metax python - <<'PY' |
| 60 | +import importlib.metadata as metadata |
| 61 | +
|
| 62 | +assert metadata.version("vllm").startswith("0.20.2") |
| 63 | +entrypoints = { |
| 64 | + entry.name: entry.value |
| 65 | + for entry in metadata.entry_points(group="vllm.platform_plugins") |
| 66 | +} |
| 67 | +assert entrypoints.get("fl") == "vllm_fl:register", entrypoints |
| 68 | +print("vllm:", metadata.version("vllm")) |
| 69 | +print("vllm-plugin-fl:", metadata.version("vllm-plugin-fl")) |
| 70 | +print("platform entrypoints:", entrypoints) |
| 71 | +PY |
| 72 | +} |
| 73 | + |
| 74 | +main() { |
| 75 | + install_requirements || die "MetaX inference requirements failed" |
| 76 | + install_plugin || die "vllm-plugin-FL installation failed" |
| 77 | + validate_runtime || die "MetaX inference runtime validation failed" |
| 78 | + log_success "MetaX inference runtime ready" |
| 79 | +} |
| 80 | + |
| 81 | +main |
0 commit comments