MoE Serving Routing LoadBalance
MoE Serving - Routing๊ณผ Load Balancing ์ฌ์ธต ๋ถ์
Expert Routing ยท All-to-All Dispatch ยท Capacity Factor ยท Expert Parallelism ยท Hot Expert Replication
๊ฐ์
MoE ์๋น์ ๋ณ๋ชฉ์ ์ ๋ฌธ๊ฐ ์๋ณด๋ค ํ ํฐ์ด ์ ํ๋ ์ ๋ฌธ๊ฐ๋ก ์ผ๋ง๋ ๊ณ ๋ฅด๊ฒ, ๋น ๋ฅด๊ฒ ์ด๋ํ๋๋์ ๊ฐ๊น์ต๋๋ค. sparse activation์ ๊ณ์ฐ๋์ ์ค์ด์ง๋ง, expert parallelism์ ์ฐ๋ ์๊ฐ all-to-all dispatch์ gather๊ฐ ์ถ๊ฐ๋์ด ํต์ ์ด ์ง์ฐ์ ์ค์ฌ์ด ๋ฉ๋๋ค.
ํ์ต ๋จ๊ณ์ ๋ผ์ฐํ ํ์ง๊ณผ ์๋น ๋จ๊ณ์ ์ฒ๋ฆฌ๋์ ๊ฐ์ ๋ฌธ์ ๊ฐ ์๋๋๋ค. ๋ผ์ฐํ ์ด ์กฐ๊ธ๋ง ์น์ฐ์ณ๋ ํน์ expert shard๊ฐ tail latency๋ฅผ ๊ฒฐ์ ํ๊ณ , capacity factor์ ๋ฐฐ์น ์ ์ฑ ์ด ์ ์ฒด ์์คํ ์ ์์ ์ฑ์ ์ข์ฐํฉ๋๋ค.
๊ทธ๋ฆผ 1. MoE serving pipeline - router, dispatch, expert compute, gather๊ฐ ํ ํ๋ฆ์ผ๋ก ์ด์ด์ง๋ค.
1. ํต์ฌ ๊ฐ๋
| ๊ฐ๋ | ์๋ฏธ | ์๋น ์ํฅ |
|---|---|---|
| Routing / Gating | ํ ํฐ๋ง๋ค top-k expert๋ฅผ ๊ณ ๋ฅด๋ ๋จ๊ณ | ๋ผ์ฐํ ๋ถํฌ๊ฐ ๊ณง ๋ถํ ๋ถํฌ๊ฐ ๋๋ค |
| Expert Parallelism | expert๋ฅผ ์ฌ๋ฌ GPU์ shardํ๋ ๋ฐฐ์น ๋ฐฉ์ | GPU ๊ฐ all-to-all ํต์ ์ด ํ์ํ๋ค |
| Capacity Factor | expert๊ฐ ํ ๋ฒ์ ๋ฐ์ ํ ํฐ ์ํ | overflow๋ฅผ dropํ๊ฑฐ๋ ๋๊ธฐ์ํจ๋ค |
| Hot Expert | ์ ํ ๋น๋๊ฐ ๋์ expert | hotspot, queueing, tail latency๋ฅผ ๋ง๋ ๋ค |
| Hot Expert Replication | ์์ฃผ ์ฐ๋ expert๋ฅผ ๋ณต์ ๋ฐฐ์น | ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฐ๋ ๋์ ๋ณ๋ชฉ์ ์ค์ธ๋ค |
| Dropless Buffering | overflow๋ฅผ ๋ฐ๋ก ๋ฒ๋ฆฌ์ง ์๊ณ ํก์ | ํ์ง์ ์งํค์ง๋ง ์ง์ฐ์ด ๋ ์ ์๋ค |
๊ทธ๋ฆผ 2. expert parallelism์์๋ ํ ํฐ์ด GPU ์ฌ์ด๋ฅผ ์ค๊ฐ๋ฉฐ, ํ์ชฝ์ผ๋ก ์ ๋ฆฌ๋ฉด ์ ์ฒด step์ด ๋๋ ค์ง๋ค.
2. ๋น๊ต/๋ถ์
| ์ ๊ทผ | ํต์ฌ ์์ด๋์ด | ์ฅ์ | ๋จ์ |
|---|---|---|---|
| Switch Transformer | top-1 routing๊ณผ ๋จ์ํ ๊ท ํ ์ ์ด | ํต์ ๋น์ฉ์ด ๋ฎ๋ค | ๋ผ์ฐํ ์ ํ ํญ์ด ์ข๋ค |
| GShard ๊ณ์ด | top-k routing๊ณผ capacity ๊ด๋ฆฌ | ํ์ง๊ณผ ํ์ฅ์ฑ์ด ์ข๋ค | ํต์ ๊ณผ ๊ตฌํ์ด ๋ณต์กํ๋ค |
| DeepSeekMoE | fine-grained expert์ shared expert | ์ ๋ฌธํ๊ฐ ์ ๋๋ค | expert ๊ด๋ฆฌ ๋ถ๋ด์ด ์ปค์ง๋ค |
| DeepSeek-V3 | auxiliary-loss-free load balancing | ํ์ต ์์ ์ฑ์ด ์ข๋ค | ์๋น ๋ฐฐ์น ๋ฌธ์ ๋ ๋ณ๋๋ค |
| Hot expert replication | ์ธ๊ธฐ expert ๋ณต์ | tail latency๋ฅผ ์ค์ธ๋ค | ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋์ด ์ฆ๊ฐํ๋ค |
๊ทธ๋ฆผ 3. ํ์ต, ๋ผ์ฐํ , ๋ฐฐ์น, ์ปค๋ ์ต์ ํ๊ฐ ๊ฐ๊ฐ ๋ค๋ฅธ ๋ ์ด์ด์์ ๋ถํ๋ฅผ ์ค์ธ๋ค.
3. ๋์ ์๋ฆฌ
ํ ํฐ์ router์์ ์ ์๋ฅผ ๊ณ์ฐํ ๋ค top-k expert๋ก ์ ํ๋๊ณ , dispatcher๊ฐ ๊ฐ์ expert๋ก ๊ฐ ํ ํฐ์ ๋ฌถ์ด GPU๋ณ๋ก ๋ณด๋ ๋๋ค. expert ๊ณ์ฐ์ด ๋๋๋ฉด gather๊ฐ ์๋ ์์๋ก ์ถ๋ ฅ์ ํฉ์นฉ๋๋ค.
์ด ํ๋ฆ์์ ๊ฐ์ฅ ๋ฏผ๊ฐํ ์ง์ ์ routing skew์ ๋๋ค. ํน์ expert๋ก ํ ํฐ์ด ๋ชฐ๋ฆฌ๋ฉด ๊ทธ expert๊ฐ ์ํ GPU๋ ๊ณ์ฐ๊ณผ ํต์ ์ ๋์์ ๋ ์๊ณ , ๋๋จธ์ง GPU๋ ์ ํด ์ํ๊ฐ ๋ฉ๋๋ค. capacity factor๊ฐ ์์ผ๋ฉด overflow๊ฐ ๋ฐ์ํ๊ณ , ํฌ๋ฉด queueing์ด ๊ธธ์ด์ง๋๋ค.
๊ทธ๋ฆผ 4. expert๋ณ ํ ํฐ ์๊ฐ ๊ท ์ผํ์ง ์์ผ๋ฉด capacity ์ด๊ณผ์ ๋๊ธฐ์ด์ด ๋์์ ์๊ธด๋ค.
4. ์ฅ๋จ์
| ํญ๋ชฉ | ์ฅ์ | ๋จ์ |
|---|---|---|
| Sparse activation | ํ์ฑ ๊ณ์ฐ๋์ ์ค์ธ๋ค | ํต์ ๋ณ๋ชฉ์ด ์๋ก ์๊ธด๋ค |
| Expert specialization | expert๊ฐ ์ญํ ์ ๋๋ ํ์ตํ๋ค | ํน์ expert ํธ์ค์ด ์๊ธธ ์ ์๋ค |
| Topology-aware placement | ๋คํธ์ํฌ ๋ณ๋ชฉ์ ์ค์ธ๋ค | ๋ฐฐ์น์ ์ด์์ด ๋ณต์กํ๋ค |
| Fused all-to-all | ๊ณ ์ ๋น๋ฅผ ๋ฎ์ถ๋ค | ์ปค๋ ๊ตฌํ ๋๋๊ฐ ๋๋ค |
MoE ์๋น์ ๋ชจ๋ธ๋ง ๋ณด๋ฉด ์ข์ ๋ณด์ด์ง๋ง, ์ค์ ์ด์์์๋ ๋คํธ์ํฌ ํ ํด๋ก์ง์ expert ๋ฐฐ์น๊ฐ ์ฑ๋ฅ์ ์ข์ฐํฉ๋๋ค. ์ข์ ๋ผ์ฐํฐ๋ณด๋ค ๋ ์ค์ํ ๊ฒ์ ๋๋ฆฐ shard๋ฅผ ๋ง๋ค์ง ์๋ ์ด์ ๋ฐฉ์์ ๋๋ค.
๊ทธ๋ฆผ 5. scheduler, router, dispatcher, expert compute, gather๋ฅผ ํ๋์ ๋ฃจํ๋ก ๋ฌถ์ด์ผ ์ง์ฐ์ด ์์ ๋๋ค.
5. ๊ด๋ จ ๊ธฐ์
- MoE Analysis - MoE ๊ตฌ์กฐ, routing, load balancing, DeepSeek ๊ณ์ด ๋ฐฐ๊ฒฝ
- Continuous Batching Analysis - active request๊ฐ ๋ณํ ๋์ ์ค์ผ์ค๋ง
- Disaggregated LLM Serving Analysis - prefill/decode ๋ถ๋ฆฌ์ ๋ฐฐ์น ์ ๋ต
- Switch Transformers: arXiv:2101.03961
- DeepSeekMoE: arXiv:2401.06066
- DeepSeek-V3 Technical Report: arXiv:2412.19437
Switch Transformer๋ routing ์๊ณ ๋ฆฌ์ฆ์ ๋จ์ํํ๊ณ ํต์ ๋น์ฉ๊ณผ ํ์ต ๋ถ์์ ์ ์ค์๊ณ , DeepSeekMoE๋ fine-grained expert์ shared expert๋ก ์ ๋ฌธํ๋ฅผ ๊ฐํํ์ต๋๋ค. DeepSeek-V3๋ 671B total / 37B activated ๊ตฌ์กฐ์ auxiliary-loss-free load balancing์ ํจ๊ป ์ฌ์ฉํด ์์ ์ฑ๊ณผ ํจ์จ์ ๋ง์ท์ต๋๋ค.
6. ํต์ฌ ์ ๋ฆฌ
MoE ์๋น์ ํต์ฌ์ sparse activation ์์ฒด๊ฐ ์๋๋ผ, ํ ํฐ์ด ์ ํ๋ expert๋ก ์ผ๋ง๋ ๊ท ๋ฑํ๊ฒ ํ๋ฌ๊ฐ๋๋์ ๋๋ค. routing skew๋ ๊ณ์ฐ ๋ฌธ์ ์ด๋ฉด์ ๋์์ ํต์ ๋ฌธ์ ์ ๋๋ค.
๋ฐ๋ผ์ MoE ์ด์์ ๋ชจ๋ธ ์ค๊ณ๋ง์ผ๋ก ๋๋์ง ์๊ณ , capacity factor, batch policy, expert placement, hot expert replication, fused all-to-all๊น์ง ํจ๊ป ๋ด์ผ ํฉ๋๋ค.
์๋น ํ์ง์ ๊ฐ์ฅ ๋น ๋ฅธ expert๊ฐ ์๋๋ผ ๊ฐ์ฅ ๋๋ฆฐ shard๊ฐ ๊ฒฐ์ ํฉ๋๋ค. ์ด ๋ฌธ๋งฅ์์ MoE๋ ๋ถ์ฐ ์์คํ ๋ฌธ์ ๋ก ๋ค๋ฃจ๋ ๊ฒ์ด ๋ง์ต๋๋ค.