Skip to content
Closed
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
13 changes: 8 additions & 5 deletions scripts/rdna_launcher_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ rdna_init() {
export GPU_MAX_HW_QUEUES=${GPU_MAX_HW_QUEUES:-2}
export VLLM_ROCM_USE_AITER=${VLLM_ROCM_USE_AITER:-0}
export VLLM_ROCM_USE_AITER_MOE=${VLLM_ROCM_USE_AITER_MOE:-0}
export VLLM_RDNA_FORCE_FP16=${VLLM_RDNA_FORCE_FP16:-1}
export TORCH_BLAS_PREFER_HIPBLASLT=${TORCH_BLAS_PREFER_HIPBLASLT:-0}
export VLLM_BATCH_INVARIANT=${VLLM_BATCH_INVARIANT:-0}

Expand Down Expand Up @@ -139,13 +138,17 @@ rdna_run_cwd() {
}

rdna_kill_stale() {
local _sig _p
local _sig _p _signaled=0
for _sig in TERM KILL; do
for _p in $(pgrep -f "entrypoints.cli.main serve|entrypoints.openai.api_server|VLLM::Worker|VLLM::EngineCore|PleOffloadWorker" 2>/dev/null); do
[ -r "/proc/$_p/environ" ] || continue
tr '\0' '\n' < "/proc/$_p/environ" 2>/dev/null | grep -q "^VLLM_CACHE_ROOT=${VLLM_CACHE_ROOT}$" && kill -"$_sig" "$_p" 2>/dev/null
tr '\0' '\n' < "/proc/$_p/environ" 2>/dev/null | grep -q "^VLLM_CACHE_ROOT=${VLLM_CACHE_ROOT}$" && kill -"$_sig" "$_p" 2>/dev/null && _signaled=1
done
[ "$_sig" = TERM ] && sleep 8
if [ "$_sig" = TERM ] && [ "$_signaled" = 1 ]; then
sleep 8
fi
done
sleep 3
if [ "$_signaled" = 1 ]; then
sleep 3
fi
}
1 change: 0 additions & 1 deletion scripts/recipes/flashnext-mtp0.env
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ VLLM_PLE_CPU_OFFLOAD=1

# --- RDNA vLLM env block ---
VLLM_USE_V2_MODEL_RUNNER=1
VLLM_ROCM_MOE_PREFILL=0
VLLM_GDN_HIP_PREFILL=0
VLLM_RDNA_FUSED_SE=1
VLLM_RDNA_DENSE_INT8=0
Expand Down
1 change: 0 additions & 1 deletion scripts/recipes/flashnext-mtp2.env
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ VLLM_PLE_CPU_OFFLOAD=1

# --- RDNA vLLM env block ---
VLLM_USE_V2_MODEL_RUNNER=1
VLLM_ROCM_MOE_PREFILL=0
VLLM_GDN_HIP_PREFILL=0
VLLM_RDNA_FUSED_SE=1
VLLM_RDNA_DENSE_INT8=0
Expand Down
2 changes: 0 additions & 2 deletions scripts/recipes/full.env
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ ALLOC_CONF=auto
# --- RDNA vLLM env block ---
VLLM_USE_V2_MODEL_RUNNER=1
VLLM_USE_RDNA2_FA=1
# Do not hash the live last hybrid GDN+FA page while decode is appending.
VLLM_ROCM_SKIP_LIVE_TAIL_HASH=1
VLLM_USE_AOT_COMPILE=0
VLLM_DISABLE_COMPILE_CACHE=1
FLASH_ATTENTION_TRITON_AMD_ENABLE=TRUE
Expand Down
5 changes: 2 additions & 3 deletions scripts/serve_rdna.sh
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ RDSE_ENV_KEYS=(
LD_LIBRARY_PATH ROCM_HOME ROCM_PATH HIP_PATH HIP_ROOT_DIR
PYTHONPATH HF_HUB_OFFLINE TRANSFORMERS_OFFLINE
HIP_VISIBLE_DEVICES VLLM_WORKER_MULTIPROC_METHOD GPU_MAX_HW_QUEUES
VLLM_ROCM_USE_AITER VLLM_ROCM_USE_AITER_MOE VLLM_RDNA_FORCE_FP16
VLLM_ROCM_USE_AITER VLLM_ROCM_USE_AITER_MOE
TORCH_BLAS_PREFER_HIPBLASLT VLLM_BATCH_INVARIANT
VLLM_CACHE_ROOT TRITON_CACHE_DIR TORCHINDUCTOR_CACHE_DIR TORCH_EXTENSIONS_DIR
PYTORCH_TUNABLEOP_ENABLED PYTORCH_TUNABLEOP_TUNING
Expand All @@ -323,14 +323,13 @@ RDSE_ENV_KEYS=(
FLASH_ATTENTION_TRITON_AMD_ENABLE
VLLM_USE_V2_MODEL_RUNNER VLLM_USE_AOT_COMPILE VLLM_DISABLE_COMPILE_CACHE
VLLM_USE_BREAKABLE_CUDAGRAPH VLLM_RDNA_FUSED_HC
VLLM_ROCM_MOE_PREFILL VLLM_GDN_HIP_PREFILL VLLM_RDNA_FUSED_SE
VLLM_GDN_HIP_PREFILL VLLM_RDNA_FUSED_SE
VLLM_RDNA_DENSE_INT8 VLLM_RDNA_DENSE_INT8_ONLY VLLM_RDNA_DENSE_GEMV
VLLM_RDNA2_W4A8_SDOT4 VLLM_RDNA2_W4A8_DEBUG
VLLM_FORCE_CUSTOM_ALL_REDUCE VLLM_RDNA_AR VLLM_RDNA_AR_MAX_KB
VLLM_RDNA_AR_ONESHOT_KB VLLM_RDNA_AR_BLOCKS VLLM_RDNA_AR_PACE
VLLM_CAUSAL_CONV1D_RDNA2_FWD VLLM_CAUSAL_CONV1D_RDNA2_UPDATE
VLLM_ENABLE_STARTUP_PLAN VLLM_TUNED_CONFIG_FOLDER
VLLM_ROCM_SKIP_LIVE_TAIL_HASH
VLLM_PLE_CPU_OFFLOAD VLLM_PLE_OFFLOAD_READY_TIMEOUT VLLM_PLE_QUANT_DIR
VLLM_EXL3_DEBUG
NCCL_P2P_LEVEL RCCL_P2P_NET_DISABLE RCCL_P2P_BATCH_ENABLE NCCL_PROTO
Expand Down
157 changes: 1 addition & 156 deletions tools/rdna2/tunableop_env.sh
Original file line number Diff line number Diff line change
@@ -1,160 +1,5 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
#
# Profile-aware TunableOp helper for the RDNA fork.
#
# This is the tools/rdna2 mirror of tools/rdna2_028/tunableop_env.sh; the two
# files are kept byte-identical below this header. Prefer the rdna2_028 copy.
#
# configure_tunableop <librocblas.so.5 path> <tunableop dir> [profile]
#
# Rows live in <tunableop dir>/<profile-dir>/tunableop_results{0..3}.csv, one
# folder per rocBLAS build, registered in <tunableop dir>/profiles.json
# (name -> {dir, lib_sha256, rocblas, rocm, torch, rows_per_rank, status}).
# Solver IDs are build-specific, so rows are only ever used for the rocBLAS
# build that produced them.
#
# Selection:
# * explicit (third argument or $TUNABLEOP_PROFILE): use that profile and
# validate its lib_sha256 against the loaded library. A mismatch makes the
# launch fail (return 1) unless TUNABLEOP_ALLOW_MISMATCH=1, which warns
# hard and proceeds anyway.
# * default: auto-select the profile whose lib_sha256[:12] equals the loaded
# library's sha256[:12].
# * no registered match: a legacy <tunableop dir>/rocblas-<sha12>/ folder is
# still honoured, then the per-user fallback
# $HOME/.cache/tunableop/tunableop_results.csv (created).
#
# Lookup only by default (PYTORCH_TUNABLEOP_TUNING=0); set TUNING=1 to re-tune
# shapes missing from the table. Rows are never written to /tmp or the run CWD.
#
# configure_mtp_tunableop is an alias so existing callers do not break.
# configure_v620_tunableop keeps the historical strict behaviour (lookup is
# disabled unless this build's four rank files exist; no per-user fallback).

# Print "<name>\t<dir>\t<lib_sha256>" for every profile in the registry.
# Empty (and non-zero) when the registry is absent or unparseable.
_tunableop_profiles() {
local registry=$1
[ -r "$registry" ] || return 1
if command -v python3 >/dev/null 2>&1; then
python3 -c 'import json, sys
try:
prof = json.load(open(sys.argv[1])).get("profiles", {})
except Exception:
sys.exit(0)
for name in sorted(prof):
p = prof[name] or {}
d, s = p.get("dir"), p.get("lib_sha256")
if d and s:
print("%s\t%s\t%s" % (name, d, s))' "$registry" 2>/dev/null
elif command -v jq >/dev/null 2>&1; then
jq -r '.profiles // {} | to_entries[]
| select(.value.dir and .value.lib_sha256)
| "\(.key)\t\(.value.dir)\t\(.value.lib_sha256)"' \
"$registry" 2>/dev/null
fi
}

configure_tunableop() {
local library=${1:-} rows_root=${2:-} requested=${3:-${TUNABLEOP_PROFILE:-}}
local library_id selected_name="" rows_dir profile_line tune_state canonical
local profile_dir profile_sha
export PYTORCH_TUNABLEOP_HIPBLASLT_ENABLED=0
export PYTORCH_TUNABLEOP_TUNING=${PYTORCH_TUNABLEOP_TUNING:-0}
export PYTORCH_TUNABLEOP_ENABLED=0
unset PYTORCH_TUNABLEOP_FILENAME
canonical=${TUNEOP_PER_USER_DIR:-$HOME/.cache/tunableop}
mkdir -p -- "$canonical" 2>/dev/null || true

if [[ -z $library || ! -f $library ]]; then
printf 'WARNING: TunableOp lookup disabled: rocBLAS library "%s" is unavailable; using default FP16 algorithms.\n' "$library" >&2
return 0
fi

library_id=$(sha256sum -- "$library")
library_id=${library_id:0:12}

if [[ -n $requested ]]; then
profile_line=$(_tunableop_profiles "$rows_root/profiles.json" |
awk -F'\t' -v n="$requested" '$1 == n { print; exit }')
if [[ -z $profile_line ]]; then
printf 'ERROR: TunableOp profile "%s" is not registered in %s/profiles.json; refusing to start.\n' \
"$requested" "$rows_root" >&2
return 1
fi
selected_name=${profile_line%%$'\t'*}
profile_dir=$(printf '%s' "$profile_line" | cut -f2)
profile_sha=$(printf '%s' "$profile_line" | cut -f3)
if [[ ${profile_sha:0:12} != "$library_id" ]]; then
if [[ ${TUNABLEOP_ALLOW_MISMATCH:-0} == 1 ]]; then
printf 'WARNING: TunableOp profile "%s" was tuned for rocBLAS %s but the loaded library is %s; TUNABLEOP_ALLOW_MISMATCH=1 set, using it anyway (results may be wrong or slow).\n' \
"$selected_name" "${profile_sha:0:12}" "$library_id" >&2
else
printf 'ERROR: TunableOp profile "%s" was tuned for rocBLAS %s, but the loaded librocblas.so.5 hashes to %s. Solver IDs are build-specific; refusing to start. Unset TUNABLEOP_PROFILE to auto-select, or set TUNABLEOP_ALLOW_MISMATCH=1 to override (experiments only).\n' \
"$selected_name" "${profile_sha:0:12}" "$library_id" >&2
return 1
fi
fi
rows_dir=$rows_root/$profile_dir
else
profile_line=$(_tunableop_profiles "$rows_root/profiles.json" |
awk -F'\t' -v h="$library_id" 'substr($3, 1, 12) == h { print; exit }')
if [[ -n $profile_line ]]; then
selected_name=${profile_line%%$'\t'*}
profile_dir=$(printf '%s' "$profile_line" | cut -f2)
rows_dir=$rows_root/$profile_dir
else
# Legacy hash-named folder, then the per-user fallback below.
rows_dir=$rows_root/rocblas-$library_id
fi
fi

for rank in 0 1 2 3; do
if [[ ! -s $rows_dir/tunableop_results$rank.csv ]]; then
if [[ ${TUNEOP_REQUIRE_HASH_ROWS:-0} == 1 ]]; then
printf 'WARNING: TunableOp disabled: missing rank %s rows for rocBLAS %s at %s; using default FP16 algorithms.\n' \
"$rank" "$library_id" "$rows_dir" >&2
return 0
fi
tune_state=off
[[ $PYTORCH_TUNABLEOP_TUNING == 1 ]] && tune_state=enabled
printf 'WARNING: no fork rows for rocBLAS build %s (rank %s missing) at %s; falling back to per-user %s (tuning %s).\n' \
"$library_id" "$rank" "$rows_dir" "$canonical/tunableop_results.csv" "$tune_state" >&2
export PYTORCH_TUNABLEOP_FILENAME=$canonical/tunableop_results.csv
export PYTORCH_TUNABLEOP_ENABLED=1
return 0
fi
done

tune_state=off
[[ $PYTORCH_TUNABLEOP_TUNING == 1 ]] && tune_state=enabled
export PYTORCH_TUNABLEOP_FILENAME=$rows_dir/tunableop_results.csv
export PYTORCH_TUNABLEOP_ENABLED=1
if [[ -n $selected_name ]]; then
if [[ -n $requested ]]; then
printf 'TunableOp profile %s selected for rocBLAS build %s (rows: %s); tuning %s.\n' \
"$selected_name" "$library_id" "$rows_dir" "$tune_state" >&2
else
printf 'TunableOp profile %s auto-selected for rocBLAS build %s.\n' \
"$selected_name" "$library_id" >&2
printf 'TunableOp lookup enabled for profile %s (rocBLAS %s; rows: %s); tuning %s (set PYTORCH_TUNABLEOP_TUNING=1 to re-tune missing shapes).\n' \
"$selected_name" "$library_id" "$rows_dir" "$tune_state" >&2
fi
else
printf 'TunableOp lookup enabled for rocBLAS build %s (rows: %s); tuning %s.\n' \
"$library_id" "$rows_dir" "$tune_state" >&2
fi
}

# Alias kept for the MTP/Flash-Next launchers and other existing callers.
configure_mtp_tunableop() {
configure_tunableop "$@"
}

# Historical V620 entry point: same as the generic helper but strict about the
# hash-matched rank files (no per-user fallback). Callers unchanged.
configure_v620_tunableop() {
TUNEOP_REQUIRE_HASH_ROWS=1 configure_tunableop "$@"
}
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../rdna2_028/tunableop_env.sh"
6 changes: 0 additions & 6 deletions tools/rdna2_028/tunableop_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
# Lookup only by default (PYTORCH_TUNABLEOP_TUNING=0); set TUNING=1 to re-tune
# shapes missing from the table. Rows are never written to /tmp or the run CWD.
#
# configure_mtp_tunableop is an alias so existing callers do not break.
# configure_v620_tunableop keeps the historical strict behaviour (lookup is
# disabled unless this build's four rank files exist; no per-user fallback).

Expand Down Expand Up @@ -145,11 +144,6 @@ configure_tunableop() {
fi
}

# Alias kept for the MTP/Flash-Next launchers and other existing callers.
configure_mtp_tunableop() {
configure_tunableop "$@"
}

# Historical V620 entry point: same as the generic helper but strict about the
# hash-matched rank files (no per-user fallback). Callers unchanged.
configure_v620_tunableop() {
Expand Down
Loading