All problems
Expert Capacity Drop Rate
Problem
Compute the fraction of tokens dropped by expert capacity limits. Capacity per expert = ceil(num_tokens * capacity_factor / num_experts); tokens beyond capacity are dropped.
The signature is expert_capacity_drop(expert_counts, num_tokens, capacity_factor). Return the drop rate.
Hint
Tiny capacity factors drop tokens; large ones waste compute on padding.
Test cases
case 1
in: [[10,10,10,10],40,1]
expected: 0
case 2
in: [[20,0,0,0],20,1]
expected: 0.75
case 3
in: [[5,5,5,5],20,0.5]
expected: 0.4
case 4
in: [[7,3],10,1]
expected: 0.2
Starter codePython
import math
def expert_capacity_drop(expert_counts, num_tokens, capacity_factor):
# Your code here
pass4 test cases · run your code against them in the editor