All problems
Draft Cost Ratio From Time
Problem
Compute the cost ratio of running the draft model versus the target model per token: draft_ms_per_token / target_ms_per_token. This is the per-token time ratio that speculative decoding multiplies by the number of drafted tokens.
The signature is draft_cost_ratio(draft_ms_per_token, target_ms_per_token).
Hint
A draft ten times faster per token has a cost ratio of 0.1.
Test cases
case 1
in: [1,10]
expected: 0.1
case 2
in: [0,5]
expected: 0
case 3
in: [5,5]
expected: 1
case 4
in: [2,8]
expected: 0.25
Starter codePython
def draft_cost_ratio(draft_ms_per_token, target_ms_per_token):
# Your code here
pass4 test cases · run your code against them in the editor