download

A small model costs 10x less. When does routing beat both?

AI engineering~14 minReviewed 3 Dec 2026Free · No sign-in

Question

You compare three serving setups on a fixed 200-query eval: Small ($1.00 / 1,000 queries), Large ($10.00 / 1,000 queries), and a Confidence-Routed cascade. The cascade runs Small first and escalates the 50 low-confidence queries (25%) to Large. Within each slice, the same short-prompt queries hit typical latency on both models, and the same long-prompt queries hit tail latency on both models.

Slice (200 total)Small passLarge passSmall latency (typical / tail)Large latency (typical / tail)
150 high-confidence144/150 (96%)145/150 (96.7%)300 ms (145) / 450 ms (5)1,400 ms (145) / 2,200 ms (5)
50 low-confidence16/50 (32%)41/50 (82%)350 ms (35) / 450 ms (15)1,600 ms (35) / 2,200 ms (15)
  1. Compute pass rate, p95 latency, cost per 1,000 queries, and cost per 1,000 successful answers for all three.
  2. When does the cascade win on the Pareto frontier, and when does it lose?
Show hints (3)
  1. "ADD ESCALATED CALLS"

    The cascade pays Small on 100% of queries ($1.00) plus Large on 25% ($2.50). What is the total per 1,000 queries?

  2. "DIVIDE BY PASS RATE"

    Cost per 1,000 successful answers equals cost per 1,000 queries divided by pass rate. Compare Small ($1.25), Cascade ($3.78), and Large ($10.75).

  3. "WATCH TAIL LATENCY"

    Because 25% of queries run Small and then Large in sequence, where does the 95th percentile (p95) latency land?

Show checked explanation

The cascade hits 92.5% pass rate at $3.50 per 1,000 queries ($3.78 per 1,000 successes), nearly matching Large (93.0%, $10.00 / 1,000, $10.75 per 1,000 successes) at 65% lower spend. However, sequential escalation pushes p95 latency to 2,650 ms, slower than Large (2,200 ms). Routing wins under a quality-and-cost budget, but loses if p95 must stay below 2,400 ms.

"SOLUTION · PYTHON"
import math
from fractions import Fraction

# 200-case eval: 150 high-confidence + 50 low-confidence queries
s_lat = [300] * 145 + [450] * 5 + [350] * 35 + [450] * 15
l_lat = [1400] * 145 + [2200] * 5 + [1600] * 35 + [2200] * 15
c_lat = s_lat[:150] + [a + b for a, b in zip(s_lat[150:], l_lat[150:])]
policies = [  # (name, passed, cost_per_1k_usd, latencies_ms)
    ("small", 160, Fraction(1, 1), s_lat),
    ("cascade", 185, Fraction(7, 2), c_lat),
    ("large", 186, Fraction(10, 1), l_lat),
]
for name, passed, cost1k, lats in policies:
    rate = Fraction(passed, 200)
    p95 = sorted(lats)[math.ceil(0.95 * len(lats)) - 1]
    per_ok = cost1k / rate
    print(f"{name:7} pass={float(rate):.1%} p95={p95:4}ms "
          f"cost/1k=${float(cost1k):.2f} $/1k_ok=${float(per_ok):.2f}")
"OUTPUT"
small   pass=80.0% p95= 450ms cost/1k=$1.00 $/1k_ok=$1.25
cascade pass=92.5% p95=2650ms cost/1k=$3.50 $/1k_ok=$3.78
large   pass=93.0% p95=2200ms cost/1k=$10.00 $/1k_ok=$10.75

Code, latency quantiles, and exact rational unit costs run on CPython 3.12.10 against the 200-query local fixture above; official Python documentation link checked. Checked by an editor other than the author.

Walkthrough

Raw price per call misleads when models differ in accuracy. Compare every option on the same fixed eval across quality, cost per successful answer, and tail latency:

PolicyPass ratep50 latencyp95 latencyCost / 1,000 queriesCost / 1,000 successes
Small only80.0% (160/200)300 ms450 ms$1.00$1.25
Cascade (75/25)92.5% (185/200)300 ms2,650 ms$3.50$3.78
Large only93.0% (186/200)1,400 ms2,200 ms$10.00$10.75

1. Why the cascade shines on cost and quality. The cascade keeps Small on the 150 easy queries (144 pass) and escalates the 50 hard ones to Large (41 pass), scoring 185/200 (92.5%). It pays $1.00 + 0.25 * $10.00 = $3.50 per 1,000 queries, cutting spend by 65% compared to Large.

Look at the marginal cost of each extra successful answer:

  • Small to Cascade: +$2.50 per 1,000 queries buys +125 extra successes (800 to 925), or $0.02 per extra success.
  • Cascade to Large: +$6.50 per 1,000 queries buys only +5 extra successes (925 to 930), or $1.30 per extra success (65x more expensive).

2. Why p95 gets worse in a cascade. Median latency (p50) stays at Small's fast 300 ms because 75% of requests never escalate. A sequential cascade pushes p95 above Large alone when more than 5% of all queries both escalate and exceed Large's p95. Here, the 15 escalated long-prompt queries take 450 + 2,200 = 2,650 ms, which is 15/200 (7.5%) of all queries. Because 7.5% exceeds 5%, cascade p95 lands at 2,650 ms, 450 ms slower than Large alone.

3. How to pick on the Pareto frontier. Filter out any option that breaks a hard SLO floor first. If your target is >= 90% pass rate and <= 3,000 ms p95, Small fails quality and Cascade beats Large easily. If your p95 SLO is strictly <= 2,400 ms, a sequential cascade fails; use a fast upfront classifier (pre-router) so hard queries go straight to Large without waiting for Small.

Common mistakes

  • Comparing only cost per 1,000 queries without dividing by pass rate. A cheap model that fails half its queries wastes retries and support hand-offs.
  • Assuming a cascade lowers p95 because average latency drops. When over 5% of all queries both escalate and exceed Large's p95 (here 7.5%), sequential cascades are slower than Large at p95.
  • Using uncalibrated model self-confidence to route. If Small is overconfident on hard queries, it fails to escalate and quality collapses toward 80%.
  • Forgetting router overhead and hidden retries in total cost. Include classifier calls, extra context tokens, and retry traffic in the cost per success.

Follow-up questions

  • "How do you decide whether to escalate if the small model does not expose well-calibrated confidence scores?" Use cheap deterministic checks first (JSON schema errors, empty citations, low retrieval score, or refusal flags), or train a tiny upfront router on query features and past eval failures. Always measure router recall on the hard slice on your held-out set.
  • "What happens to cascade economics if hard traffic rises from 25% to 70% during a busy billing week?" Escalation cost rises to $1.00 + 0.70 * $10.00 = $8.00 per 1,000 queries, and 70% of users pay double latency. Monitor live escalation rate as an SLO metric; above roughly 60% to 70%, switch to a fast pre-router or route directly to Large.

What a strong answer covers

Computes pass rate, p95 latency, cost per 1,000 queries, and cost per 1,000 successes for all three setups. Shows Cascade cuts spend 65% for 0.5 points less quality, flags the 2,650 ms p95 cascade penalty, and knows when a pre-router beats a sequential cascade.

Open in interactive practice deck →

Original OfferVibe question. Lingjiao Chen, Matei Zaharia, and James Zou, "FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance" (2023) · Python statistics documentation.
© 2026 OfferVibe · Text CC BY-NC-SA 4.0 · code MITFree to share and adapt with credit, not for commercial use. Code samples are free for any use.