Skip to content

Commit 613b455

Browse files
TheTomclaude
authored andcommitted
ci: quality+speed gate script — PPL + context scaling check before push
Checks both: 1. PPL within 5% of q8_0 baseline (8-chunk wikitext-2) 2. Context scaling ratio > 0.95 at 4K context Both must pass. Run: bash scripts/turbo-quality-gate.sh Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-Authored-By: tturney@psyguard.ai
1 parent f286b3c commit 613b455

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

scripts/turbo-quality-gate.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
# TurboQuant quality + speed gate — run BEFORE pushing any changes
3+
# Checks: (1) perplexity within 5% of q8_0, (2) context scaling ratio > 0.95
4+
#
5+
# Usage: bash scripts/turbo-quality-gate.sh
6+
# Exit 0 = PASS, Exit 1 = FAIL
7+
8+
set -e
9+
10+
LLAMA=${LLAMA:-~/local_llms/llama.cpp/build-turbo/bin}
11+
MODEL=${MODEL:-~/local_llms/models/Qwen3.5-35B-A3B-Q8_0.gguf}
12+
WIKI=${WIKI:-~/local_llms/llama.cpp/wikitext-2-raw/wiki.test.raw}
13+
14+
if [ ! -f "$WIKI" ]; then
15+
echo "Downloading wikitext-2..."
16+
bash ~/local_llms/llama.cpp/scripts/get-wikitext-2.sh
17+
fi
18+
19+
FAIL=0
20+
21+
echo "========================================"
22+
echo " TurboQuant Quality + Speed Gate"
23+
echo "========================================"
24+
echo ""
25+
26+
# --- Test 1: Perplexity ---
27+
echo "[1/2] Running perplexity check (8 chunks)..."
28+
PPL_TURBO=$($LLAMA/llama-perplexity -m $MODEL -f $WIKI -c 512 -ctk turbo3 -ctv turbo3 -fa on --chunks 8 -ngl 99 2>&1 | grep "Final" | grep -oE 'PPL = [0-9.]+' | grep -oE '[0-9.]+')
29+
30+
if [ -z "$PPL_TURBO" ]; then
31+
echo " FAIL: Could not get turbo3 perplexity (crash or timeout)"
32+
FAIL=1
33+
else
34+
BASELINE_PPL=6.111
35+
MAX_PPL=$(echo "$BASELINE_PPL * 1.05" | bc)
36+
PPL_OK=$(echo "$PPL_TURBO < $MAX_PPL" | bc)
37+
if [ "$PPL_OK" -eq 1 ]; then
38+
echo " PASS: turbo3 PPL = $PPL_TURBO (< $MAX_PPL, within 5% of q8_0 $BASELINE_PPL)"
39+
else
40+
echo " FAIL: turbo3 PPL = $PPL_TURBO (> $MAX_PPL, exceeds 5% threshold)"
41+
FAIL=1
42+
fi
43+
fi
44+
echo ""
45+
46+
# --- Test 2: Context Scaling ---
47+
echo "[2/2] Running context scaling check (4K prefill)..."
48+
TURBO_TPS=$($LLAMA/llama-perplexity -m $MODEL -f $WIKI -c 4096 -ctk turbo3 -ctv turbo3 -fa on --chunks 4 -ngl 99 2>&1 | grep "prompt eval" | grep -oE '[0-9.]+ tokens per second' | grep -oE '[0-9.]+')
49+
Q8_TPS=$($LLAMA/llama-perplexity -m $MODEL -f $WIKI -c 4096 -ctk q8_0 -ctv q8_0 -fa on --chunks 4 -ngl 99 2>&1 | grep "prompt eval" | grep -oE '[0-9.]+ tokens per second' | grep -oE '[0-9.]+')
50+
51+
if [ -z "$TURBO_TPS" ] || [ -z "$Q8_TPS" ]; then
52+
echo " FAIL: Could not measure speed (crash or timeout)"
53+
echo " turbo3=$TURBO_TPS q8_0=$Q8_TPS"
54+
FAIL=1
55+
else
56+
RATIO=$(echo "scale=4; $TURBO_TPS / $Q8_TPS" | bc)
57+
RATIO_OK=$(echo "$RATIO > 0.95" | bc)
58+
if [ "$RATIO_OK" -eq 1 ]; then
59+
echo " PASS: turbo3/q8_0 = ${RATIO}x at 4K context (> 0.95 threshold)"
60+
echo " turbo3 = $TURBO_TPS tok/s, q8_0 = $Q8_TPS tok/s"
61+
else
62+
echo " FAIL: turbo3/q8_0 = ${RATIO}x at 4K context (< 0.95 threshold)"
63+
echo " turbo3 = $TURBO_TPS tok/s, q8_0 = $Q8_TPS tok/s"
64+
echo " Context scaling regression detected!"
65+
FAIL=1
66+
fi
67+
fi
68+
echo ""
69+
70+
# --- Summary ---
71+
echo "========================================"
72+
if [ "$FAIL" -eq 0 ]; then
73+
echo " ALL CHECKS PASSED"
74+
echo "========================================"
75+
exit 0
76+
else
77+
echo " CHECKS FAILED — DO NOT PUSH"
78+
echo "========================================"
79+
exit 1
80+
fi

0 commit comments

Comments
 (0)