16 / 16 · Responsibility and Cost
Cost and efficiency of ML systems
Where the money of an ML system goes and how to spend less: training against inference, GPU utilization and MFU, latency–cost Pareto fronts, choosing a serving configuration, spot capacity and scaling to zero, the cost of an LLM request, and its energy.
Distributed training · Serving models · LLM inference systems
On this page 11
A server can become cheaper per processed item while the monthly bill grows. More capacity may sit idle; a faster model may trigger more retries; a lower token price may encourage longer prompts. We need a denominator tied to useful work and a workload against which configurations can be compared.
All prices, capacities and durations below are fictional inputs to an original arithmetic example. They are neither vendor quotations nor measured accelerator results.
Name the unit of useful work#
For the preview service, define success as a usable preview delivered within the agreed delay. Count failed attempts and retries in cost, but count the completed preview once in the denominator. If is total cost and useful completions, unit cost is . A low cost per attempted request can coexist with a high cost per completion.
Separate costs that follow volume from costs that remain when traffic stops. A permanently allocated worker costs money during idle time. Storage depends on retained bytes and duration. Human review depends on the decision policy. Recording those terms prevents an optimization in inference from concealing increased work elsewhere.
Training and inference occur on different clocks#
A training run is a bounded job; inference is a continuing workload. For a reporting period, write
The terms are accounting categories defined for this example. Include failed experiments and repeated evaluation in training cost. Amortizing a run over future requests requires an assumed useful lifetime. If a model is replaced sooner, its actual cost per useful completion rises.
For a service with hourly price and sustained useful throughput of completions per hour, the fully utilized compute cost per completion is . That expression does not include storage, network or review, and it does not apply at capacity when actual arrival rate is lower.
Busy hardware and useful arithmetic#
A device may report busy time while waiting on memory or executing recomputation. Model FLOPs utilization (MFU) compares the required model computation per unit time with the system’s peak arithmetic rate; its definition excludes extra recomputation used by the implementation (Chowdhery et al.). Use the same precision and arithmetic convention for numerator and denominator.
If the required model work completed each second is 30 trillion operations and the compatible peak is 100 trillion, MFU is . These are hypothetical rates. They say nothing about memory capacity or whether an output is correct. Training and inference can have different bottlenecks; a training MFU target is not automatically a serving objective.
Compare feasible configurations#
The following fictional configurations serve the same request distribution at the same stipulated quality. Latency is an assumed p95 at the listed load.
| Configuration | Cost/hour | Useful requests/hour | p95, ms | Compute cost/request |
|---|---|---|---|---|
| A | 0.72 | 180 | 90 | 0.004000 |
| B | 1.08 | 300 | 65 | 0.003600 |
| C | 1.62 | 420 | 45 | 0.003857 |
| D | 1.44 | 300 | 80 | 0.004800 |
B is both faster and cheaper per request than A and D. Neither B nor C dominates the other: C buys lower delay at greater unit cost. These two form the Pareto frontier for the stated pair of objectives. A configuration dominates another only if it is no worse on every chosen objective and strictly better on at least one.
With a p95 requirement of at most 80 ms, B, C and D satisfy the delay bound, but D is dominated by B. Choose between the remaining options by cost and latency margin. If B receives only 60 requests per hour while remaining allocated, its compute cost is per request. The attractive 0.0036 figure assumed 300. Capacity and actual utilization must therefore be reported together.
Price the entire call path#
For a token-priced service, let be input/output tokens and their prices per token. One call costs . Add each attempt in a retry or tool loop. A prefix-cache discount changes the input term for the tokens actually billed at that rate; it does not remove output generation.
For self-hosting, token counts are workload descriptors rather than an invoice. Long contexts consume cache memory and long outputs retain a decoding slot. Compare cost per successful task as well as tokens per second. The LLMOps example supplies a separate, fully specified call calculation.
Change one mechanism and preserve the contract#
Batching shares execution overhead but may add queue delay. Quantization reduces storage or computation only where the engine supports the format, and it changes numerical behaviour. More parallel devices can shorten one request while adding communication and hourly cost. Each proposal needs a quality check and a latency measurement on the workload that will use it. An engine feature list cannot establish the frontier.
Keep the input distribution, output-length rules and success criterion fixed during a comparison. Record configuration and engine versions with the measurements. Recheck after traffic changes: a configuration that wins on short requests can lose on a mixture with a long tail.
Interruption changes the effective price#
Interruptible capacity is useful when work can restart from durable checkpoints. In a simplified schedule, four minutes of checkpoint work after every sixty minutes of useful computation consumes of uninterrupted runtime. If a failure lands uniformly inside a sixty-minute work interval, the mean lost work is thirty minutes. These assumptions omit correlated failures, checkpoint failures and restart time.
AWS describes interruption warnings as best effort, with different behaviour for hibernation; a last-second checkpoint is therefore not a durability strategy (AWS). Reserved capacity changes the commitment and discount structure but still needs a utilization forecast. Lower advertised hourly price is only one term in effective job cost.
Empty queues do not imply instant shutdown#
Scaling to zero saves idle allocation while adding cold-start work to the next request. The service must retain its queue, artifacts and ownership information outside the terminated worker. A deadline-sensitive path may need warm capacity; an asynchronous repair queue may tolerate startup delay. Scale against a signal related to waiting work and service rate, then verify the complete-request delay during bursts.
Avoid using a daily average as the sole scale target. A long running request can keep a device busy after the queue length falls to zero. Cancellation and draining behaviour determine whether scale-down loses useful work or simply waits for it.
Energy has its own units#
Average electrical power in kW multiplied by hours gives kWh. In a hypothetical run, two devices averaging 0.15 kW for three hours use kWh. Applying a facility-overhead multiplier of 1.2 gives 1.08 kWh. This excludes manufacturing and any infrastructure outside the chosen boundary.
To estimate operational emissions, multiply energy by a region- and time-specific emissions intensity, with compatible units. Hardware power limits are not measured average power. A financial saving is not automatically an energy saving if the new configuration runs longer or moves work elsewhere.
What changed#
We can now reject A and D for the stated workload, explain why B’s cost rises under low traffic, and account for repeated work. The decision remains conditional on quality, volume and delay; the fictional table cannot select real hardware.
Limits#
Real measurements need warmup, enough requests to estimate tail latency, and an explicit treatment of failed requests. Shared hosts, changing prices and bursty demand can invalidate a comparison. The accounting boundary must also remain stable: excluding review or data preparation from one option makes its apparent saving misleading.
What to retain#
Use useful completions as a denominator. Separate capacity from utilization. Compare cost, latency and quality together. Include retries, idle time and interruptions. Keep energy units and accounting boundaries explicit.
Reproduce the calculation#
The cost function in Python source recomputes the table, dominance decisions, low-load cost, checkpoint fraction and energy. Its saved output contains B and C as the nondominated configurations. It performs no cloud requests and does not load a model.
Connect cost to the rest of the system#
Cost depends on decisions made throughout the pipeline: the data retained, the features calculated, the acceptance rule, the serving schedule and the recovery path. A release should carry those assumptions alongside its quality evidence. When an assumption changes, repeat the comparison that depended on it.
References#
- Aakanksha Chowdhery et al. PaLM: Scaling Language Modeling with Pathways, 2022, section 4.1 and appendix B: definition of MFU. No benchmark table or model artifact reproduced.
- Amazon Web Services. Spot Instance interruption notices, checked 13 November 2026: best-effort notification and hibernation exception. No event payload or example code reproduced.
- NVIDIA Triton contributors. Dynamic Batcher, checked 13 November 2026: queue-delay and batching mechanism. The configuration table above is original fictional data.