diff --git a/scripts/validate.sh b/scripts/validate.sh index b3fccf1..edac8e5 100755 --- a/scripts/validate.sh +++ b/scripts/validate.sh @@ -26,12 +26,12 @@ for i in $(seq 1 300); do sleep 2 done -# Send the request and capture timing +# Send two parallel requests and capture timing echo "" -echo "Sending validation prompt..." +echo "Sending 2 parallel validation prompts..." START_TIME=$(date +%s%N) -RESPONSE=$(curl -s \ +RESPONSE1=$(curl -s \ -X POST "http://${HOST}:${PORT}/v1/chat/completions" \ -H "Content-Type: application/json" \ -d "{ @@ -41,26 +41,45 @@ RESPONSE=$(curl -s \ \"max_tokens\": ${MAX_TOKENS}, \"temperature\": 0.7, \"top_p\": 0.95 - }") + }" &) + +RESPONSE2=$(curl -s \ + -X POST "http://${HOST}:${PORT}/v1/chat/completions" \ + -H "Content-Type: application/json" \ + -d "{ + \"messages\": [ + {\"role\": \"user\", \"content\": \"Write a detailed analysis of the geopolitical consequences of the fall of the Byzantine Empire in 1453. Trace the chain of events from the Ottoman conquest of Constantinople through the next two centuries, covering at minimum: the shift in Mediterranean trade routes, the Italian Renaissance's relationship with fleeing Greek scholars, the Russian claim to Roman succession, and the papal response. Then compare how the region might have developed differently had Constantinople remained independent.\"} + ], + \"max_tokens\": ${MAX_TOKENS}, + \"temperature\": 0.7, + \"top_p\": 0.95 + }" &) + +wait END_TIME=$(date +%s%N) -# Extract token counts and timing from response -COMPLETION_TOKENS=$(echo "$RESPONSE" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['usage']['completion_tokens'])" 2>/dev/null || echo "0") +# Extract token counts and timing from responses +COMPLETION_TOKENS1=$(echo "$RESPONSE1" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['usage']['completion_tokens'])" 2>/dev/null || echo "0") +COMPLETION_TOKENS2=$(echo "$RESPONSE2" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['usage']['completion_tokens'])" 2>/dev/null || echo "0") +TOTAL_TOKENS=$((COMPLETION_TOKENS1 + COMPLETION_TOKENS2)) TOTAL_TIME_MS=$(( (END_TIME - START_TIME) / 1000000 )) -if [ "$COMPLETION_TOKENS" -eq 0 ]; then +if [ "$TOTAL_TOKENS" -eq 0 ]; then echo "FAIL: No tokens generated or response parse error" - echo "Response: $RESPONSE" + echo "Response1: $RESPONSE1" + echo "Response2: $RESPONSE2" exit 1 fi # Calculate tokens/sec -TOK_PER_SEC=$(python3 -c "print(f'{${COMPLETION_TOKENS} * 1000 / ${TOTAL_TIME_MS}:.2f}')") +TOK_PER_SEC=$(python3 -c "print(f'{${TOTAL_TOKENS} * 1000 / ${TOTAL_TIME_MS}:.2f}')") echo "" echo "=== Results ===" -echo "Completion tokens: ${COMPLETION_TOKENS}" +echo "Prompt 1 tokens: ${COMPLETION_TOKENS1}" +echo "Prompt 2 tokens: ${COMPLETION_TOKENS2}" +echo "Total tokens: ${TOTAL_TOKENS}" echo "Total time: ${TOTAL_TIME_MS}ms" echo "Speed: ${TOK_PER_SEC} tok/s" echo ""