Pathwise-Budgeted LLM Routing: Online Allocation with K-Bit Tail-Cost Learning
Organizations: Department of Industrial Systems Engineering and Management, National University of Singapore · The Wharton School of Business, University of Pennsylvania, Philadelphia PA, USA · Department of Industrial Engineering, Tsinghua University, Beijing, China
Abstract
Firms using large language models under fixed budgets must decide which model to call and whether to retry a failed task. Because a call's charge is revealed only after completion, one long response can exhaust the remaining budget and leave later tasks unserved. Our objective is to maximize the number of tasks solved before service stops. We develop a contextual bandit policy, ADP-HT, which learns each model's task-specific success probability and constructs conservative cost estimates from coarsened response-length labels on a quantile grid with intervals. The policy weighs predicted success against these costs, adjusting the cost penalty to realized spending and the budget available per remaining task. Under calibration, local regularity, and grid-coverage conditions, we bound the excess allowance in the policy's conservative cost estimates. At a fixed sample size, increasing reduces the discretization term but increases the estimation allowance. At the tightest tested budgets, ADP-HT solves more than twice as many MATH500 and GPQA tasks as the best implemented baseline. It achieves the highest mean cumulative score at ten of fourteen RouterBench budgets. On LiveCodeBench, it outperforms a deployed commercial router in both default and cost-saving modes at the three lowest test budgets.
Figures & tables
| Budget (USD) | K-Bit | Continuous Mean | Mean-Adjusted |
|---|---|---|---|
| 5.00 | 15,989.4 (770.9) | 14,774.2 (768.9) | 15,502.3 (416.7) |
| 8.86 | 18,397.6 (462.3) | 16,923.7 (1,589.2) | 17,419.5 (1,048.8) |
| 10.00 | 18,673.3 (376.0) | 17,248.3 (1,359.2) | 17,446.2 (1,199.9) |
| 13.34 | 18,931.1 (515.2) | 17,851.0 (1,330.5) | 17,762.9 (1,310.1) |
| 20.00 | 18,996.2 (532.9) | 18,771.0 (883.9) | 18,668.4 (992.8) |
| 40.02 | 19,888.3 (315.2) | 20,072.6 (151.7) | 20,054.0 (188.7) |
Appendix figures & tables15 assets
Supplementary material from the paper’s appendix.
Appendix
| Setting | MATH500 | GPQA |
|---|---|---|
| Seeds, warm/test split | – , | – , |
| Warm-start, retry upper bound | Greedy infinite-budget replay, | Greedy infinite-budget replay, |
| Embedding and grader | BGE-small-en-v1.5, GPT-OSS-120B | BGE-small-en-v1.5, GPT-OSS-120B |
| Arms | Qwen3-8B, Phi-4, Gemini-Flash-Lite, DeepSeek-V3.2, GPT-5-mini | |
| Budgets (USD) | MATH grid plus | |
| , mesh edges, | , warm-start quantiles, | , warm-start quantiles, |
| Model | Input price | Output price |
|---|---|---|
| qwen/qwen3-8b | ||
| microsoft/phi-4 | ||
| google/gemini-2.5-flash-lite | ||
| deepseek/deepseek-v3.2 | ||
| openai/gpt-5-mini |
| Budget | ADP-HT | BA | PA | ParetoBandit | Greedy |
|---|---|---|---|---|---|
| Nominal | ADP-HT solved | ADP-HT spend | Errors | Auto-CS solved | Auto-CS spend | Auto-default (spend) |
|---|---|---|---|---|---|---|
| 244 | 0 | 86 | 8 ( ) | |||
| 436 | 0 | 166 | 8 ( ) | |||
| 682 | 0 | 372 | 15 ( ) | |||
| 704 | 1 | 732 | 154 ( ) | |||
| 628 | 137 | 732 | 298 ( ) | |||
| 710 | 36 | 732 | 420 ( ) |
| Dataset | Budget | Greedy | B-aware | P-aware | Pareto | ADP-HT | Gap |
|---|---|---|---|---|---|---|---|
| MATH500 | 0.025 | 31.0 14.8 | 96.6 8.0 | 100.8 16.8 | 79.6 13.0 | 216.2 83.8 | 115.4 |
| 0.050 | 53.0 18.8 | 197.0 22.0 | 191.0 21.6 | 151.0 23.3 | 261.4 67.7 | 64.4 | |
| 0.075 | 69.4 19.8 | 263.4 18.8 | 257.8 23.1 | 252.2 33.6 | 300.4 29.1 | 37.0 | |
| 0.125 | 103.0 30.9 | 313.8 7.7 | 329.2 8.0 | 329.6 30.9 | 339.0 22.4 | 9.4 | |
| 0.300 | 249.8 67.5 | 332.4 13.5 | 369.4 5.8 | 370.8 8.8 | 371.4 17.5 | 0.6 | |
| 0.450 | 353.8 76.6 | 344.6 23.0 | 381.2 3.4 | 380.6 7.0 | 386.2 5.3 | 5.0 |
| Dataset | Baseline | Mean diff. | CI | -value (one-sided) |
|---|---|---|---|---|
| GPQA | Budget-aware | [27.4, 54.2] | ||
| GPQA | Position-aware | [19.6, 54.2] | ||
| GPQA | ParetoBandit | [11.3, 46.3] | ||
| MATH500 | Budget-aware | [31.5, 80.4] | ||
| MATH500 | Position-aware | [7.1, 71.3] | ||
| MATH500 | ParetoBandit | [8.1, 88.2] |
| Panel A, mean budget utilization on MATH500 (%) | ||||
| Policy | ADP-HT | BA | PA | ParetoBandit |
| Realized spend / nominal budget | 93.4 | 75.7 | 77.2 | 81.5 |
| Panel B, maximum-budget task profiles for ADP-HT | ||||
| Dataset ( ) | Profiles | Unsolved (%) | Unsolved spend (%) | Mean cost, solved / unsolved |
| MATH500 ( ) | 2,000 | 3.25 | 20.2 | |
| GPQA ( ) | 1,784 | 24.72 | 53.9 | |
| Dataset | Budget | |||||
|---|---|---|---|---|---|---|
| MATH500 | 0.05 | 273.8 49.3 | 270.2 67.8 | 265.4 75.3 | 266.4 75.7 | 245.8 83.8 |
| MATH500 | 0.3 | 370.4 17.9 | 371.0 16.2 | 367.0 19.4 | 334.4 88.3 | 335.0 91.0 |
| GPQA | 0.05 | 124.6 11.7 | 138.6 13.2 | 135.0 6.7 | 131.8 10.5 | 129.4 9.8 |
| GPQA | 0.3 | 232.8 15.2 | 243.2 3.9 | 241.8 9.8 | 239.8 7.3 | 240.0 7.2 |
| Dataset | cells | Coverage | All-call gap | Cond. severity | Target-core exceedance | |
|---|---|---|---|---|---|---|
| ( ) | ( ) | rate | ||||
| GPQA | 1 | 10 | 0.960 | 2.40 | 6.08 | 0.0126 |
| GPQA | 2 | 10 | 0.876 | 4.11 | 3.31 | 0.0137 |
| GPQA | 3 | 10 | 0.807 | 5.56 | 2.88 | 0.0124 |
| GPQA | 4 | 10 | 0.751 | 5.68 | 2.28 | 0.0116 |
| GPQA | 5 | 10 | 0.715 | 6.53 | 2.29 | 0.0112 |
| Budget (USD) | K-Bit | Continuous Mean | Mean-Adjusted |
|---|---|---|---|
| Panel A. Cumulative score, mean (sample standard deviation) | |||
| 5.00 | 15,989.4 (770.9) | 14,774.2 (768.9) | 15,502.3 (416.7) |
| 8.86 | 18,397.6 (462.3) | 16,923.7 (1,589.2) | 17,419.5 (1,048.8) |
| 10.00 | 18,673.3 (376.0) | 17,248.3 (1,359.2) | 17,446.2 (1,199.9) |
| 13.34 | 18,931.1 (515.2) | 17,851.0 (1,330.5) | 17,762.9 (1,310.1) |
| 20.00 | 18,996.2 (532.9) | 18,771.0 (883.9) | 18,668.4 (992.8) |
| Model | Fixed length | Tail length | ||||
|---|---|---|---|---|---|---|
| 0.80 | 0.20 | 0.650 | 0.350 | 2 | 2 | |
| 0.90 | 0.40 | 0.775 | 0.525 | 3 | 2 (0.8), 7 (0.2) | |
| 0.95 | 0.55 | 0.850 | 0.650 | 4 | 2 (0.8), 12 (0.2) |
| Cost / difficulty | ADP-HT [95% CI] | ADP/ | Agreement | ||
|---|---|---|---|---|---|
| 2,000 | Fixed / iid | 336.30 | 309.80 [306.47, 313.73] | 92.12% | 31.32% |
| 2,000 | Fixed / persistent | 336.28 | 315.28 [312.97, 317.45] | 93.76% | 33.78% |
| 2,000 | Tail / iid | 336.32 | 312.52 [308.10, 317.42] | 92.92% | 34.07% |
| 2,000 | Tail / persistent | 336.31 | 315.48 [311.05, 319.92] | 93.81% | 33.70% |
| 5,000 | Fixed / iid | 763.27 | 741.98 [734.52, 749.47] | 97.21% | 51.93% |
| 5,000 | Fixed / persistent | 750.76 | 736.97 [731.97, 741.93] | 98.16% | 64.14% |
| Measure | DP | ADP-HT | DP | ADP-HT |
|---|---|---|---|---|
| Tasks served | 573.15 | 436.03 | 999.85 | 999.83 |
| First-call success among served tasks (%) | 59.23 | 71.51 | 67.53 | 71.41 |
| First-call successes | 339.50 | 309.80 | 675.20 | 714.02 |
| Retry calls | 0.00 | 0.00 | 122.40 | 41.87 |
| Retry successes | 0.00 | 0.00 | 95.60 | 27.97 |
LLM Routing
Large language model routing selects models, tools, experts, or inference strategies to balance answer quality, cost, latency, and deployment constraints.
See all 364 papers