Streaming Latency Metrics: TTFT, TPOT and ITL

easy
Unit 6 · Agents & Inference0/3 to milestone

LLM serving dashboards track:

  • TTFT (time to first token): first token time minus request start
  • TPOT (time per output token): (last - first) / (n_tokens - 1), undefined for a single token
  • ITL (inter-token latency): every gap between consecutive tokens

Each request is (start_time, token_times) in seconds. Implement:

  • request_metrics(start, token_times): a dict with ttft, tpot (None for one token) and itl (a list)
  • summarise(requests, percentiles=(50, 95, 99)): a dict with ttft_p<k> and itl_p<k> for each percentile (pooling the ITL gaps from all requests, using np.percentile) and throughput: total tokens divided by the span from the earliest start to the latest token
#inference#monitoring#performance2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Streaming Latency Metrics: TTFT, TPOT and ITL · TechGradify