Unit 3 of 13 · about 4 hours · derive

Cost per token, quality acceptance, retry cost and energy

Build on Unit cost, headroom and simpler designs. Token counts now need quality, retry and allocation rules before they can support an economic comparison.

You'll be able to

  • Derive input, output and quality-accepted output unit costs with explicit allocation rules.
  • Account for failed attempts, retries, idle capacity and failure reserve in serving cost.
  • Optionally derive joules and operational carbon per useful output with an explicit measurement boundary.

Covers

Cost per input, output and accepted tokenQuality acceptance and retry costEnergy and carbon accounting alongside cost
1

Read

In this order, only the parts listed

0 of 3 done

  1. Lifetime serving economicsMachine Learning Systems, Volume 2 - The Economics and Architecture of Inference

    Inference at Scale, Serving cost can dominate training cost: Napkin Math 1.1 and equation 2; The serving hierarchy (page read 2026-10-14)

    Stop before Serving Architecture Dimensions. Treat the monetary examples as assumed scenarios, not current prices or measurements.

  2. Quality, retries and cost belong to one plannerLLM Inference Systems Laboratory - Full Capstone

    Core requirements: analytical planner; Architecture constraints: correctness and quality; Failure-injection requirements: retry storm; Measurement requirements: quality and cost/token/request

  3. Optional energy and operational carbon boundaryMachine Learning Systems, Volume 2 - Sustainable AI

    Energy measurement techniques: Hardware power counters and System-level energy profiling; Carbon Footprint Calculation: Operational carbon calculation, equation 11 (page read 2026-10-14)

    Optional: read the measurement and unit-conversion method only. Do not adopt the chapter's hardware power estimates or fleet results.

2

Focus on

  • For total interval cost , report , and as separate normalizations, not additive charges. Splitting input and output charges requires an explicit allocation policy.
  • Sum costs over every attempt for a logical request; count its accepted output once. Retry amplification depends on failure correlation, backoff, deadline and attempt cap.
  • Keep quality acceptance separate from speculative draft-token acceptance. A verified draft token is not evidence that an answer meets the application's quality gate.
  • Optional: integrate measured power over the same interval as accepted work. GPU energy alone is not total IT energy; facility overhead and grid intensity are assumptions unless measured.
Common mistakes · 3
  • Dividing only successful-attempt cost by accepted output. Failed attempts and provisioned idle time still consume budget.
  • Comparing token costs across tokenizers as if tokens were identical work. Use the same text tasks and quality gate; report tokenizer identity.
  • Applying facility overhead twice or to GPU energy alone and calling it a measured facility footprint. State what is missing.
3

Try it yourself

Closed-book, before checking anything

Derive a synthetic accounting example without notes: an interval costs 12 currency units, processes 6000 input tokens and generates 3000 output tokens across all attempts, of which 2000 are quality-accepted useful output tokens. Obtain 0.002 per input token, 0.004 per generated output token and 0.006 per accepted token. With independent attempts of constant cost , success probability and unlimited retries, derive expected cost ; state why bounded deadlines and correlated failures require a different model. Optional: a constant 100 W over 10 seconds is 1000 J, or 0.5 J per accepted token for this fixture.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.May input-normalized and output-normalized total costs be added?Answer

    No. Each uses the same numerator. Adding them double counts cost; additive input/output prices need an allocation or billing rule.

  2. 2.When does expected retry cost equal ?Answer

    For independent, identically distributed attempts, constant per-attempt cost, positive success probability and unlimited retries. Deadline caps and correlated failures invalidate that shortcut.

  3. 3.What if no output passes the quality gate?Answer

    Cost per accepted token has no finite value. Report zero accepted output and the spent cost; do not replace the denominator with generated tokens.

  4. 4.How do you convert energy to operational carbon?Answer

    Multiply facility energy in kWh by the corresponding grid intensity in mass per kWh. Apply facility overhead once if starting from complete IT energy; report embodied carbon separately.

You're done when

Your cost table reconciles all attempts and idle/reserve charges, counts accepted work once and states the units and allocation boundary of every denominator.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 11 more in the section
  • Machine Learning Systems, Volume 2 - The Economics and Architecture of InferenceHarvard (Vijay Janapa Reddi) · support

    Read the opening sections of Inference at Scale for cost per token, utilization and serving-architecture dimensions, then build your own capacity and cost model from measured numbers.

  • LLM Inference Systems Laboratory - Full CapstoneRoadmap-Final · required

    Complete the architecture map, contribution, fallbacks, correctness and fault suite, raw benchmark package, negative result, capacity and cost plan, independent reproduction and design defense. This artifact supplies the track milestone.

  • Machine Learning Systems, Volume 2 - Sustainable AIVijay Janapa Reddi · support

    For optional energy/carbon accounting, read Energy measurement techniques, System-level energy profiling and Operational carbon calculation. State meter boundaries and apply PUE only to complete IT energy, once.

Also in this section

  • Hands-On LLM Serving and Optimization - Chapters 8 and 9, frameworks and optimization in practiceChi Wang and Peiheng Hu (O'Reilly) · primary

    Read Chapter 9 as a worked sequence from traffic generation and baseline through quantized and distributed variants, then the vLLM architecture and scheduler sections of Chapter 8. Replace its model, engine version and hardware with your own fixed contract.

  • TensorRT-LLM Benchmarking GuideNVIDIA · required

    Use the benchmark workflow, configuration capture, startup metrics and online-serving path as a benchmark-governance reference. Apply the same discipline to your engine and never import NVIDIA results as your own evidence.

  • vLLM V1 Architecture OverviewvLLM Project · required

    Map API server, EngineCore, scheduler, KV cache manager, model executor and distributed deployment from the current documentation into exact source files. Select the bounded contribution only after identifying its state and fallback boundaries.

  • Nano-vLLM and Mini-SGLang as Engine Reconstruction BridgesGeeeekExplorer and SGLang Project · required

    Reconstruct Nano-vLLM first, then compare Mini-SGLang cache, scheduler, overlap and model-runner boundaries. Move to vLLM or SGLang only when you can predict where the same responsibility lives.

  • UCSD CSE 291A (Spring 2026) - Guest lecture: Engineering vLLMUC San Diego · support

    Read the scribe notes, Sections 3, 6 and 7: the architecture overview, model parallelism and serving topology, and the hybrid KV allocator with offloading. Use it to predict where a change would live before reading code.

  • AI Performance Engineering - Inference Engine and Benchmark LanesWafer · reference

    A curated index. Use Sections 4 and 5 only to find a mechanism source for the contribution.

  • AI Systems Performance Engineering companion code - inference labsChris Fregly (O'Reilly) · required

    Use labs/dynamic_router, labs/cache_aware_disagg_inference, labs/speculative_decode or labs/flashinfer_attention as a pattern for a controlled baseline, optimization and profile. Rerun everything under your own manifest.

  • Etalon: Holistic Performance Evaluation Framework for LLM Inference SystemsMicrosoft Research · required

    Use its per-request SLO and goodput framing to audit the benchmark. Preserve raw outcomes, quality acceptance and load shape so a throughput increase cannot hide missed latency targets.

  • MLPerf Inference Datacenter BenchmarkMLCommons · support

    Study scenario definitions, audit discipline and reproducibility. Borrow governance ideas appropriate to the capstone; submitting to MLPerf or reproducing its fleet hardware is outside the gate.

  • Artificial Analysis - Performance benchmarking methodologyArtificial Analysis · reference

    Read how its latency, output speed and price figures are measured. Use its public numbers as an outside comparison for your capacity plan, never as your own evidence.

  • SciPy bootstrap confidence intervalsSciPy · support

    Read the resampling procedure, paired parameter, Notes on degenerate data and Examples. Apply it to independent trials; do not assume correlated serving requests are independent samples.