sglang tp_dp_matrix: fix timeout calling bash function (rc=127)

timeout(1) cannot execute shell functions directly; it needs a standalone
command. Export run_bench_serving via export -f and wrap both warmup and
scenario runs in bash -c so the function is visible in the subshell.
This commit is contained in:
yy-fighting 2026-07-10 02:51:29 +00:00
parent 938b2f1e88
commit 4ea6e92b42

View File

@ -132,26 +132,29 @@ run_bench_serving() {
"$PYTHON" -m sglang.bench_serving "$@"
fi
}
export -f run_bench_serving
run_warmup() {
local input_len="$1"
local output_len="$2"
log "warming up (input=${input_len}, output=${output_len}, num=1)"
bash -c '
run_bench_serving \
--backend sglang \
--host 127.0.0.1 \
--port "$SGLANG_PORT" \
--port "'"$SGLANG_PORT"'" \
--dataset-name random \
--dataset-path "$DATASET_PATH" \
--random-input-len "$input_len" \
--random-output-len "$output_len" \
--dataset-path "'"$DATASET_PATH"'" \
--random-input-len "'"$input_len"'" \
--random-output-len "'"$output_len"'" \
--num-prompts 1 \
--max-concurrency 1 \
--request-rate 10000 \
--output-file /dev/null \
--output-details \
>> "${log_dir_global}/warmup.log" 2>&1
>> "'"${log_dir_global}/warmup.log"'" 2>&1
'
log "warmup completed"
}
@ -415,21 +418,22 @@ run_parallel_config() {
gpu_pid="$(start_gpu_monitor "$gpu_csv")"
bench_rc=0
timeout "$SCENARIO_TIMEOUT_S" \
timeout "$SCENARIO_TIMEOUT_S" bash -c '
run_bench_serving \
--backend sglang \
--host 127.0.0.1 \
--port "$SGLANG_PORT" \
--port "'"$SGLANG_PORT"'" \
--dataset-name random \
--dataset-path "$DATASET_PATH" \
--random-input-len "$isl" \
--random-output-len "$dsl" \
--num-prompts "$num" \
--max-concurrency "$conc" \
--dataset-path "'"$DATASET_PATH"'" \
--random-input-len "'"$isl"'" \
--random-output-len "'"$dsl"'" \
--num-prompts "'"$num"'" \
--max-concurrency "'"$conc"'" \
--request-rate 10000 \
--output-file "$output_file" \
--output-file "'"$output_file"'" \
--output-details \
> "$detail_log" 2>&1 || bench_rc=$?
> "'"$detail_log"'" 2>&1
' || bench_rc=$?
stop_gpu_monitor "$gpu_pid"