Skip to content
DeepForgeby svx
All problems
MediumDeep Learningdl-445

TTFT Component Sum

Problem

Sum the components of time to first token and report the dominant one: tokenization, queueing, prefill compute and network transfer. Return [total_ms, dominant], choosing the earliest component in that order on ties.

The signature is ttft_components(tokenize_ms, queue_ms, prefill_ms, network_ms).

Hint

Strict greater-than keeps the first component when several tie for the maximum.

Test cases

case 1
in: [2,5,80,3]
expected: [90,"prefill"]
case 2
in: [1,1,1,1]
expected: [4,"tokenize"]
case 3
in: [0,40,20,40]
expected: [100,"queue"]
case 4
in: [5,0,0,0]
expected: [5,"tokenize"]
Starter codePython
def ttft_components(tokenize_ms, queue_ms, prefill_ms, network_ms):
    # Your code here
    pass

4 test cases · run your code against them in the editor