7 MoE routing strategies in production, clearly explained
Onyx 是一款基於 MIT license 開源、可 self-host 的 AI 聊天平台,支援包括 Claude、GPT、Gemini 和 Llama 在內的多種 large language models。它提供 multi-tool agents、MCP 支援、code interpreter,並具備透過 Docker 進行 self-hosting 的能力。與 Claude 透過 MCP-based connectors 進行 runtime 查詢不同,Onyx 會對橫跨超過 40 種 connectors 的團隊資料建立索引,以實現更快且更可靠的搜尋。此外,其 deep research 功能在 DeepResearchBench benchmark 上名列第一,超越了專有解決方案。Mixture of Experts (MoE) 模型必須在 expert 選擇品質、計算效率與 communication overhead 之間取得平衡,因為單純將 token 路由至得分最高的 expert 會導致 workload 不均衡。不同的 MoE routing 策略——包括 top-k routing、Expert Choice、confidence thresholds、global matching、deterministic hashing、Soft MoE 和 node-limited routing——以不同方式因應這項權衡。有幾種 routing 方法源自於訓練或 vision 研究領域,在應用於 autoregressive 文字生成之前需要謹慎調整。有效的 production serving 需要分別對 routing、token communication、expert execution 和 output combination 進行 profiling,以找出瓶頸。模型的 benchmark 分數並不能反映其在 production 高度 API 負載下的表現。為此,GitHub 上推出了一份包含 50 次半小時 session 的 10 週實用學習路線圖(roadmap),涵蓋核心 LLM inference engineering 主題。課程重點在於利用 roofline model 理解硬體瓶頸、部署像 vLLM 和 SGLang 這樣的 inference engines、掌握 prefix caching 和 continuous batching 等技術,以及建立完善的 observability。最終,這些練習將指引工程師建構、instrument、load-test 並 benchmark 兼顧成本效益的 inference service。
Claude 的開源替代方案(33k+ stars)!
Onyx 是一款基於 MIT license 開源、可 self-host 的 AI 聊天平台,支援包括 Claude、GPT、Gemini 和 Llama 在內的多種 large language models。它提供 multi-tool agents、MCP 支援、code interpreter,並具備透過 Docker 進行 self-hosting 的能力。與 Claude 透過 MCP-based connectors 進行 runtime 查詢不同,Onyx 會對橫跨超過 40 種 connectors 的團隊資料建立索引,以實現更快且更可靠的搜尋。此外,其 deep research 功能在 DeepResearchBench benchmark 上名列第一,超越了專有替代方案。
- Onyx 是一款開源(MIT licensed)AI 聊天平台,支援如 Claude、GPT、Gemini、Llama 以及 open-weight 模型。
- 該平台具備串接工具的 agents、MCP 支援、code interpreter,以及透過 Docker 進行 self-hosting 部署的功能。
- Onyx 對橫跨超過 40 種 connectors(包括 Slack、Drive、Confluence、Jira 和 GitHub)的資料建立索引,而不是像 Claude 一樣在 runtime 進行查詢。
- Onyx 的 deep research 能力在 DeepResearchBench 上排名第一,表現優於其他專有替代方案。
詳解 production 中的 7 種 MoE routing 策略
Mixture of Experts (MoE) 模型必須在 expert 選擇品質、計算效率與 communication overhead 之間取得平衡,因為單純將 token 路由至得分最高的 expert 會導致 workload 不均衡。不同的 MoE routing 策略——包括 top-k routing、Expert Choice、confidence thresholds、global matching、deterministic hashing、Soft MoE 和 node-limited routing——以不同方式因應這項權衡。有幾種 routing 方法源自訓練或 vision 研究領域,在應用於 autoregressive 文字生成前需要謹慎調整。有效的 production serving 需要分別對 routing、token communication、expert execution 和 output combination 進行 profiling,以找出瓶頸。
- 標準的 top-k routing 固定了每個 token 的 expert 數量,但無法保證 serving batches 之間的 expert workload 保持均衡。
- Expert Choice 顛倒了 routing 方式,由 expert 在 capacity limit 內挑選 token,這平衡了 expert load,但可能會使某些 token 未被分配。
- BASE Layers 展示了在 expert capacity 限制下透過 global matching 分配 token,代價是額外的 solver overhead。
- Soft MoE 使用 slot 來處理 token 的加權混合(weighted mixtures),而非離散的 token,這對 autoregressive decoding 帶來了 causality 方面的挑戰。
- DeepSeek-V3 採用了 node-limited routing,將每個 token 限制最多路由至 4 個 node,以減輕跨 node 的 communication overhead。
身為 AI 工程師,請務必掌握:
模型的 benchmark 分數並不能反映其在 production 高度 API 負載下的表現。為此,GitHub 上推出了一份包含 50 次半小時 session 的 10 週實用學習路線圖(roadmap),涵蓋核心 LLM inference engineering 主題。課程重點在於利用 roofline model 理解硬體瓶頸、部署像 vLLM 和 SGLang 這樣的 inference engines、掌握 prefix caching 和 continuous batching 等技術,以及建立完善的 observability。最終,這些練習將指引工程師建構、instrument、load-test 並 benchmark 兼顧成本效益的 inference service。
- 在 roofline model 下,small-batch 的 token decoding 通常是 memory-bound。
- Inference observability 應在最佳化之前就建構完成,使用 Prometheus 和 Grafana 追蹤 time to first token (TTFT)、inter-token latency、throughput 和 queue depth 等指標。
- Prefix caching 重用的是 shared-prefix 的計算,而非生成新的 token。
- 在 FP8 和 INT4 之間評估像 AWQ 和 GPTQ 這樣的 quantization 方法時,需要權衡品質與記憶體使用量及速度。
- GitHub 上結構化的 10 週 roadmap 引導工程師部署服務、執行高併發 load tests(最高達 1,000+ requests),並發布具再現性的 benchmarks。