Skip to content
nonconvexcard

Build a serving capacity calculator

CodingAdvanced⏱ 3 hoursLLM Opsrooflinesimulationcapacity planningimplementation

Problem

Implement a capacity planner and validate it against the analysis.

  1. Given model shape, precision and hardware, compute the decode latency floor, the KV cache per token, the maximum batch at a given context, and whether decode is compute- or memory-bound.
  2. Sweep context length and plot achievable batch size and arithmetic intensity together.
  3. Simulate static versus continuous batching with a heavy-tailed length distribution and measure the utilisation gap against the 1/HB1/H_B prediction.
  4. Add speculative decoding and find the optimal γ\gamma numerically for measured α\alpha.

Implement it, then check the implementation against something you can verify independently.

Write it

Solve it here6 tests · Python runs in your browser
⌘/Ctrl + ↵ to run · limit 20s · draft saved in this browser
6 tests will run against your code. The first run downloads the Python runtime — several megabytes, once per browser.

Solution

Opening this before you have a real attempt on paper is the fastest way to feel like you understand something you cannot reproduce.

Related problems

All problems
SolvedProblemFieldTypeDifficultyTime
Count the FLOPs of a forward passLLM OpsNumericalFoundation15 min
Derive the attention crossover lengthLLM OpsProofBeginner15 min
Implement the cluster sizing formula runAI SystemsCodingBeginner30 min
Ridge point and the batch size needed to saturateLLM OpsNumericalBeginner15 min
Simulate distance contrast runClassical MLCodingBeginner30 min