Experts run as fixed-size matrix multiplies, so each one can only take a set number of tokens per batch. Switch Transformers set that capacity from the average load times a slack factor, and tokens beyond it are dropped.
Implement expert_capacity(n_tokens, n_experts, capacity_factor), returning the integer capacity per expert.
Multiply the factor by the average load per expert, then take the ceiling.
No results yet
Run your code to check it against the examples, or submit to run every test.