sskj/scripts/common/platform.sh
Quantong Qiu 227ef603a6 refactor: experiments/ + platforms/ layout and P800 SGLang support
- Restructure repo around experiments/<name>/ and platforms/<chip>.env.
- Add shared scripts under scripts/common/ for platform/server/bench-client logic.
- Add Kunlun P800 platform config and runtime patches.
- Add dsv4_p800_sglang experiment with INT8 smoke-test support.
- Update BENCHMARK_WORKFLOW.md and README.md with chip/engine recording rules.
- Add scripts/analysis/compare_experiments.py for cross-experiment comparison.
- Ignore experiments/*/results/ raw output directories by default.
2026-07-08 05:15:59 +00:00

38 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Platform loader.
# Usage: source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../scripts/common/platform.sh"
set -Eeuo pipefail
_PLATFORM_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "${_PLATFORM_DIR}/../.." && pwd)"
# Auto-detect platform if not set.
if [[ -z "${PLATFORM:-}" ]]; then
if lspci 2>/dev/null | grep -qiE "XPU|Kunlun"; then
PLATFORM="kunlun_p800"
elif command -v nvidia-smi >/dev/null 2>&1; then
PLATFORM="nvidia_h200"
else
echo "ERROR: Could not auto-detect PLATFORM. Set PLATFORM env var explicitly." >&2
exit 1
fi
echo "Auto-detected platform: ${PLATFORM}"
fi
PLATFORM_FILE="${ROOT_DIR}/platforms/${PLATFORM}.env"
if [[ ! -f "$PLATFORM_FILE" ]]; then
echo "ERROR: Platform config not found: ${PLATFORM_FILE}" >&2
exit 1
fi
# shellcheck source=/dev/null
source "$PLATFORM_FILE"
# Export key variables if not already set.
export CHIP="${CHIP:-$PLATFORM}"
export ACCELERATOR="${ACCELERATOR:-$PLATFORM}"
export HARDWARE="${HARDWARE:-$PLATFORM}"
export DEFAULT_PORT="${DEFAULT_PORT:-30000}"
export MODEL_ROOT="${MODEL_ROOT:-/data1/models}"