Skip to content

Commit bb4f45f

Browse files
seungrokjclaude
andcommitted
feat(agentic-mtp): add cache metrics capture and eval-only support
Add capture_cache_metrics() to snapshot SGLang cache/usage metrics before and after benchmark runs for debugging. Add eval-only mode branch to run_eval instead of replay when EVAL_ONLY=true. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fac0fc5 commit bb4f45f

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

benchmarks/single_node/agentic/dsv4_fp4_mi355x_sglang_mtp.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ echo "Starting SGLang server for MI355X..."
169169
SERVER_PID=$!
170170
echo "Server PID: $SERVER_PID"
171171

172+
capture_cache_metrics() {
173+
{
174+
echo "=== SGLang cache metrics snapshot $(date --iso-8601=seconds) ==="
175+
curl -fsS "http://localhost:$SGLANG_BACKEND_PORT/metrics" 2>/dev/null \
176+
| grep -E '^(sglang:(cache_hit_rate|cached_tokens_total|prompt_tokens_total|hicache_host_used_tokens|hicache_host_total_tokens|token_usage|num_requests_running|num_requests_waiting))' \
177+
|| true
178+
echo "============================================================"
179+
} >> "$SERVER_LOG"
180+
}
181+
172182
wait_for_server_ready --port "$SGLANG_BACKEND_PORT" --server-log "$SERVER_LOG" --server-pid "$SERVER_PID"
173183

174184
if [ "$USE_SGLANG_ROUTER" = "true" ]; then
@@ -190,9 +200,17 @@ if [ "$USE_SGLANG_ROUTER" = "true" ]; then
190200
echo "Router PID: $ROUTER_PID"
191201
wait_for_server_ready --port "$PORT" --server-log "$ROUTER_LOG" --server-pid "$ROUTER_PID"
192202
fi
193-
194203
# ---- Run benchmark ----------------------------------------------------------
195-
build_replay_cmd "$RESULT_DIR"
196-
REPLAY_CMD+=" --server-metrics http://localhost:$SGLANG_BACKEND_PORT/metrics"
197204

198-
run_agentic_replay_and_write_outputs "$RESULT_DIR"
205+
if [ "${#METRICS_ARGS[@]}" -gt 0 ]; then
206+
capture_cache_metrics
207+
trap capture_cache_metrics EXIT
208+
fi
209+
210+
if [ "${EVAL_ONLY}" = "true" ]; then
211+
run_eval --port "$PORT"
212+
else
213+
build_replay_cmd "$RESULT_DIR"
214+
REPLAY_CMD+=" --server-metrics http://localhost:$SGLANG_BACKEND_PORT/metrics"
215+
run_agentic_replay_and_write_outputs "$RESULT_DIR"
216+
fi

0 commit comments

Comments
 (0)