Cost Reduction
82.9%
95% CI 79.6 to 86.0, vs all-heavyweight, 519 prompts
Draft Acceptance
92.3%
479 of 519 prompts at T=2.0
Served Accuracy
98.1%
LLM-as-judge, 95% CI 96.7 to 99.0
P99 Latency
107ms
accept path, 50 req/s, mock upstream

The headline above is real and replays from a committed trace. The rest of this page is the evaluation that followed: random, oracle, always-drafter and learned-router baselines, three public benchmarks with answer keys, a disjoint replication of every result, and the speculative executor and semantic cache measured by replaying traces through their production code. Most of it is negative for the entropy signal, and all of it reproduces with one command from the repository.

01Verdict
Window-peak AUROC
0.45 to 0.57
the statistic the gateway thresholds, 5 answer-key samples, chance is 0.5
Mean-entropy AUROC
0.70 to 0.81
same 5 samples, needs the whole draft
Router vs random, pts
-0.2 to -1.0
served accuracy at T=2.0, 3 held-out sets, same escalation rate
Learned vs random, pts
+0.8 to +3.0
logistic on 22 trace features, trained r1, tested r2, CIs overlap
02Held-Out Evaluation
Served Accuracy at Matched Escalation (7 traces)
DatasetEsc%RouterRandomvs RandMean-HLearned
GSM8K r1answer key5.393.092.7+0.394.3train
MMLU r1answer key18.777.376.7+0.679.3train
GSM8K r2held out6.890.490.8-0.492.292.4
ARC-Challengeheld out13.293.093.2-0.293.494.0
MMLU r2held out19.078.279.2-1.081.682.2
GSM8K, qwen drafteranswer key28.087.388.0-0.790.3n/a
Project setLLM judge7.798.198.10.097.998.3

Served accuracy in percent. Every method escalates the same share of requests as the production router at T=2.0 on that dataset. Random is the rate-matched random router. Mean-H thresholds the trace mean entropy. Learned is a 22-feature logistic model trained on the two r1 sets and tested on the r2 sets and ARC.

qwen row: drafter is qwen2.5-coder:7b via local Ollama, heavyweight gpt-4.1, T=2.0 not recalibrated. Project set is judged by gpt-4.1 against its own answer, so the heavyweight is correct by definition. Bootstrap 95% intervals for every cell are in docs/RESULTS.md sections 3 to 5, 9 and 13.

Learned Router
Features22 from the drafter trace
Modelslogistic, GBT (150 x depth 2)
Trainr1 GSM8K + MMLU, 600 records
Testr2 GSM8K, MMLU, ARC, 1500
Go / Python parity50 records to 1e-9
vs production AUROC+0.23 to +0.27, CIs disjoint
vs mean entropy+0.003 to +0.030, CIs overlap
Prefix-only (20 / 50 tok)AUROC 0.48 to 0.62
Pooled 2100, OOF0.794 vs 0.719 mean

Features computed in Go and replayed in Go, so training and inference cannot disagree. Top standardised coefficients: token count +0.54, entropy std +0.47, mean entropy +0.37; the window peak goes negative (-0.30) once the others are present. The learned router costs slightly more at the same escalation rate because it prefers long, high-variance drafts.

Signal Quality (AUROC vs chance, 95% CI)
WINDOW PEAK (PRODUCTION)MEAN ENTROPYLEARNED LOGISTICCHANCE 0.5
GSM8K r1
22 positives
training set
0.51
0.76
MMLU r1
73 positives
training set
0.47
0.63
GSM8K r2
50 positives
0.57
0.81
0.81
ARC-Challenge
37 positives
0.52
0.72
0.75
MMLU r2
116 positives
0.45
0.69
0.71
GSM8K, qwen
49 positives
not retrained
0.52
0.73
Project set (judge)
11 positives
0.68
0.52
0.74

AUROC of each per-request score as a detector of wrong drafts, bar at the point estimate, lighter band is the bootstrap 95% interval. The window peak is the exact statistic the gateway thresholds. Its interval covers 0.5 on all five answer-key samples. Mean entropy is informative on every one of them but needs the whole draft.

Open-Weight Drafter
Drafterqwen2.5-coder:7b, Ollama
HardwareRTX 4050 laptop, 6 GB
Heavyweightgpt-4.1, GSM8K r1, n=300
Drafter alone83.7% (79.3 to 87.7)
Router T=2.087.3%, escalates 28.0%
Random, same rate88.0% (84.3 to 91.7)
Mean-entropy, same rate90.3% (86.7 to 93.7)
Heavyweight alone97.0% (95.0 to 98.7)
Min-logprob sweep100% to 0%, no ceiling

The pattern transfers to a different model family: window peak at chance (0.52), trace mean informative (0.73), router below random. T=2.0 escalates 28.0% of this drafter against 5.3% for gpt-4.1-nano on the same prompts; thresholds do not transfer between drafters. Ollama reports real logprobs for tokens outside the top 5, which confirms the OpenAI -9999 sentinel ceiling is an API encoding artifact.

03Components Measured by Replay
Speculative Execution (soft trigger 0.8T)
TraceTrigger%Cancel%p50Cancel/1k
Project setn=51970.596.436 ms680
GSM8K r1n=30087.798.926 ms867
MMLU r1n=30086.093.427 ms803
GSM8K r2n=50088.898.637 ms876
ARC-Challengen=50088.896.430 ms856
MMLU r2n=50086.492.629 ms800

Every recorded trace replayed through the production executor with synthetic logprobs that reproduce the recorded entropy exactly. Trigger is the share of requests that start a speculative heavyweight call at 0.8T; Cancel is the share of those calls cancelled because the draft was accepted. Head start is escalations that had a speculative call already running. Billed to completion, the cancelled calls would cost 80 to 88% of the all-heavyweight bill. Recommendation on record: speculative.enabled false.

Semantic Cache (cosine > 0.95)
TraceHitsWrongNN maxp50 / p99
Project setn=5190(0.0%)00.878197 / 374 ms
GSM8K r1n=3000(0.0%)00.763199 / 406 ms
MMLU r1n=3003(1.0%)11.000201 / 360 ms

Prompts replayed in order through the production vector store with the real embedding client, inserting what the T=2.0 router would have accepted. NN max is the highest cosine any prompt reached against an earlier one. The MMLU hits are two exact duplicates and one templated near-duplicate at 0.959 that served the wrong letter.

At 0.90 the MMLU replay would hit 30 prompts and serve a wrong cached answer on 19. A second pass over the project set hits all 479 inserted prompts. Lookup is dominated by the embedding call.

Load Test with Fault Injection (vegeta, 50 req/s x 30 s)
ScenarioSuccessp50p99
confident
all drafts accepted
100%105.9 ms107.4 ms
mixed
20% of drafts uncertain
100%106.3 ms109.8 ms
flaky
20% drafter 503s, 5% stalls, 2 s timeout
100%107.1 ms2107.9 ms

1,500 requests per scenario at 50 req/s with vegeta against a mock upstream that streams 20 SSE chunks at 5 ms each, so p50 is upstream time and gateway overhead is low single-digit milliseconds. In the flaky run every injected drafter failure was served by the heavyweight with zero 5xx responses. The 2.1 s p99 is the drafter timeout plus one heavyweight call. Config: config.loadtest.yaml.

Graceful Degradation
Drafter 5xx or timeoutserved by heavyweight
Heavyweight fails after escalationre-run drafter
Flagged onresponse headers + metrics
Handler tests9 fallback cases, race-clean
Flaky run 5xx0 of 1500
Before round 1any provider error failed the request

Both fallbacks are configurable. The mock's uncertain tokens originally carried 1.58 bits, below T=2.0, so earlier load tests never exercised escalation; the mixed scenario now escalates about 21% of requests.

04Project Set
Cost Reduction by Threshold
TCOST REDUCTIONACC
1.00
100%
1.25
99.8%
1.50
99%
1.75
98.3%
2.00
82.9%
98.1%
2.25
97.9%
2.50
97.9%
Confusion Matrix at T=2.0
Accept
Escalate
Actual
469
TN
39
FP
10
FN
1
TP
n=519T=2.0 bits

40 escalations caught exactly one bad draft. Random escalation at the same rate also caught one. With 11 positives and a judge that is the heavyweight itself, this set cannot distinguish routers; the answer-key sets above can.

Threshold Sweep (n=519)

4 categories: factual, reasoning, code generation, ambiguous/creative. LLM-as-judge evaluation. Swept T=1.0..2.5 in 0.25 steps. Top-5 renormalised entropy caps at log2(5) = 2.32 bits, so the T=2.25 and 2.50 rows are degenerate.

TESC%ACC%COST RED%
1.0068.0100.03.6
1.2548.599.824.4
1.5032.699.046.4
1.7515.698.373.2
2.00SEL7.798.182.9
2.250.897.991.9
2.500.097.992.6
Cost Model
Baseline (all-heavyweight)
$1.623
519 prompts, input + output tokens
Routed at T=2.0
$0.277
82.9% reduction, USD 0.534 per 1k requests vs 3.127
DRAFTER OUTPUT$0.80/1M tok
HEAVY OUTPUT$10.00/1M tok
DRAFTER INPUT$0.20/1M tok
HEAVY INPUT$2.50/1M tok
DRAFTERgpt-4.1-nano
HEAVYWEIGHTgpt-4.1
EMBEDDINGStext-embedding-3-small
05Design
Entropy Analysis

H(X) = -SUM p(x) log2 p(x) over top-5 logprobs per token. 10-token sliding window. The router thresholds the window peak; the trace mean is the statistic that carries signal.

ARITHMETICWhat is 347 + 892?
ACCEPT
avg 0.028peak 0.303
avg 0.028peak 0.303
FACTUALWhat is photosynthesis?
ACCEPT
avg 0.210peak 1.835
avg 0.210peak 1.835
AMBIGUOUSDefine ubiquitous
ESCALATE
avg 0.359peak 2.198
avg 0.359peak 2.198
T=2.0 mean entropy peak (under T) peak (over T)
Routing State Machine
DRAFTINGentry
Drafter generates. Entropy computed per token, 10-token sliding window.
SPECULATINGH(X) > 0.8*T
Any single token above 0.8T starts the heavyweight in a goroutine. Replay shows this fires on 70 to 89% of requests; disabling it is the documented recommendation.
ACCEPTEDH(X) < T at EOS
Draft served. Response cached. Speculative heavyweight canceled if running.
ESCALATEDH(X) >= T
Heavyweight response used. Measured head start is 26 to 37 ms at the median, and most escalations get none because a token above T escalates before any speculative call starts.
Key Parameters
HARD THRESHOLDT=2.0 bits
SOFT THRESHOLD0.8*T=1.6 bits, per token
WINDOW10 tokens
EARLY EXIT10 tokens
CACHE COSINE>0.95
TOP LOGPROBS5 (max 2.32 bits)
System Architecture
CLIENTGATEWAYGo net/http, goroutinesSEMANTIC CACHEQdrant + RedisHITMISSRETURN CACHEDDRAFTERgpt-4.1-nano, logprobsENTROPY ENGINEH(X) = -Σ p log₂ p, 10-tokH < TH ≥ TACCEPTserve draft, cacheESCALATEHEAVYWEIGHTgpt-4.1speculate at 0.8*T
Known Tradeoffs
ROUTER VS RANDOM

At T=2.0 the entropy router is 0.2 to 1.0 accuracy points below a random router escalating the same share on all three held-out sets, and level with it on the project set. The savings come from the cheap drafter being usually right, not from the entropy signal choosing what to escalate.

CONFIDENT HALLUCINATION

Drafter produces wrong answers with low entropy. 10 of 11 bad drafts pass at T=2.0 on the project set; all 11 have mean entropy under 0.5 bits. On MMLU r2 the window peak sits below chance at 0.445.

NO PREFIX SIGNAL

Routers restricted to the first 20 or 50 drafter tokens reach held-out AUROC 0.48 to 0.62. The information that predicts a wrong draft arrives with the answer, which removes the basis for early exit and speculative execution on these tasks.

SPECULATIVE WASTE

Replayed through the executor: fires on 70 to 89% of requests, cancels 93 to 99% of those calls, median head start 26 to 37 ms. The trigger is per token, not per window, which the design doc had wrong. The under-10%-waste target is not met at any multiplier.

CACHE CONSERVATISM

Cosine > 0.95, only draft-accepted responses cached. Replayed: 0 to 1% hits on unique benchmark prompts, 100% on repeats, lookup about 200 ms. At 0.90 MMLU would serve 19 wrong cached answers in 30 hits.

CALIBRATION DOES NOT TRAVEL

An 8% served-error operating point calibrated on round 1 folds held on GSM8K r2 (6.4%), held wastefully on ARC by escalating 66.8%, and missed on MMLU r2 (11.0%, where the heavyweight alone is 9.2% wrong). Risk control needs calibration data from the traffic it governs.

GATEWAY
Go net/http
DRAFTER
gpt-4.1-nano, qwen2.5-coder:7b
HEAVYWEIGHT
gpt-4.1
CACHE
Qdrant + Redis
OBS
Prometheus + Grafana
Reproduce

Every number on this page replays offline from traces committed under benchmarks/results. No API key is needed for the sweeps, the learned-router evaluation or the speculative replay; the cache replay makes embedding calls (about one cent per thousand prompts). Full commands in docs/RESULTS.md section 14.

go test -race ./...
go run ./benchmarks/cmd/compare -input benchmarks/results/collected.jsonl.gz -output benchmarks/results/compare.csv
go run ./benchmarks/cmd/compare -input benchmarks/results/collected_gsm8k_r2.jsonl.gz -output benchmarks/results/compare_gsm8k_r2.csv \
  -models benchmarks/models/router_full_logistic.json
go run ./benchmarks/cmd/replayspec -input benchmarks/results/collected_mmlu_r2.jsonl.gz
OPENAI_API_KEY=... go run ./benchmarks/cmd/replaycache -input benchmarks/results/collected_mmlu.jsonl.gz