Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 5 additions & 2 deletions Magpie/modes/benchmark/benchmarker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
{
"vllm_mi300x.sh",
"vllm_mi355x.sh",
"vllm_radeon8060s.sh",
"sglang_mi300x.sh",
"sglang_mi355x.sh",
"sglang_radeon8060s.sh",
"atom_mi300x.sh",
"atom_mi355x.sh",
}
Expand Down Expand Up @@ -832,8 +834,9 @@ def _execute_local_benchmark_with_reuse(
result.success = False
result.errors.append(
"server_lifecycle requires a Magpie built-in InferenceX benchmark "
"script (vllm_mi300x.sh, vllm_mi355x.sh, sglang_mi300x.sh, "
"sglang_mi355x.sh, atom_mi300x.sh, atom_mi355x.sh). Current "
"script (vllm_mi300x.sh, vllm_mi355x.sh, vllm_radeon8060s.sh, "
"sglang_mi300x.sh, sglang_mi355x.sh, sglang_radeon8060s.sh, "
"atom_mi300x.sh, atom_mi355x.sh). Current "
f"resolved script={script_name}. Set benchmark_script accordingly "
"or omit server_lifecycle."
)
Expand Down
1 change: 1 addition & 0 deletions Magpie/modes/benchmark/image_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def get_runner_type(self, gpu_arch: Optional[str] = None) -> str:
"gfx942": "mi300x", # MI300X
"gfx950": "mi355x", # MI355X
"gfx1100": "mi325x", # MI325X
"gfx1151": "radeon8060s", # Radeon 8060S (Strix Halo APU, RDNA 3.5)
# NVIDIA GPUs
"sm_80": "a100", # A100
"sm_90": "h100", # H100
Expand Down
168 changes: 168 additions & 0 deletions Magpie/scripts/benchmark/sglang_radeon8060s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/usr/bin/env bash
###############################################################################
# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
#
# See LICENSE for license information.
###############################################################################
#
# Magpie Generic SGLang Benchmark Script for Radeon 8060S / gfx1151
#
# Phases (via MAGPIE_RUN_PHASE): all | server | client (default all).
#
# Remote server (BENCHMARK_BASE_URL): when set, the client phase points
# benchmark_serving at an external SGLang-compatible HTTP endpoint
# instead of localhost:$PORT, and forces PHASE=client (no local server
# launch). See sglang_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 "[sglang_radeon8060s] 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

for numeric in TP CONC ISL OSL PORT; do
value=${!numeric:-}
if [[ -n "$value" && ! "$value" =~ ^[0-9]+$ ]]; then
echo "ERROR: $numeric must be an unsigned integer, got '$value'." >&2
exit 2
fi
done

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

# Radeon 8060S / RDNA 3.5: pin native gfx1151 without architecture spoofing.
if [[ -n "${PYTORCH_ROCM_ARCH:-}" && "$PYTORCH_ROCM_ARCH" != "gfx1151" ]]; then
echo "ERROR: sglang_radeon8060s requires PYTORCH_ROCM_ARCH=gfx1151." >&2
exit 2
fi
export PYTORCH_ROCM_ARCH=gfx1151
export HSA_ENABLE_SDMA=${HSA_ENABLE_SDMA:-0}
unset HSA_OVERRIDE_GFX_VERSION

# The qualified gfx1151 route uses Triton attention. Current AITER CK prefill
# does not compile for this geometry and AITER paged decode device-asserts.
export SGLANG_USE_AITER=0
unset SGLANG_AITER_MLA_PERSIST
export HYPERLOOM_GFX1151_LOWBIT_BRIDGE=0

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

if [[ "${PROFILE:-}" == "1" ]]; then
TRACE_DIR="${SGLANG_TORCH_PROFILER_DIR:-$WORKSPACE_DIR/torch_trace}"
mkdir -p "$TRACE_DIR"
export SGLANG_TORCH_PROFILER_DIR="$TRACE_DIR"
fi

# Pin the physically qualified route. Reject rather than silently override it.
DEFAULT_ARGS=("--mem-fraction-static=0.5" "--disable-radix-cache" "--attention-backend=triton" "--disable-cuda-graph")
read -r -a EXTRA_SGLANG_ARGV <<< "${EXTRA_SGLANG_ARGS:-}"
for arg in "${EXTRA_SGLANG_ARGV[@]}"; do
case "$arg" in
--attention-backend|--attention-backend=*|--prefill-attention-backend|--prefill-attention-backend=*|--decode-attention-backend|--decode-attention-backend=*|--disable-cuda-graph|--enable-cuda-graph*)
echo "ERROR: sglang_radeon8060s pins Triton attention with CUDA graphs disabled; conflicting arg '$arg'." >&2
exit 2
;;
esac
done

set -x
if [[ "$PHASE" == "server" || "$PHASE" == "all" ]]; then
SERVER_CMD=(
python3 -m sglang.launch_server
--model-path "$MODEL"
--host 0.0.0.0
--port "$PORT"
--trust-remote-code
--tensor-parallel-size "$TP"
)
SERVER_CMD+=("${DEFAULT_ARGS[@]}")
SERVER_CMD+=("${EXTRA_SGLANG_ARGV[@]}")
setsid "${SERVER_CMD[@]}" > "$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 || exit $?
else
# InferenceX names its OpenAI-compatible completions client "vllm";
# SGLang serves that protocol, and this is the physically qualified path.
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" \
"${SERVER_MONITOR_ARGS[@]}" \
--result-dir ${RESULT_DIR:-/workspace/} \
--trust-remote-code || exit $?
fi
fi

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 "[sglang_radeon8060s] 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
177 changes: 177 additions & 0 deletions Magpie/scripts/benchmark/vllm_radeon8060s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#!/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 Radeon 8060S / gfx1151
#
# 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): when set, the client phase points
# benchmark_serving at an external vLLM-compatible HTTP endpoint
# instead of localhost:$PORT, and forces PHASE=client (no local server
# launch). 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_radeon8060s] 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.95}
for numeric in TP CONC ISL OSL MAX_MODEL_LEN PORT; do
value=${!numeric:-}
if [[ -n "$value" && ! "$value" =~ ^[0-9]+$ ]]; then
echo "ERROR: $numeric must be an unsigned integer, got '$value'." >&2
exit 2
fi
done
if [[ "$MODEL" == -* ]]; then
echo "ERROR: MODEL cannot begin with '-'." >&2
exit 2
fi

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

# Radeon 8060S / RDNA 3.5: pin native gfx1151 without architecture spoofing.
if [[ -n "${PYTORCH_ROCM_ARCH:-}" && "$PYTORCH_ROCM_ARCH" != "gfx1151" ]]; then
echo "ERROR: vllm_radeon8060s requires PYTORCH_ROCM_ARCH=gfx1151." >&2
exit 2
fi
export PYTORCH_ROCM_ARCH=gfx1151
export HSA_ENABLE_SDMA=${HSA_ENABLE_SDMA:-0}
unset HSA_OVERRIDE_GFX_VERSION

# 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 attention is not qualified for the tested gfx1151 geometry.
export VLLM_ROCM_USE_AITER=0
export VLLM_ROCM_USE_AITER_MHA=0
export VLLM_ROCM_USE_AITER_RMSNORM=0
unset VLLM_USE_AITER

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

read -r -a EXTRA_VLLM_ARGV <<< "${EXTRA_VLLM_ARGS:-}"

set -x
if [[ "$PHASE" == "server" || "$PHASE" == "all" ]]; then
SERVER_CMD=(
vllm serve "$MODEL"
--port "$PORT"
--tensor-parallel-size "$TP"
--gpu-memory-utilization "$GPU_MEMORY_UTILIZATION"
--max-model-len "$MAX_MODEL_LEN"
--trust-remote-code
)
SERVER_CMD+=("${PROFILER_ARGS[@]}")
SERVER_CMD+=("${EXTRA_VLLM_ARGV[@]}")
setsid "${SERVER_CMD[@]}" > "$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

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_radeon8060s] 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
2 changes: 1 addition & 1 deletion docs/how-to/benchmarking/benchmark.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Magpie's benchmark mode runs end-to-end performance tests against LLM inference

TraceLens is an AMD tool for visualizing profiler traces; it installs automatically on first use, but can also be installed manually—see [TraceLens installation](../../reference/troubleshooting.md#benchmarking-mode) if the auto-install fails.

Magpie uses [InferenceX](https://github.com/SemiAnalysisAI/InferenceX) as its benchmarking backend; InferenceX is a collection of benchmark scripts for LLM inference frameworks and is cloned automatically on first run. Use this mode to measure inference performance on AMD Instinct™ GPUs and identify the GPU kernels that dominate runtime.
Magpie uses [InferenceX](https://github.com/SemiAnalysisAI/InferenceX) as its benchmarking backend; InferenceX is a collection of benchmark scripts for LLM inference frameworks and is cloned automatically on first run. Use this mode to measure inference performance on AMD Instinct™ GPUs or the Radeon 8060S (`gfx1151`) and identify the GPU kernels that dominate runtime.

Review these topics for more information:

Expand Down
Loading