A hash layer replaces the learned router's selection with a fixed table: token id always goes to the experts in row of a (V, k) table, and nothing during training can rebalance it. Because token frequencies are heavy-tailed, how the table is built decides how even the expert load is. Build two tables and measure them.
round_robin_table(vocab_size, num_experts, k)
(V, k) int array.balanced_table(token_counts, num_experts, k)
token_counts[v] is how often token id occurs in a reference corpus. Greedy bin packing: keep a running load per expert, all zero at the start. Visit the token ids in descending count order (equal counts: lower id first). Give the current token the distinct experts with the smallest current load (equal loads: lower expert index first), write them into its row in that order (smallest load first), then add the token's count to each of those experts' loads.(V, k) int array. Assume .expert_loads(table, token_counts, num_experts)
token_counts[v] over every row that contains . Return an int array (N,).maxvio(loads)