Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Magpie/benchmark_images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Format: framework -> gpu_arch -> docker_image
#
# GPU Architecture Identifiers:
# AMD: gfx942 (MI300X), gfx950 (MI355X)
# AMD: gfx942 (MI300X), gfx950 (MI355X), gfx1151 (Strix Halo / Radeon 8060S)
# NVIDIA: sm_80 (A100), sm_90 (H100/H200), sm_100 (B200)
#
# Usage:
Expand All @@ -13,6 +13,7 @@ vllm:
# AMD GPUs
gfx942: "vllm/vllm-openai-rocm:v0.23.0"
gfx950: "vllm/vllm-openai-rocm:v0.23.0"
gfx1151: "vllm/vllm-openai-rocm:v0.23.0"
Comment thread
haofrank marked this conversation as resolved.
Resolved
# NVIDIA GPUs
sm_80: "vllm/vllm-openai:v0.23.0"
sm_90: "vllm/vllm-openai:v0.23.0"
Expand Down
1 change: 1 addition & 0 deletions Magpie/modes/benchmark/benchmarker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
{
"vllm_mi300x.sh",
"vllm_mi355x.sh",
"vllm_gfx11.sh",
"sglang_mi300x.sh",
"sglang_mi355x.sh",
"atom_mi300x.sh",
Expand Down
13 changes: 11 additions & 2 deletions Magpie/modes/benchmark/image_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,19 @@ def get_runner_type(self, gpu_arch: Optional[str] = None) -> str:

# Map GPU architectures to runner types
arch_to_runner = {
# AMD GPUs
# AMD data-center GPUs
"gfx942": "mi300x", # MI300X
"gfx950": "mi355x", # MI355X
"gfx1100": "mi325x", # MI325X
# AMD client/edge (RDNA3/3.5): one shared runner, since the
# recipe is identical across the family.
"gfx1100": "gfx11", # Navi31 (RX 7900 XT/XTX, W7900)
"gfx1101": "gfx11", # Navi32 (RX 7800 XT, W7800)
"gfx1102": "gfx11", # Navi33 (RX 7600)
"gfx1103": "gfx11", # Phoenix APU (Radeon 780M)
"gfx1150": "gfx11", # Strix Point APU (Radeon 890M)
"gfx1151": "gfx11", # Strix Halo APU (Radeon 8040S/8050S/8060S)
"gfx1152": "gfx11", # Krackan Point APU
"gfx1153": "gfx11", # Krackan Point APU
# NVIDIA GPUs
"sm_80": "a100", # A100
"sm_90": "h100", # H100
Expand Down
8 changes: 7 additions & 1 deletion Magpie/modes/benchmark/tracelens_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ def trace_arch_platform_from_runner(runner_type: Optional[str]) -> Optional[str]
"""Map Magpie runner/GPU architecture naming to TraceLens platform names."""
if runner_type:
runner = runner_type.lower()
if runner.startswith("gfx11"):
# A family runner can't pick a per-SKU spec (gfx1151 covers the
# 8060S/8050S/8040S). None omits --gpu_arch_platform so TraceLens
# identifies the part itself instead of us guessing.
return None
aliases = {
"mi300": "MI300X",
"mi300x": "MI300X",
Expand All @@ -245,7 +250,8 @@ def trace_arch_platform_from_runner(runner_type: Optional[str]) -> Optional[str]
arch_map = {
"gfx942": "MI300X",
"gfx950": "MI355X",
"gfx1100": "MI325X",
# No gfx11: each target covers several parts with different CU counts,
# so None lets TraceLens identify the part.
}
return arch_map.get(arch)

Expand Down
146 changes: 146 additions & 0 deletions Magpie/scripts/benchmark/vllm_gfx11.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#!/usr/bin/env bash
###############################################################################
# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
#
# See LICENSE for license information.
###############################################################################

# Magpie Generic vLLM Benchmark Script for AMD gfx11 (RDNA3 / RDNA3.5)
#
# Phases (via MAGPIE_RUN_PHASE): all | server | client (default all).
# Server-only writes PID to MAGPIE_SERVER_PID_FILE then disowns and exits.
# Remote server (BENCHMARK_BASE_URL) forces PHASE=client; see vllm_mi300x.sh
# for the full contract.

source "$(dirname "$0")/benchmark_lib.sh"
source "$(dirname "$0")/server_cleanup.sh"
# shellcheck source=magpie_bench_remote_compat.sh
source "$(dirname "$0")/magpie_bench_remote_compat.sh"

PHASE="${MAGPIE_RUN_PHASE:-all}"
case "$PHASE" in
all|server|client) ;;
*) echo "ERROR: Invalid MAGPIE_RUN_PHASE='$PHASE'. Must be all|server|client." >&2; exit 2 ;;
esac

if [[ -n "${BENCHMARK_BASE_URL:-}" ]]; then
if [[ "$PHASE" != "client" ]]; then
echo "[vllm_gfx11] BENCHMARK_BASE_URL set; forcing PHASE=client (was $PHASE)"
PHASE=client
fi
fi

if [[ "$PHASE" == "server" || "$PHASE" == "all" ]]; then
check_env_vars MODEL TP
fi
if [[ "$PHASE" == "client" || "$PHASE" == "all" ]]; then
check_env_vars MODEL CONC ISL OSL RANDOM_RANGE_RATIO RESULT_FILENAME
fi

MAX_MODEL_LEN=${MAX_MODEL_LEN:-4096}
GPU_MEMORY_UTILIZATION=${GPU_MEMORY_UTILIZATION:-0.7}

if [[ -n "$SLURM_JOB_ID" ]]; then
echo "JOB $SLURM_JOB_ID running on $SLURMD_NODENAME"
fi

if [[ "$PHASE" != "client" ]]; then
hf download "$MODEL" 2>/dev/null || true
fi

# ROCR_VISIBLE_DEVICES already re-indexes visible GPUs to 0..N-1, so HIP
# must use the logical range, not the original physical ids.
if [ -n "$ROCR_VISIBLE_DEVICES" ] && [ -z "$HIP_VISIBLE_DEVICES" ]; then
n=$(echo "$ROCR_VISIBLE_DEVICES" | awk -F, '{print NF}')
export HIP_VISIBLE_DEVICES=$(seq -s, 0 $((n-1)))
fi

# AITER ships kernels for gfx942/gfx950 only.
export VLLM_ROCM_USE_AITER=${VLLM_ROCM_USE_AITER:-0}

WORKSPACE_DIR=${RESULT_DIR:-/workspace}
SERVER_LOG=${SERVER_LOG:-$WORKSPACE_DIR/server.log}
PORT=${PORT:-8888}

# Build profiler args for vLLM >= 0.15 (env var VLLM_TORCH_PROFILER_DIR is deprecated)
PROFILER_ARGS=()
if [[ "${PROFILE:-}" == "1" ]]; then
TRACE_DIR="${VLLM_TORCH_PROFILER_DIR:-$WORKSPACE_DIR/torch_trace}"
mkdir -p "$TRACE_DIR"
PROFILER_ARGS+=(--profiler-config.profiler torch)
PROFILER_ARGS+=(--profiler-config.torch_profiler_dir "$TRACE_DIR")
PROFILER_ARGS+=(--profiler-config.torch_profiler_record_shapes True)
PROFILER_ARGS+=(--profiler-config.torch_profiler_with_memory True)
PROFILER_ARGS+=(--profiler-config.torch_profiler_with_flops True)
PROFILER_ARGS+=(--profiler-config.torch_profiler_use_gzip True)
fi

set -x
if [[ "$PHASE" == "server" || "$PHASE" == "all" ]]; then
setsid vllm serve $MODEL --port $PORT \
--tensor-parallel-size=$TP \
--gpu-memory-utilization "$GPU_MEMORY_UTILIZATION" \
--max-model-len $MAX_MODEL_LEN \
--trust-remote-code \
"${PROFILER_ARGS[@]}" \
$EXTRA_VLLM_ARGS > $SERVER_LOG 2>&1 &

SERVER_PID=$!
if [[ "$PHASE" == "all" ]]; then
trap 'magpie_stop_benchmark_server_stack "$SERVER_PID"' EXIT INT TERM
fi

wait_for_server_ready --port "$PORT" --server-log "$SERVER_LOG" --server-pid "$SERVER_PID"

if [[ "$PHASE" == "server" ]]; then
if [[ -z "${MAGPIE_SERVER_PID_FILE:-}" ]]; then
echo "ERROR: MAGPIE_SERVER_PID_FILE must be set for MAGPIE_RUN_PHASE=server" >&2
kill -TERM "-$SERVER_PID" 2>/dev/null || true
exit 3
fi
printf '%s\n' "$SERVER_PID" > "$MAGPIE_SERVER_PID_FILE"
disown "$SERVER_PID" 2>/dev/null || true
exit 0
fi
fi

SERVER_MONITOR_ARGS=()
if [[ -n "${SERVER_PID:-}" ]]; then
SERVER_MONITOR_ARGS+=(--server-pid "$SERVER_PID")
fi

if [[ "$PHASE" == "client" || "$PHASE" == "all" ]]; then
if [[ -n "${BENCHMARK_BASE_URL:-}" ]]; then
SERVER_MONITOR_ARGS=()
magpie_run_benchmark_serving_remote_direct trust || exit $?
else
run_benchmark_serving \
--model "$MODEL" \
--port "$PORT" \
--backend vllm \
--input-len "$ISL" \
--output-len "$OSL" \
--random-range-ratio "$RANDOM_RANGE_RATIO" \
--num-prompts ${NUM_PROMPTS:-$(( $CONC * 10 ))} \
--max-concurrency "$CONC" \
--result-filename "$RESULT_FILENAME" \
--result-dir "$WORKSPACE_DIR/" \
"${SERVER_MONITOR_ARGS[@]}" \
--trust-remote-code || exit $?
fi
fi

# After throughput, run evaluation only if RUN_EVAL is true
if [[ "$PHASE" != "server" && "${RUN_EVAL}" = "true" ]]; then
if [[ -n "${BENCHMARK_BASE_URL:-}" ]]; then
if declare -F magpie_run_eval_remote_direct &>/dev/null; then
magpie_run_eval_remote_direct || exit $?
else
echo "[vllm_gfx11] RUN_EVAL=true with BENCHMARK_BASE_URL but magpie_run_eval_remote_direct shim not available; skipping eval (results gate will see accuracy=None)."
fi
else
export EVAL_CONCURRENT_REQUESTS="${MAGPIE_EVAL_CONCURRENCY:-${EVAL_CONCURRENT_REQUESTS:-$CONC}}"
magpie_run_eval_persisted --framework lm-eval --port "$PORT" || exit $?
fi
fi
set +x
120 changes: 120 additions & 0 deletions tests/test_benchmark_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -2590,3 +2590,123 @@ def test_result_parser_carries_scriptable_quality_gate(tmp_path):
d = parsed.to_dict()
assert d["workload_kind"] == "scriptable"
assert d["quality_gate"]["passed"] is True


# ── gfx11 (RDNA3 / RDNA3.5) client-GPU support ────────────────────────


@pytest.mark.parametrize(
"gpu_arch",
[
"gfx1100",
"gfx1101",
"gfx1102",
"gfx1103",
"gfx1150",
"gfx1151",
"gfx1152",
"gfx1153",
],
)
def test_gfx11_arches_share_one_runner(gpu_arch):
"""The whole gfx11 family selects the shared vllm_gfx11.sh recipe."""
assert ImageSelector().get_runner_type(gpu_arch) == "gfx11"


def test_gfx1100_no_longer_reports_as_mi325x():
"""gfx1100 is Navi31 (RX 7900); MI325X is gfx942 silicon."""
assert ImageSelector().get_runner_type("gfx1100") != "mi325x"


def test_instinct_runner_types_unchanged():
selector = ImageSelector()
assert selector.get_runner_type("gfx942") == "mi300x"
assert selector.get_runner_type("gfx950") == "mi355x"


def test_vllm_gfx11_script_is_a_builtin():
"""server_lifecycle rejects any script outside MAGPIE_BUILTIN_SCRIPTS."""
from Magpie.modes.benchmark.benchmarker import MAGPIE_BUILTIN_SCRIPTS

assert "vllm_gfx11.sh" in MAGPIE_BUILTIN_SCRIPTS


def test_gfx11_runner_defers_tracelens_platform_selection():
"""A family runner cannot identify a per-SKU TraceLens spec, so defer."""
assert trace_arch_platform_from_runner("gfx11") is None
# Instinct runners still resolve as before.
assert trace_arch_platform_from_runner("mi300x") == "MI300X"
assert trace_arch_platform_from_runner("mi355x") == "MI355X"


@pytest.mark.parametrize(
"gpu_arch",
[
"gfx1100",
"gfx1101",
"gfx1102",
"gfx1103",
"gfx1150",
"gfx1151",
"gfx1152",
"gfx1153",
],
)
def test_gfx11_arch_resolves_to_the_shipped_script(tmp_path, gpu_arch):
"""arch -> runner -> filename must land on the script that actually ships.

get_runner_type() and MAGPIE_BUILTIN_SCRIPTS are asserted separately above,
but nothing tied the two ends together: _get_benchmark_script() derives
f"{framework}_{runner}.sh", so naming the file vllm_gfx1151.sh would keep
every other gfx11 test green while breaking every run.
"""
mode = BenchmarkMode(
BenchmarkConfig(framework="vllm", model="demo", inferencex_path=str(tmp_path)),
output_dir=str(tmp_path / "out"),
)
mode._prepare_benchmark_scripts()

runner = ImageSelector().get_runner_type(gpu_arch)
assert mode._get_benchmark_script(runner) == "benchmarks/vllm_gfx11.sh"


def test_gfx11_autodetected_arch_defers_tracelens_platform(monkeypatch):
"""The arch-keyed branch, reached when no runner_type is passed."""

def _arch(value):
monkeypatch.setattr(
"Magpie.modes.benchmark.tracelens_inference.detect_gpu",
lambda: (GPUVendor.AMD, value),
)

for arch in ("gfx1151", "gfx1100"):
_arch(arch)
assert trace_arch_platform_from_runner(None) is None

# Instinct arches still resolve; gfx1100 used to answer MI325X here.
_arch("gfx942")
assert trace_arch_platform_from_runner(None) == "MI300X"
_arch("gfx950")
assert trace_arch_platform_from_runner(None) == "MI355X"


def test_gfx11_has_no_sglang_or_atom_image():
"""No gfx11 build exists for either, so they must error, not fall back."""
selector = ImageSelector()
for framework in ("sglang", "atom"):
with pytest.raises(ValueError, match="No image found for GPU architecture"):
selector.select_image(framework, gpu_arch="gfx1151")


def test_unvalidated_gfx11_arch_has_a_runner_but_no_image():
"""Runners are family-level; image entries stay per-arch and opt-in."""
selector = ImageSelector()
assert selector.get_runner_type("gfx1103") == "gfx11"
with pytest.raises(ValueError, match="No image found for GPU architecture"):
selector.select_image("vllm", gpu_arch="gfx1103")


def test_runner_type_to_gpu_type_rejects_gfx11():
"""TraceLens ships no gfx11 build script; the sglang path must not guess."""
with pytest.raises(ValueError, match="MI300/MI350/MI355"):
runner_type_to_gpu_type("gfx11")
2 changes: 1 addition & 1 deletion tests/test_benchmark_unit_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def test_image_selector_loads_mapping_and_selects_images(tmp_path, monkeypatch):
[
("gfx942", "mi300x"),
("gfx950", "mi355x"),
("gfx1100", "mi325x"),
("gfx1100", "gfx11"),
("sm_80", "a100"),
("sm_90", "h100"),
("sm_90a", "h200"),
Expand Down
1 change: 1 addition & 0 deletions tests/test_eval_concurrency_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"sglang_mi355x.sh",
"vllm_mi300x.sh",
"vllm_mi355x.sh",
"vllm_gfx11.sh",
]
CONCURRENCY_EXPORT = (
'export EVAL_CONCURRENT_REQUESTS="${MAGPIE_EVAL_CONCURRENCY:-'
Expand Down