Skip to content

Commit 1330e4d

Browse files
authored
Fix duplicate flag addition and make sleep time configurable (#20)
* first commit * dont remove licence * revert todo
1 parent d46637a commit 1330e4d

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

latency_throughput_curve.sh

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16+
1617
set -o xtrace
1718

1819
export IP=$IP
@@ -24,48 +25,51 @@ if [[ "$PROMPT_DATASET" = "sharegpt" ]]; then
2425
fi
2526

2627
PYTHON="python3"
27-
PYTHON_OPTS="benchmark_serving.py "
28+
BASE_PYTHON_OPTS=(
29+
"benchmark_serving.py"
30+
"--save-json-results"
31+
"--host=$IP"
32+
"--port=$PORT"
33+
"--dataset=$PROMPT_DATASET_FILE"
34+
"--tokenizer=$TOKENIZER"
35+
"--backend=$BACKEND"
36+
"--max-input-length=$INPUT_LENGTH"
37+
"--max-output-length=$OUTPUT_LENGTH"
38+
"--file-prefix=$FILE_PREFIX"
39+
"--models=$MODELS"
40+
"--pm-namespace=$PM_NAMESPACE"
41+
"--pm-job=$PM_JOB"
42+
)
43+
44+
[[ "$TRAFFIC_SPLIT" ]] && BASE_PYTHON_OPTS+=("--traffic-split=$TRAFFIC_SPLIT")
45+
[[ "$OUTPUT_BUCKET" ]] && BASE_PYTHON_OPTS+=("--output-bucket=$OUTPUT_BUCKET")
46+
[[ "$SCRAPE_SERVER_METRICS" = "true" ]] && BASE_PYTHON_OPTS+=("--scrape-server-metrics")
47+
[[ "$SAVE_AGGREGATED_RESULT" = "true" ]] && BASE_PYTHON_OPTS+=("--save-aggregated-result")
48+
[[ "$STREAM_REQUEST" = "true" ]] && BASE_PYTHON_OPTS+=("--stream-request")
49+
[[ "$OUTPUT_BUCKET_FILEPATH" ]] && BASE_PYTHON_OPTS+=("--output-bucket-filepath" "$OUTPUT_BUCKET_FILEPATH")
50+
51+
SLEEP_TIME=${SLEEP_TIME:-0}
52+
2853
for request_rate in $(echo $REQUEST_RATES | tr ',' ' '); do
2954
echo "Benchmarking request rate: ${request_rate}"
3055
# TODO: Check if profile already exists, if so then skip
3156
timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
3257
output_file="latency-profile-${timestamp}.txt"
33-
if [ ${request_rate} == 0 ]; then
58+
59+
if [ "$request_rate" == "0" ]; then
3460
request_rate="inf"
3561
num_prompts=$MAX_NUM_PROMPTS
3662
else
3763
num_prompts=$(awk "BEGIN {print int($request_rate * $BENCHMARK_TIME_SECONDS)}")
3864
fi
39-
40-
echo "TOTAL prompts: $num_prompts"
41-
42-
# Build the python command options
43-
PYTHON_OPTS="$PYTHON_OPTS --save-json-results --host=$IP --port=$PORT --dataset=$PROMPT_DATASET_FILE --tokenizer=$TOKENIZER --request-rate=$request_rate --backend=$BACKEND --num-prompts=$num_prompts --max-input-length=$INPUT_LENGTH --max-output-length=$OUTPUT_LENGTH --file-prefix=$FILE_PREFIX --models=$MODELS --pm-namespace=$PM_NAMESPACE --pm-job=$PM_JOB"
4465

45-
if [[ "$TRAFFIC_SPLIT" ]]; then
46-
PYTHON_OPTS="$PYTHON_OPTS --traffic-split=$TRAFFIC_SPLIT"
47-
fi
48-
49-
if [[ "$OUTPUT_BUCKET" ]]; then
50-
PYTHON_OPTS="$PYTHON_OPTS --output-bucket=$OUTPUT_BUCKET"
51-
fi
52-
53-
if [[ "$SCRAPE_SERVER_METRICS" = "true" ]]; then
54-
PYTHON_OPTS="$PYTHON_OPTS --scrape-server-metrics"
55-
fi
56-
if [[ "$SAVE_AGGREGATED_RESULT" = "true" ]]; then
57-
PYTHON_OPTS="$PYTHON_OPTS --save-aggregated-result"
58-
fi
59-
if [[ "$STREAM_REQUEST" = "true" ]]; then
60-
PYTHON_OPTS="$PYTHON_OPTS --stream-request"
61-
fi
62-
if [[ "$OUTPUT_BUCKET_FILEPATH" ]]; then
63-
PYTHON_OPTS="$PYTHON_OPTS --output-bucket-filepath $OUTPUT_BUCKET_FILEPATH"
64-
fi
66+
echo "TOTAL prompts: $num_prompts"
67+
PYTHON_OPTS=("${BASE_PYTHON_OPTS[@]}" "--request-rate=$request_rate" "--num-prompts=$num_prompts")
6568

66-
$PYTHON $PYTHON_OPTS > $output_file
67-
cat $output_file
68-
sleep 30 # wait 30 seconds before next run to ensure metrics isolation
69+
$PYTHON "${PYTHON_OPTS[@]}" > "$output_file"
70+
cat "$output_file"
71+
echo "Sleeping for $SLEEP_TIME seconds..."
72+
sleep $SLEEP_TIME
6973
done
7074

7175
export LPG_FINISHED="true"

0 commit comments

Comments
 (0)