NumPy allowed · plain Python earns 10 bonus points
Q · Kᵀ / √d scores normalized with softmax
Implement Mixture-of-Experts top-k routing, the real gating mechanism deciding which experts process a given token and how much weight each contributes.
Implement moe_topk_routing(router_logits, top_k). Apply softmax to router_logits to get expert probabilities. Select the top_k experts by probability. RENORMALIZE just those top_k probabilities to sum to 1 (so the token's output is a proper weighted combination of only the selected experts). Return a list of {"expert_idx": int, "weight": float}, sorted by expert_idx ascending.
moe_topk_routing(router_logits: list[float], top_k: int) -> list[dict]