amd_ci_exec.sh 1.2 KB
Newer Older
Sai Enduri's avatar
Sai Enduri committed
1
2
3
#!/bin/bash
set -euo pipefail

4
5
6
7
8
9
10
11
12
13
14
15
# Detect GPU family from hostname (e.g., linux-mi35x-gpu-1-xxxxx-runner-zzzzz)
HOSTNAME_VALUE=$(hostname)
GPU_FAMILY=""

# Host names look like: linux-mi35x-gpu-1-xxxxx-runner-zzzzz
if [[ "${HOSTNAME_VALUE}" =~ ^linux-(mi[0-9]+[a-z]*)-gpu-[0-9]+ ]]; then
  GPU_FAMILY="${BASH_REMATCH[1]}"
  echo "Detected GPU family from hostname: ${GPU_FAMILY}"
else
  echo "Warning: could not parse GPU family from '${HOSTNAME_VALUE}'"
fi

Sai Enduri's avatar
Sai Enduri committed
16
WORKDIR="/sglang-checkout/test/srt"
17
18
19
20
declare -A ENV_MAP=(
  [SGLANG_AMD_CI]=1
  [SGLANG_IS_IN_CI]=1
  [SGLANG_USE_AITER]=1
Sai Enduri's avatar
Sai Enduri committed
21
22
)

23
24
25
26
27
# Conditionally add GPU_ARCHS only for mi35x
if [[ "${GPU_FAMILY}" == "mi35x" ]]; then
  ENV_MAP[GPU_ARCHS]="gfx950"
fi

28
# Parse -w/--workdir and -e ENV=VAL
Sai Enduri's avatar
Sai Enduri committed
29
30
31
32
33
34
35
while [[ $# -gt 0 ]]; do
  case "$1" in
    -w|--workdir)
      WORKDIR="$2"
      shift 2
      ;;
    -e)
36
37
      IFS="=" read -r key val <<< "$2"
      ENV_MAP["$key"]="$val"
Sai Enduri's avatar
Sai Enduri committed
38
39
40
41
42
43
44
45
46
47
48
49
      shift 2
      ;;
    --)
      shift
      break
      ;;
    *)
      break
      ;;
  esac
done

50
51
52
53
54
55
# Build final ENV_ARGS
ENV_ARGS=()
for key in "${!ENV_MAP[@]}"; do
  ENV_ARGS+=("-e" "$key=${ENV_MAP[$key]}")
done

Sai Enduri's avatar
Sai Enduri committed
56
57
58
59
60
# Run docker exec
docker exec \
  -w "$WORKDIR" \
  "${ENV_ARGS[@]}" \
  ci_sglang "$@"