Engineering-Grade Evaluation of LLM Math Reasoning and Decoding Throughput
This article presents a practical, engineering-oriented methodology for evaluating large language models (LLMs) on math reasoning, code capability, and decoding throughput. It shows how to align the variables that make comparisons meaningful, why "answer correct" must be separated from "reasoning trustworthy," how to control data contamination, and how to use pass@k, compute-matched comparison, and paired bootstrap significance testing instead of single-point scores. It also covers the engineering behind hundreds of tokens/second of decoding, capacity planning with goodput rather than peak throughput, a build-versus-buy decision checklist, tiered routing and cascade strategies, a four-week evaluation loop, and common pitfalls to avoid. The core message: no model wins on every dimension, and the real ROI comes from disciplined evaluation aligned with capacity planning and cost accounting.
1. First, define the evaluation target: which set of variables are you actually comparing?
Recurring debates in the community take the form of “A is definitely better than B” or “a model has already caught up with the strongest closed-source model.” Such conclusions often fall apart—not because the opinions themselves are wrong, but because the comparison baseline is not aligned. A rigorous evaluation must hold at least four groups of variables fixed:
- Inference budget: whether deep-thinking mode is enabled, the maximum chain-of-thought length, sampling temperature, and whether tool calls are allowed. The gap between deep thinking off and on is often larger than the generational gap between models.
- Decoding configuration: number of samples, voting or self-consistency strategy, and whether external retrieval and a code-execution sandbox are included.
- Task distribution: source of problem types, difficulty distribution, and whether natural-language scratch work is allowed.
- Prompt engineering effort: whether few-shot examples are given and whether a solving template is provided. Giving a new model a full prompt while running an old model bare is the most common source of evaluation distortion.
Scores are only comparable once these four groups of variables are aligned. In practice, it helps to split evaluation into three layers: the capability layer (a model’s ceiling under fully offline conditions), the system layer (end-to-end effect after adding retrieval, tools, and routing), and the cost layer (resource consumption per unit of effective output). Most teams measure only the first layer, yet make decisions at the system layer.
2. Math reasoning evaluation: from “answer correct” to “process trustworthy”
Math ability is the most sensitive probe for reasoning depth because its judging criteria are objective and automatically verifiable. But getting math evaluation right involves a few easy traps.
1. Tier the problem set, don’t just pile on difficulty.
- Routine computation and algebraic manipulation: tests basic reliability; catches regressions and formatting issues.
- Competition problems: test multi-step reasoning and technique combinations; the current main discrimination band for mainstream models.
- Open research questions: test whether a model can produce a structurally complete proof and can self-check and repair its own gaps. This tier is often unsuitable for accuracy scoring and should instead use process review—scoring by humans or a stronger model across four dimensions: correctness of the conclusion, completeness of the reasoning chain, whether key lemmas are proven rather than merely cited, and whether unresolved problems are acknowledged.
The ability to “handle open math problems” mentioned in the source is exactly this third-tier capability. It is closer to real research-assistance scenarios and most capable of separating models apart. Note, however, that results on such problems vary wildly, and with too few samples the conclusions carry no statistical meaning.
2. Strictly separate “final answer correct” from “reasoning process correct.”
Samples that reach the right answer through skipped steps, circular arguments, or reliance on erroneous intermediate conclusions will directly break auditability in production. Beyond automatic grading, sample 5%–10% for manual process review, and report “answer accuracy” and “process trustworthiness” side by side as two metrics.
3. Control for data contamination.
Public problem sets leak into pretraining corpora, systematically inflating scores. Practical measures:
- Build a private holdout set, generating new problems quarterly from the same source style;
- Apply equivalent rewriting and numerical perturbation to problem statements (swap parameters, reorder narration, change notation systems) and watch whether scores drop sharply;
- Record regression curves of the same model across time and versions, rather than a one-off snapshot.
4. Use statistical methods instead of single-point scores.
Score differences from a single evaluation often fall within noise. Sample each problem multiple times, use pass@k to measure “potential” and pass@1 to measure “day-to-day usability,” and provide confidence intervals.
from math import combdef pass_at_k(n: int, c: int, k: int) -> float:"""Unbiased pass@k estimate: with c successes in n samples, estimate theprobability of at least one success within k samples.Using 1 - c/n directly is biased; the combinatorial form removes the bias."""if n - c < k:return 1.0return 1.0 - comb(n - c, k) / comb(n, k)
Apply a paired bootstrap significance test to the difference between two models rather than computing each mean and concluding immediately: on the same batch of problems, if the 95% confidence interval crosses 0, judge it as “no significant difference.”
5. Chain-of-thought length must be part of the cost accounting.
Long chains of thought almost always bring higher accuracy, which biases evaluation conclusions toward “the model that talks the most.” The correct approach is compute-matched comparison: compare models under comparable reasoning-token budgets, or conversely fix a target accuracy and compare the average number of tokens required to reach it. The latter is more valuable for engineering, and the metric can be written as:
solved per unit cost = number of correctly solved problems / (input token cost + output token cost + tool call cost)
If model A is 3% more accurate but its chain of thought is 5× longer than B’s and its unit price is higher, then in a high-concurrency online scenario A may actually be the worse choice. This is why many “top-of-leaderboard strong models” deliver a worse experience in production.
3. Code and engineering capability: it must be executable
Code evaluation is closer to production value than math, and its core principles are executable, reproducible, and covering repository-level context:
- Prefer problems with hidden test cases to avoid models special-casing against sample inputs;
- Add repository-level tasks: cross-file refactoring, defect localization, and fixing compile errors after dependency upgrades—these are more sensitive to long-context and tool-calling ability;
- Track three kinds of metrics: first-pass pass rate, time to fix (including rounds of human intervention), and regression-introduction rate (whether a change breaks existing tests);
- Run in isolated containers with CPU/memory/time quotas and a network allowlist, to prevent untrusted generated code from accessing real credentials or external networks.
4. Throughput and unit economics: the engineering logic behind hundreds of tokens/second
The community often circulates rumors that “a single-rack cluster can decode a large model at hundreds of tokens per second.” The number itself is not mysterious—it is the combined result of several general inference optimizations, and understanding the causes matters more than memorizing the figure.
1. Decode throughput is determined by memory access and batching together.
Autoregressive decoding produces only one token per step, so the bottleneck usually lies in memory bandwidth and weight reads. Improvement paths include:
- Continuous batching: dynamically assemble batches rather than waiting for a whole batch of requests to finish;
- Paged KV cache management: reduce memory fragmentation and significantly raise cache utilization under high concurrency;
- Speculative decoding: use a small model or draft head to guess several tokens, then let the large model verify them in one pass, lowering the average number of decode steps;
- Tensor parallelism / expert parallelism + sparse expert activation: distribute weights across multiple cards and activate only part of the parameters, reducing per-step compute and reads;
- Separating prefill and decode deployment: prefill is compute-intensive while decode is memory-intensive, and colocating them causes interference; separation lets you scale each with different ratios;
- Prefix cache reuse: when system prompts, long documents, and few-shot examples are hit repeatedly, duplicate prefill can be avoided;
- Low-precision weights and quantization: reduce memory and bandwidth pressure within an acceptable precision range.
Single-token latency and overall throughput are two different goals, and one configuration rarely optimizes both at once: small batches for low latency, large batches for high throughput—tune per business SLA.
2. Use goodput, not theoretical peak, for capacity planning.
Only throughput of requests that meet the SLA is a meaningful capacity metric:
goodput = number of successful requests meeting (first-token latency ≤ L1 and end-to-end latency ≤ L2) / unit timereplica estimate:replicas = ceil(peak requests/sec × avg output tokens÷ (single-replica decode throughput × target utilization (recommend 0.6~0.8)))
Reserving utilization headroom is for absorbing long-tail long-text requests and traffic bursts; otherwise P99 latency degrades sharply.
3. The cost-structure shift brought by open weights.
High decode throughput directly determines per-token cost, and per-unit cost in turn determines the feasibility of an important business model: deploying open-weight models on high-density inference clusters to offer inference services externally, or providing private inference for enterprise customers. The profit margin does not come from the model license itself but from inference resource utilization and engineering optimization. The competitiveness formula for self-hosted inference can thus be summarized as:
gross margin ≈ unit price × actual throughput × effective utilization − hardware depreciation − power and data center − ops and labor
“Effective utilization” is the term most easily overestimated. In multi-tenant scenarios, long-request queuing, preemptive scheduling, and low cache-hit rates all prevent nominal throughput from materializing. If you plan to sell inference capability externally, pay particular attention to whether the license terms permit commercial use and resale, the responsibility boundaries for output content, and compliance with multi-tenant isolation and quota governance.
5. Self-host or buy managed inference: a decision checklist
| Dimension | Self-hosted / private deployment | Managed inference service |
|---|---|---|
| Unit cost | Better under high throughput and steady load | More economical at low utilization |
| Elasticity | Constrained by hardware procurement and scaling cycles | Minute-level elasticity |
| Data security | Data stays in-domain, most controllable | Depends on provider compliance |
| Version tracking | You handle upgrades and regression testing | Handled by the provider |
| Ops burden | Cluster, inference framework, monitoring all self-built | Significantly lower |
| Best fit | Stable high concurrency, strong compliance, predictable cost | Volatile traffic, rapid validation, frequently changing capabilities |
For most organizations the rational choice is a hybrid strategy: core and steady-state traffic goes to a private inference cluster, while long-tail and peak traffic goes to managed services, with a unified gateway handling routing in between.
6. Routing and tiering: turning capability gaps into a cost advantage
Model capability differences are objective, and the correct engineering response is not “always pick the strongest” but tiered routing: handle most requests first with a lightweight model or rules, then escalate hard cases.
def route(query: str, ctx: dict) -> str:# 1) Rules and a light model first, covering high-confidence simple requestsif ctx.get("intent") in {"faq", "lookup"} or len(query) < 30:return "light_model"# 2) Have the light model self-assess confidence; escalate on low confidenceresp = call("light_model", query)if resp.confidence >= 0.85:return "light_model"# 3) Hard cases needing long-chain reasoning / tool calls go to the deep-thinking tierreturn "reasoning_model"# Cascade strategy: cheap first, then expensive; use self-verification of the result# to decide whether to keep investingdef cascade(query: str, tiers=("light_model", "reasoning_model")):for model in tiers:out = call(model, query)if verifier(out) or model == tiers[-1]:return out, model # also log the routing hit, for cost accounting
This requires a closed observability loop: record each request’s hit model, input/output token counts, chain-of-thought length, latency segments (first-token and inter-token intervals), and whether an escalation or tool call was triggered. Write these details to a logging service and object storage as the source for an offline evaluation set, and use monitoring alerts to track the double curve of accuracy and cost. Without this data, any “switch model” decision can only be made on gut feeling.
7. Landing recommendations: complete an evaluation loop in four weeks
- Week 1: build the problem set. Sample 200–500 representative requests from real business, de-identify them into a private evaluation set, and stratify by difficulty; provide automatic grading scripts for math and code tasks.
- Week 2: align the baseline. Fix the inference budget, sampling configuration, and prompt template, run a baseline on all candidate models, and output pass@1, pass@k, average output tokens, and solved-per-unit-cost.
- Week 3: system-layer validation. Add retrieval, tool calls, routing, and caching; measure end-to-end goodput and P99 latency, and estimate capacity and replica counts.
- Week 4: cost and compliance review. Account for per-token cost, license and data compliance terms, and produce a hybrid deployment plan and a canary rollout plan.
8. Pitfalls to proactively avoid
- Treating leaderboard scores as production metrics: leaderboard sets are generally too easy and may be contaminated, with limited correlation to your business distribution.
- Comparing only accuracy, not cost: a 2% accuracy gain for double the cost is usually a net loss in large-scale online scenarios.
- Ignoring the uncontrollable latency from chain-of-thought length: long outputs significantly stretch tail latency; set output limits and timeout-based degradation.
- Using theoretical peak throughput for capacity planning: you must deduct the actual losses from batch fragmentation, queuing, and preemption.
- Skipping regression evaluation: both the model side and the inference-framework side keep evolving, so the same prompt performs differently across versions; without periodic regression you lose effectiveness silently.
- Neglecting manual process review: in math and code scenarios, “answers that look right” are very costly, and sampled review is a necessary investment rather than an optional one.
The conclusion is actually plain: there is no model that wins on every dimension, and no ranking you can keep forever. What truly determines ROI is the rigor of the evaluation method and the engineering ability to turn evaluation conclusions into routing strategies, capacity planning, and cost accounting. Aligning and continuously regressing the three baselines of capability—cost—throughput is the sustainable way to choose a model.
