|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Agentic trace-replay recipe for a disaggregated SGLang server on MI355X |
| 4 | +# (DeepSeek-V4-Pro FP4, 1P1D TP8). |
| 5 | +# |
| 6 | +# CI-style sibling of dsr1_fp4_mi355x_sglang-disagg.sh: driven entirely by |
| 7 | +# environment variables and submits a SLURM job via submit.sh. The agentic / |
| 8 | +# HiCache-offload configuration mirrors the DSR1 recipe but uses DSV4-Pro |
| 9 | +# specific flags (dsv4 attention backend, page-size 256, SWA settings). |
| 10 | + |
| 11 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 12 | +source "$SCRIPT_DIR/../../benchmark_lib.sh" |
| 13 | + |
| 14 | +check_env_vars \ |
| 15 | + CONC_LIST \ |
| 16 | + ISL \ |
| 17 | + OSL \ |
| 18 | + IMAGE \ |
| 19 | + SPEC_DECODING \ |
| 20 | + MODEL_PATH \ |
| 21 | + PREFILL_NUM_WORKERS \ |
| 22 | + PREFILL_TP \ |
| 23 | + PREFILL_EP \ |
| 24 | + PREFILL_DP_ATTN \ |
| 25 | + DECODE_NUM_WORKERS \ |
| 26 | + DECODE_TP \ |
| 27 | + DECODE_EP \ |
| 28 | + DECODE_DP_ATTN \ |
| 29 | + PREFILL_NODES \ |
| 30 | + DECODE_NODES \ |
| 31 | + RANDOM_RANGE_RATIO \ |
| 32 | + DURATION \ |
| 33 | + KV_OFFLOADING \ |
| 34 | + IS_AGENTIC \ |
| 35 | + FRAMEWORK |
| 36 | + |
| 37 | +if [[ -n "$SLURM_JOB_ID" ]]; then |
| 38 | + echo "JOB $SLURM_JOB_ID running on $SLURMD_NODENAME" |
| 39 | +fi |
| 40 | + |
| 41 | +set -x |
| 42 | + |
| 43 | +# Use upstreamed multi_node scripts (no external clone needed) |
| 44 | +cd "$GITHUB_WORKSPACE/benchmarks/multi_node/amd_utils" || exit 1 |
| 45 | + |
| 46 | +# Set up SGL launch script-specific environment variables |
| 47 | +export TIME_LIMIT="${TIME_LIMIT:-08:00:00}" |
| 48 | +export MODEL_PATH=$MODEL_PATH |
| 49 | +export MODEL_NAME=$MODEL_NAME |
| 50 | +export CONTAINER_IMAGE=$IMAGE |
| 51 | + |
| 52 | +# ── Identity / result naming ── |
| 53 | +export MODEL_PREFIX="${MODEL_PREFIX:-dsv4}" |
| 54 | +export PRECISION="${PRECISION:-fp4}" |
| 55 | +export RESULT_FILENAME="${RESULT_FILENAME:-${RUNNER_NAME:-dsv4-fp4-agentic}}" |
| 56 | + |
| 57 | +# ── Agentic benchmark params ── |
| 58 | +export DURATION="${DURATION:-1800}" |
| 59 | +# DSV4-Pro max model len for agentic traces (matches single-node recipe). |
| 60 | +export MAX_MODEL_LEN="${MAX_MODEL_LEN:-1000000}" |
| 61 | + |
| 62 | +# ── In-tree sglang patches ── |
| 63 | +# mori_conn.py targets hybrid-state bugs (GLM-5, Qwen3.5). DSV4-Pro uses a |
| 64 | +# pure MoE/DSA architecture without hybrid state; skip to avoid interference. |
| 65 | +export MORI_CONN_PATCH="${MORI_CONN_PATCH:-skip}" |
| 66 | + |
| 67 | +# ── Aiter fault mitigation ── |
| 68 | +# --disable-custom-all-reduce avoids a known aiter fault on MI355X. |
| 69 | +export DISABLE_CUSTOM_ALL_REDUCE="${DISABLE_CUSTOM_ALL_REDUCE:-0}" |
| 70 | + |
| 71 | +# ── KV cache offloading (HiCache) ── |
| 72 | +# KV_OFFLOADING=none | dram (passed from YAML; default none for disagg). |
| 73 | +# KV_OFFLOAD_BACKEND selects the backend when offloading is on; this recipe |
| 74 | +# only implements HiCache, so "hicache" is the only supported value. |
| 75 | +# HICACHE_TIER: L2 -> GPU + CPU-DRAM host pool. L3 -> + Mooncake store. |
| 76 | +export KV_OFFLOADING="${KV_OFFLOADING:-none}" |
| 77 | +if [[ "$KV_OFFLOADING" != "none" ]]; then |
| 78 | + export KV_OFFLOAD_BACKEND="${KV_OFFLOAD_BACKEND:-hicache}" |
| 79 | +fi |
| 80 | +# HiCache/Mooncake tunables only matter when KV offloading is enabled. |
| 81 | +if [[ "$KV_OFFLOADING" != "none" && "${KV_OFFLOAD_BACKEND:-}" == "hicache" ]]; then |
| 82 | + export HICACHE_TIER="${HICACHE_TIER:-L2}" |
| 83 | + export HICACHE_HOST_POOL_COUNT="${HICACHE_HOST_POOL_COUNT:-1}" |
| 84 | + # DSV4 uses page-size 256 (set in models.yaml); HiCache must match. |
| 85 | + export HICACHE_PAGE_SIZE="${HICACHE_PAGE_SIZE:-256}" |
| 86 | + # HiCache ratio (host pool = ratio * GPU KV pool). Default derived in server_sglang.sh. |
| 87 | + export HICACHE_RATIO="${HICACHE_RATIO:-}" |
| 88 | + |
| 89 | + # ── HiCache layout/backend by tier ── |
| 90 | + # L3 (Mooncake): page_first + direct + write_through + storage=mooncake |
| 91 | + # L2 (CPU DRAM): layer_first + direct + write_through_selective + storage=none |
| 92 | + # NOTE: write_through_selective evicts only under GPU memory pressure, avoiding |
| 93 | + # the mori RDMA race that causes GPU memory access faults with write_through. |
| 94 | + if [[ "${HICACHE_TIER^^}" == "L3" ]]; then |
| 95 | + export HICACHE_MEM_LAYOUT="${HICACHE_MEM_LAYOUT:-page_first}" |
| 96 | + export HICACHE_IO_BACKEND="${HICACHE_IO_BACKEND:-direct}" |
| 97 | + export HICACHE_WRITE_POLICY="${HICACHE_WRITE_POLICY:-write_through}" |
| 98 | + export HICACHE_STORAGE_BACKEND="${HICACHE_STORAGE_BACKEND:-mooncake}" |
| 99 | + else |
| 100 | + export HICACHE_MEM_LAYOUT="${HICACHE_MEM_LAYOUT:-page_first}" |
| 101 | + export HICACHE_IO_BACKEND="${HICACHE_IO_BACKEND:-direct}" |
| 102 | + export HICACHE_WRITE_POLICY="${HICACHE_WRITE_POLICY:-write_through}" |
| 103 | + export HICACHE_STORAGE_BACKEND="${HICACHE_STORAGE_BACKEND:-}" |
| 104 | + fi |
| 105 | + export HICACHE_PREFETCH_POLICY="${HICACHE_PREFETCH_POLICY:-best_effort}" |
| 106 | + # Shared nodes: use non-default Mooncake ports to avoid collisions. |
| 107 | + export MC_MASTER_PORT="${MC_MASTER_PORT:-58137}" |
| 108 | + export MC_METADATA_PORT="${MC_METADATA_PORT:-8080}" |
| 109 | + export MC_METRICS_PORT="${MC_METRICS_PORT:-19003}" |
| 110 | + export MC_MASTER_THREADS="${MC_MASTER_THREADS:-64}" |
| 111 | + export MC_EVICTION_HIGH_WATERMARK="${MC_EVICTION_HIGH_WATERMARK:-0.95}" |
| 112 | + export MC_PATCH_HOSTPOOL="${MC_PATCH_HOSTPOOL:-1}" |
| 113 | + export MC_PROTOCOL="${MC_PROTOCOL:-tcp}" |
| 114 | + export MC_GLOBAL_SEG="${MC_GLOBAL_SEG:-64gb}" |
| 115 | + export MC_DEVICE="${MC_DEVICE:-}" |
| 116 | + export MC_MASTER_ADDR="${MC_MASTER_ADDR:-}" |
| 117 | + export MC_METADATA_SERVER="${MC_METADATA_SERVER:-}" |
| 118 | +fi |
| 119 | + |
| 120 | +# ── MoRIIO RDMA Send Queue tuning ── |
| 121 | +export MORI_IO_SQ_BACKOFF_TIMEOUT_US="${MORI_IO_SQ_BACKOFF_TIMEOUT_US:-500000}" |
| 122 | +export MORI_IO_QP_MAX_SEND_WR="${MORI_IO_QP_MAX_SEND_WR:-32768}" |
| 123 | + |
| 124 | +# ── SGLang PD router policy + server metrics ── |
| 125 | +export PREFILL_ROUTER_POLICY="${PREFILL_ROUTER_POLICY:-cache_aware}" |
| 126 | +export ENABLE_METRICS="${ENABLE_METRICS:-1}" |
| 127 | + |
| 128 | +# ── MTP ── |
| 129 | +export DECODE_MTP_SIZE="${DECODE_MTP_SIZE:-0}" |
| 130 | + |
| 131 | +# Derive EP/DP enable flags from the topology inputs. |
| 132 | +if [[ "${PREFILL_EP:-1}" -eq 1 ]]; then |
| 133 | +export PREFILL_ENABLE_EP=false |
| 134 | +else |
| 135 | +export PREFILL_ENABLE_EP=true |
| 136 | +fi |
| 137 | + |
| 138 | +if [[ "$PREFILL_DP_ATTN" == "true" ]]; then |
| 139 | +export PREFILL_ENABLE_DP=true |
| 140 | +else |
| 141 | +export PREFILL_ENABLE_DP=false |
| 142 | +fi |
| 143 | + |
| 144 | +if [[ "${DECODE_EP:-1}" -eq 1 ]]; then |
| 145 | +export DECODE_ENABLE_EP=false |
| 146 | +else |
| 147 | +export DECODE_ENABLE_EP=true |
| 148 | +fi |
| 149 | + |
| 150 | +if [[ "$DECODE_DP_ATTN" == "true" ]]; then |
| 151 | +export DECODE_ENABLE_DP=true |
| 152 | +else |
| 153 | +export DECODE_ENABLE_DP=false |
| 154 | +fi |
| 155 | + |
| 156 | +# Launch the job. CONC_LIST is space-delimited in YAML; submit.sh wants 'x'. |
| 157 | +JOB_ID=$(bash ./submit.sh $PREFILL_NODES \ |
| 158 | + $PREFILL_NUM_WORKERS \ |
| 159 | + $DECODE_NODES \ |
| 160 | + $DECODE_NUM_WORKERS \ |
| 161 | + $ISL $OSL "${CONC_LIST// /x}" inf \ |
| 162 | + ${PREFILL_ENABLE_EP} ${PREFILL_ENABLE_DP} \ |
| 163 | + ${DECODE_ENABLE_EP} ${DECODE_ENABLE_DP} \ |
| 164 | + ${PREFILL_TP} ${DECODE_TP} \ |
| 165 | + ${RANDOM_RANGE_RATIO}) |
| 166 | + |
| 167 | +if [[ $? -ne 0 ]]; then |
| 168 | + echo "Failed to submit job" >&2 |
| 169 | + exit 1 |
| 170 | +fi |
| 171 | + |
| 172 | +echo "$JOB_ID" |
0 commit comments