1

Prerequisites

Before tuning a model server, define the application, prove model quality, choose a serving mode, and decide which latency and throughput measurements describe success.

11 min read

Printed pages: 23–38

Star on GitHub

In one breath

Optimization is a search for the best workable balance, not a contest to maximize one number. Begin with the application’s model needs, input and output interface, end-to-end latency budget, unit economics, traffic pattern, and compliance boundary. Those constraints determine whether shared inference is still appropriate, which models deserve evaluation, and whether latency or throughput should dominate. For streamed language-model output, time to first token (TTFT) describes the wait until output begins and tokens per second (TPS) describes delivery after that point. Report their percentiles, distinguish per-user speed from service-wide throughput, and compare inference-only timing with what the client experiences. A technically faster model is not an improvement if it misses the product’s quality, cost, or reliability contract.

Product constraints turn optimization into a bounded problem

Application category narrows into a Workload contract, which guides Model and evaluation and Serving mode; production measurements then flow from User-visible metrics back toward the original contract.

  1. Application categoryInteraction style and audience determine what users notice and what traffic looks like.
  2. Workload contractModel, interface, latency, economics, usage, and compliance become explicit constraints.
  3. Model and evaluationChoose the smallest supported candidate that clears product-specific quality tests.
  4. Serving modeUse shared or dedicated inference according to volume, control, and orchestration needs.
  5. User-visible metricsMeasure streaming speed, tail latency, total response time, throughput, and quality together.
  • Application categoryWorkload contract: adds constraints
  • Workload contractModel and evaluation: defines passing
  • Model and evaluationServing mode: sets deployment needs
  • Serving modeUser-visible metrics: produces evidence
  • User-visible metricsWorkload contract: revises budgets

Why it matters

Inference improvements exchange latency, throughput, quality, and cost. Without a product definition, the team cannot tell which exchange is acceptable. A highly batched deployment may process an offline corpus efficiently yet feel unusable in chat. A premium low-latency service may delight a business workflow but destroy the margins of a volatile consumer product. Constraints reduce the search space and turn an attractive benchmark into a decision that can be evaluated against users, traffic, and economics.

The order of operations matters. Choosing a smaller capable model can change cost and latency more than a later engine optimization. Product-specific evaluations prevent engineers from accelerating a model that is not good enough, and they provide the baseline needed when an optimization might reduce quality. Only after these decisions are grounded should the team take on dedicated inference and its larger operational surface.

Constraints also need an order. Quality establishes whether the feature works at all. Interaction style establishes which part of latency users can perceive. Traffic and economics establish how much capacity the product can afford. Availability and compliance establish where and how the service may run. When two goals conflict, this hierarchy prevents a benchmark from silently redefining the product. It also makes an optimization proposal falsifiable: the team can state which constraint should improve, which one may worsen, how much movement is acceptable, and which evaluation or production measurement will decide. For example, chat may accept slightly lower total throughput for faster first output, while offline document processing may accept slower items if hourly completions rise. This is not a universal ranking; it requires each product to write its own. This discipline turns performance work from an open-ended search into a bounded engineering experiment.

Mental model

  • Product shape comes first. Agents amplify one user action into many calls; chat exposes the initial pause; voice is governed by conversational round-trip delay; media visibly trades speed against quality; search mixes offline corpus preparation with online queries; and moderation often favors economical throughput. The category predicts the cost of waiting and the value of parallel work.
  • The workload contract names the exact model, request format, output behavior, latency budget, spending unit, concurrency pattern, peaks, and geographic or privacy restrictions. These are not documentation after the design; they are inputs to model, deployment, and measurement choices.
  • Quality is a gate, not an assumption. General benchmarks can shortlist candidates, but the product’s hardest realistic cases decide whether a model is capable. The same evaluation set becomes a baseline for checking fine-tuning, distillation, quantization, or other changes that may shift behavior.
  • Serving mode is an economic and control choice. Shared endpoints remove operational overhead and match uncertain early demand. Dedicated deployments introduce a spending floor and engineering responsibility, but can win when volume, custom models, strict performance, uptime, or multi-model orchestration create a clear business need.
  • Measurement closes the loop. Use inference metrics to isolate model-serving performance and end-to-end metrics to represent the product. Examine distributions rather than only means, and segment online from offline workloads so one aggregate does not conceal incompatible objectives.

Evaluation is the bridge between product language and serving language. A product owner can describe unacceptable failures and the hardest successful cases; the evaluation set turns them into repeatable evidence. An inference engineer can then compare a smaller model, a fine-tuned variant, or a quality-risking optimization without guessing whether the behavioral change matters. This bridge must remain attached to workload slices. A model that passes on short requests may fail on long context, and a service that looks economical at average traffic may miss the latency budget at concurrency peaks. If evaluation measures only capability, performance tests use synthetic inputs, and cost estimates assume another traffic pattern, those three sets of numbers cannot answer the same product question. The contract, evaluation, and serving measurements should therefore use matching scenarios, input distributions, and identifiers so every comparison traces to one use case.

Core ideas

  • Online work places an impatient user behind the request and should emphasize latency. Offline work can tolerate slower individual requests in exchange for more completed work per hour. The same model may deserve separate deployments when both patterns have enough volume, because a compromise configuration can be unnecessarily expensive for both.
  • Consumer demand is often volatile and margin-sensitive, favoring flexibility and low marginal cost. Business software may have steadier use and better margins but stronger availability and consistency requirements. In either market, sovereignty, privacy, and regulation can remove otherwise attractive infrastructure options.
  • Shared and dedicated inference are independent of whether model weights are open. Start shared while requirements are unclear. Move to dedicated capacity when paying for GPUs beats paying for consumption, when customization or service guarantees require control, or when a multi-model pipeline makes network and deployment coordination material.
  • All else equal, fewer parameters mean faster and cheaper inference. The best candidate is therefore the smallest model that clears the task-specific quality bar and uses an architecture with robust engine support. A larger frontier model remains justified when smaller candidates fail, but its necessity should be demonstrated rather than presumed.
  • Public capability benchmarks help with discovery but can be saturated or optimized as targets. High-conviction evaluation uses representative product data, focuses on the hardest tasks that matter, and checks results against domain judgment. It answers two questions before performance work begins: is this model useful, and how much quality can later optimization spend?
  • Fine-tuning changes a pre-trained model for a specific domain; a small tuned model can sometimes match a much larger general model on a narrow task. Distillation instead teaches a smaller student to emulate a larger teacher’s probability behavior. It can transfer useful behavior and limitations, but appears less often in production than fine-tuning.

How it works

  1. Classify the interaction. Record whether the job is online or offline, streamed or returned whole, single-model or multi-step, and consumer or business-facing. Include compliance constraints before considering regions or providers.
  2. Turn expectations into budgets. Specify acceptable end-to-end wait, request or user economics, likely concurrency, daily shape, bursts, availability, input form, and output form. Separate non-negotiable limits from preferences so later trade-offs have a clear order.
  3. Build a product-specific evaluation set and use broad benchmarks only to narrow the field. Inspect real examples, concentrate on difficult cases, and retain scores plus representative failures as the quality baseline.
  4. Compare candidates from smaller to larger until one passes. Check architecture support in the intended inference engines, because a popular, well-supported family can inherit mature performance work across sizes, variants, and fine-tunes.
  5. Keep shared inference while uncertainty and low volume make consumption pricing and minimal engineering attractive. Approve dedicated deployment only when current economics, specialization, or orchestration needs justify its capacity commitment and operational ownership.
  6. Instrument both inference and client paths. For streaming, record the first visible token and subsequent delivery cadence; for non-streamed tool calls, record total response time. Report percentiles, throughput, quality, and cost on the same workload slices used in the contract.
End-to-end latency = queue time + network time + inference time + surrounding application work
Inference-only timing isolates model-serving work; the complete path explains what the user waits for and directs investigation to the right layer.

Metrics that matter

Time to first token

Lower TTFT

Measures the streamed user’s wait for the first output and reflects compute-heavy prefill.

Perceived tokens per second

Higher TPS

Measures per-user token delivery after the first token and reflects bandwidth-heavy decode.

Inter-token latency

Lower ITL

Measures time between consecutive tokens; ten milliseconds corresponds to one hundred tokens each second.

Total service throughput

Total TPS

Counts all tokens the service generates each second and must not be confused with one user’s perceived speed.

Tail percentiles

P90, P95, and P99

Reveal slow outliers that a mean or median can hide in a right-skewed response distribution.

Total response time

Request start to useful completion

Fits non-streamed agent tool calls and other outputs whose individual tokens are not useful to the caller.

A metric needs a protocol, not only a name. Record where the timer begins and ends, whether output is streamed, the prompt and output lengths, concurrency, serving mode, and the percentile being reported. For TPS, state whether the numerator covers one response or the entire service. Pair latency with the evaluation result and cost for the same workload, since a faster run with degraded answers or a different request mix is not comparable. Finally, align inference-only and end-to-end traces by request. When model time stays flat while client time rises, the evidence points toward queueing, network distance, or application work instead of another model optimization. The protocol should also fix load generation and warm-up state, avoiding cold starts, burst queues, and steady execution collapsed into one mean. Alongside central tendency, retain P90, P95, or P99 tails and the sample window. Then model, deployment, or version results become comparable and user complaints map to a specific service stage.

Trade-offs

Latency versus throughput

Online interactions reward quick individual responses; offline jobs reward more completed work per unit time. Design separate deployments when one model serves both at meaningful volume rather than forcing a single configuration to satisfy opposing objectives.

Shared versus dedicated

Shared service offers low overhead, consumption pricing, and no deployment cold start, but limited control and provider dependence. Dedicated service offers control and potential scale economics, but adds a spending floor, capacity exposure, and engineering responsibility.

Model size versus task quality

Smaller models are easier to serve, but only useful if they pass the product’s evaluation. Fine-tuning can move that frontier for a narrow domain; a larger general model remains appropriate when the task genuinely requires its capability.

Average versus tail

Improving a mean benefits aggregate speed, while reducing high percentiles protects users from rare but trust-damaging waits. A service needs both views because inference latency is commonly right-skewed.

Inference time versus product time

On-GPU timing is the right measure for model-performance work; end-to-end timing is the right measure for user experience. A gap between them redirects attention toward queueing, networking, or other infrastructure.

Engineering checklist

  • Name the application category, interaction mode, audience, and whether the workload is online, offline, or both.
  • Record model, interface, latency, unit economics, concurrency, usage shape, availability, privacy, sovereignty, and compliance constraints.
  • Create task-specific evaluations from representative and difficult product cases before performance optimization.
  • Test the smallest well-supported model family that can plausibly pass the quality gate.
  • Document the current economic or control reason before moving from shared to dedicated inference.
  • Label TPS explicitly as per-user perceived speed or total service throughput whenever ambiguity is possible.
  • Report the percentile and workload slice for every latency result instead of relying on a mean alone.
  • Instrument inference-only and end-to-end timing so a slow product can be traced to the proper layer.

Vocabulary

Shared inference
A public serving endpoint billed by consumption and operated for many customers or workloads.
Dedicated deployment
GPU capacity and an inference service reserved for one application or organization.
Model evaluation
Systematic measurement of whether model behavior meets the target product and task requirements.
Fine-tuning
Adapting a pre-trained model to a domain by training it with additional task-relevant data.
Distillation
Training a smaller student to emulate probability behavior produced by a larger teacher model.
TTFT
The elapsed time from request start until the first streamed output token becomes available.
Perceived TPS
The token delivery rate observed by one user after generation has begun.
ITL
The elapsed time between consecutive generated tokens in a streamed response.
Tail latency
Slow response behavior represented by high percentiles such as P95 or P99.

Source map

  • Printed pages 25–26

    Defines product constraints that give optimization a concrete target.

  • Printed pages 26–27

    Compares shared and dedicated inference and states the main reasons to switch.

  • Printed pages 27–30

    Differentiates application categories, workload timing, markets, and compliance needs.

  • Printed page 31

    Makes model size and architecture support first-order inference decisions.

  • Printed pages 31–32

    Explains product-specific evaluation and its role as a quality baseline.

  • Printed pages 32–35

    Contrasts domain fine-tuning with teacher-student distillation.

  • Printed pages 35–36

    Defines streaming token metrics and the ambiguity of per-user versus total TPS.

  • Printed pages 36–37

    Motivates percentile reporting for right-skewed response times.

  • Printed pages 37–38

    Separates on-GPU inference time from the complete user-visible path.

Product-specific optimization, model requirements, interfaces, budgets, and usage patterns
Printed pages: 25–26; PDF pages: 27–28
Shared inference, dedicated deployments, and the scale, specialization, and orchestration threshold
Printed pages: 26–27; PDF pages: 28–29
Application categories, online versus offline work, consumer versus business products, and compliance
Printed pages: 27–30; PDF pages: 29–32
Selecting the smallest capable model and preferring well-supported architectures
Printed pages: 31–31; PDF pages: 33–33
Product-specific model evaluation, baselines, and limits of general benchmarks
Printed pages: 31–32; PDF pages: 33–34
Fine-tuning, distillation, domain specialization, and architecture support
Printed pages: 32–35; PDF pages: 34–37
Time to first token, tokens per second, inter-token latency, and total response time
Printed pages: 35–36; PDF pages: 37–38
Right-skewed latency, percentile reporting, and tail experience
Printed pages: 36–37; PDF pages: 38–39
Inference-only versus end-to-end measurement and bottleneck localization
Printed pages: 37–38; PDF pages: 39–40