[01-latency-percentiles] measures the SPREAD of latency across requests, but LLM serving has its own vocabulary for what happens WITHIN a single streamed response. Given the timestamps at which each token of a generated response was produced (plus the request's arrival time), compute the four standard LLM serving metrics: time-to-first-token (TTFT), time-per-output-token (TPOT), inter-token latency (ITL) per gap, and overall token throughput.
TTFT = token_timestamps[0] - request_arrival_time
ITL_i = token_timestamps[i] - token_timestamps[i-1] for i = 1..n-1
TPOT = mean(ITL)
throughput = n_tokens / (token_timestamps[-1] - request_arrival_time)
request_arrival_time, not from the first token's own generation start.n_tokens - 1).None if fewer than 2 tokens).TPOT is specifically the pace of SUBSEQUENT tokens, which is why it's mean(ITL), not mean including TTFT. Guard the n_tokens == 1 case: there are no ITLs and TPOT is undefined (return None rather than dividing by zero).
No results yet
Run your code to check it against the examples, or submit to run every test.