UBEP: Re-architecting Expert Parallelism Communication Library for Production SuperpodsUBEP:為生產環境 superpod 重新架構專家平行通訊函式庫
After reading, you can explain why MoE dispatch inside a superpod is limited by barriers and hop distance rather than bandwidth, and how UBEP splits cores, balances hops and fuses flags into data.讀完後,你能說明為何 superpod 內的 MoE dispatch 受限於 barrier 與跳數距離而非頻寬,以及 UBEP 如何拆分核心、平衡跳數,並把旗標融入資料。
UBEP is a communication library for expert parallelism (EP) in mixture-of-experts (MoE) inference on Huawei's CloudMatrix384 (CM384), a superpod of 384 NPUs on one load/store fabric, the Unified Bus (UB). At 392 GB/s per link, bytes are cheap, and the software around them sets the time. Libraries built for InfiniBand clusters run dispatch as phases split by global barriers. One barrier takes about 15% of the time, and half of the vector cores already fill the link while the rest wait. Equal token counts also do not give equal times, because a two-hop access costs 11.5× a local one. UBEP runs a sending group and a counting group of cores at once, gives each core the same mix of near and far tokens, and carries the arrival signal inside each 512-byte write. On a production CM384, dispatch latency fell by up to 52.4% (at 64 NPUs) against Huawei's CANN EP, and P99 time per output token by up to 11.1%.
UBEP 是一個通訊函式庫,用於華為 CloudMatrix384(CM384)上混合專家(MoE)推論的專家平行(EP);CM384 是一個 superpod,384 顆 NPU 共用一個 load/store 網路,即 Unified Bus(UB)。每條鏈路有 392 GB/s,位元組很便宜,決定時間的是位元組周圍的軟體。為 InfiniBand 叢集打造的函式庫把 dispatch 分成以全域 barrier 隔開的階段。一次 barrier 約占 15% 的時間,而一半的向量核心就已填滿鏈路,其餘只能等待。相同的 token 數也不代表相同的時間,因為兩跳存取的代價是本地的 11.5 倍。UBEP 讓一組傳送核心與一組計數核心同時執行,給每個核心相同的遠近 token 組合,並把「資料已到」的訊號放進每一次 512 位元組的寫入。在生產環境的 CM384 上,dispatch 延遲比華為的 CANN EP 最多降低 52.4%(64 顆 NPU 時),P99 每個輸出 token 的時間最多降低 11.1%。
1. Where this paper sits1. 這篇論文的位置
Section 3.7 sizes the EP all-to-all at per MoE layer, with destinations set token by token. Those tokens go to GPUs of any rank, so EP breaks the rail assumption, and a rail-only network pays 8.2–11.2% for the NVLink detour. A superpod answers the other way. It makes the scale-up domain large enough to hold the whole EP group: 72 GPUs in NVL72, 384 NPUs in CM384. No NIC or RDMA queue pair takes part; ranks write into each other's memory with load and store instructions.
第 3.7 節把 EP all-to-all 估為每個 MoE 層 ,目的地逐 token 決定。這些 token 會送到任何 rank 的 GPU,所以 EP 打破了 rail 假設,rail-only 網路要為 NVLink 繞路付出 8.2–11.2%。superpod 從另一個方向回答。它把 scale-up domain 做得夠大,能容納整個 EP 群組:NVL72 有 72 顆 GPU,CM384 有 384 顆 NPU。這裡沒有 NIC 或 RDMA queue pair 參與;各 rank 用 load 與 store 指令直接寫進彼此的記憶體。
What remains is the fixed cost per phase, the term of the – model in the Chapter 4. UBEP's baseline is CANN EP, Huawei's Ascend adaptation of DeepEP for CM384. The scope is narrow: the paper measures decode-time inference, and only the dispatch half of the all-to-all. It calls combine analogous and does not evaluate it.
剩下的是每個階段的固定成本,也就是第 4 章 – 模型中的 項。UBEP 的基準是 CANN EP,即華為為 CM384 改寫的 Ascend 版 DeepEP。範圍很窄:論文量測的是解碼階段的推論,而且只有 all-to-all 的 dispatch 這一半。它說 combine 可比照處理,但沒有評估。
2. The problem, measured2. 問題,用量測說話
CM384 has a two-tier fabric. NPUs on one board meet at first-tier switches, and boards meet at second-tier switches. Each NPU has two compute dies and several AI Cores, each with a matrix unit and several vector cores (AIVs), which move the data. Table 2 of the paper gives the access latency by distance (Diagram A); the paper does not say how it was measured.
CM384 是兩層的網路。同一塊板上的 NPU 經第一層交換器相連,板與板之間經第二層交換器相連。每顆 NPU 有兩個計算 die 與多個 AI Core,每個 AI Core 含一個矩陣單元與數個負責搬資料的向量核心(AIV)。論文 Table 2 給出依距離區分的存取延遲(示意圖 A);論文沒有說明是怎麼量的。
The baseline dispatch runs five phases. (1) Every rank pre-allocates a receive region, split by source and expert. (2) Each AIV writes its tokens straight into the destination experts' slots. (3) A global barrier, SyncAll; then AIVs write per-expert flags and token counts. (4) AIVs poll the flags, then SyncAll again. (5) A prefix sum over the counts, CalCumSum, gives each token's offset, and the tokens are reordered.
基準的 dispatch 有五個階段。(1) 每個 rank 預先配置接收區,依來源與專家切分。(2) 每個 AIV 把自己的 token 直接寫進目的專家的位置。(3) 全域 barrier SyncAll;之後 AIV 寫入每個專家的旗標與 token 數。(4) AIV 輪詢旗標,再做一次 SyncAll。(5) 對 token 數做前綴和(CalCumSum),得到每個 token 的位移,再重排 token。
The paper draws three insights from CM384. Barriers waste cores. UB gives 392 GB/s against 50 GB/s for IB/RoCE, so half the AIVs fill the link: going from 24 to 48 communication cores gave "minimal benefit", because the extra cores wait at barriers. Synchronization dominates. One SyncAll costs about 15% of the execution time. Balance must see distance. With two hops at 11.5× local, equal token counts leave stragglers. The paper does not state the batch or message size behind the first two measurements.
論文從 CM384 得出三個洞見。barrier 浪費核心。UB 提供 392 GB/s,IB/RoCE 只有 50 GB/s,所以一半的 AIV 就填滿鏈路:通訊核心從 24 個增加到 48 個只有「極小的好處」,因為多出的核心都在 barrier 等待。同步占主導。一次 SyncAll 約占執行時間的 15%。平衡必須看距離。兩跳是本地的 11.5 倍,相同的 token 數仍會留下 straggler。論文沒有說明前兩項量測所用的批次或訊息大小。
3. The design3. 設計
Three mechanisms work together. Decomposition creates concurrent tasks, scheduling balances them, and Data-as-Flag synchronizes them without barriers. The paper's Figure 4 (below) puts the three together.
三個機制一起運作。分解產生並行的工作,排程讓它們平衡,Data-as-Flag 則不用 barrier 就讓它們同步。論文的 Figure 4(下圖)把三者畫在一起。

3.1 Kernel decomposition: split the cores by job3.1 核心分解:依工作拆分核心
UBEP splits the AIVs into two groups (Diagram B). The token group sends tokens. The count group writes the per-expert token counts and then computes CalCumSum. The groups run at the same time, so the counting hides behind the transmission. A point-to-point signal replaces SyncAll: the count group writes the offsets into shared global memory, and the other AIVs start reordering as soon as they see the update.
UBEP 把 AIV 拆成兩組(示意圖 B)。token 組負責傳送 token。計數組寫入每個專家的 token 數,再計算 CalCumSum。兩組同時執行,所以計數藏在傳輸後面。點對點訊號取代了 SyncAll:計數組把位移寫進共享的全域記憶體,其他 AIV 一看到更新就開始重排。
Appendix A sizes the groups. With AIVs, experts, top- routing and batch , the count group's time grows with and the token group's with . With linear costs and , equal times give
附錄 A 決定兩組的大小。設 個 AIV、 個專家、top- 路由、批次 ,計數組的時間隨 成長,token 組的時間隨 成長。在線性成本且 的近似下,令兩者相等得到
Here and are the costs per token sent and per expert counted; the paper never measures their ratio. More experts need more counting cores, and larger batches move cores to sending. Appendix C.3 confirms this trend.
其中 與 是每傳一個 token 與每計數一個專家的成本;論文從未量測兩者的比值。專家越多,需要越多計數核心;批次越大,核心就移往傳送。附錄 C.3 證實了這個趨勢。
3.2 Hierarchical token scheduling: equal hop mix3.2 階層式 token 排程:相同的跳數組合
One die sends tokens with AIVs. AIV gets the set ; token costs to send and to confirm. The paper's Program 1 minimizes the slowest AIV, with at most tokens per AIV:
一個 die 用 個 AIV 送出 個 token。AIV 分到集合 ;token 的傳送成本是 ,確認成本是 。論文的 Program 1 在每個 AIV 最多 個 token 的條件下,讓最慢的 AIV 最快:
The problem is NP-hard (a reduction from Subset Sum), and a solver is too slow for a microsecond budget. UBEP uses a rule instead: give every AIV the same hop mix. If tokens go hops, each AIV gets at most of them. A mapper reads a virtual AIV-by-expert matrix column by column and cuts the token sequence into equal slices. A four-way search, which tests three pivots in one SIMD instruction, finds each slice's first expert; the paper states 4–5 steps and under 1 µs.
這個問題是 NP-hard(由 Subset Sum 歸約),求解器對微秒級的預算來說太慢。UBEP 改用一條規則:給每個 AIV 相同的跳數組合。若有 個 token 要走 跳,每個 AIV 最多分到 個。對應器逐欄讀取一個虛擬的「AIV × 專家」矩陣,並把 token 序列切成等長的片段。一個四分搜尋在一條 SIMD 指令中測試三個樞紐點,找出每個片段的第一個專家;論文說只需 4–5 步、不到 1 µs。
3.3 Data-as-Flag: the write is the signal3.3 Data-as-Flag:寫入本身就是訊號
A receiver must know when data has arrived. A separate flag needs a fence between payload and flag. UB guarantees that a 512-byte write is atomic, so no receiver sees half a block, and the data can carry its own signal (Diagram C). Token-Flag Fusion puts a 32 B flag and 480 B of payload in each block, at 93.75% efficiency. Data-for-Checksum sends a checksum after the batch, which blocks token-level pipelining. Sentinel Polling pre-fills the buffer with a reserved value and watches a 32 B field. It reaches 100% efficiency, but buffers must be reset, and data equal to the sentinel would deadlock; the paper bounds that chance by under a uniform-value assumption. Without 512 B atomics, the fallback is the checksum variant or explicit fences.
接收端必須知道資料何時到達。獨立的旗標需要在資料與旗標之間加一道 fence。UB 保證 512 位元組的寫入是原子的,所以接收端永遠看不到寫了一半的區塊,資料就能攜帶自己的訊號(示意圖 C)。Token-Flag Fusion 在每個區塊放 32 B 旗標與 480 B 資料,效率 93.75%。Data-for-Checksum 在整批之後送一個 checksum,這會擋住 token 層級的管線化。Sentinel Polling 預先在緩衝區填入保留值,並監看一個 32 B 欄位。它的效率是 100%,但緩衝區必須重置,而資料若恰好等於 sentinel 就會死結;論文在均勻分布的假設下把這個機率界定為 。沒有 512 B 原子寫入時,退路是 checksum 變體或明確的 fence。
4. Implementation4. 實作
UBEP is about 10K lines of Ascend C on Huawei's CANN stack. It uses UB load/store primitives and the SIMD operations VectorCount, CompareScalar and FindFirstValue. The receive space is partitioned at initialization, so senders write tokens directly into the destination's memory. End-to-end tests use vLLM-Ascend v0.14.0.
UBEP 約有 10K 行 Ascend C,建在華為的 CANN 堆疊上。它使用 UB 的 load/store 原語,以及 VectorCount、CompareScalar 與 FindFirstValue 等 SIMD 操作。接收空間在初始化時就切分好,所以傳送端直接把 token 寫進目的地的記憶體。端到端測試使用 vLLM-Ascend v0.14.0。
5. What was measured5. 量到了什麼
All tests ran on 16 Ascend servers allocated from a production CM384, 256 NPU dies in all. The models are Qwen3-30B, GLM-4.7, DeepSeek-R1 and DeepSeek-V3.2, all with top-8 routing. The baselines are CANN EP and "UBEP w/o mapping", which keeps everything except the distance-aware mapping. Table 4 compares dispatch on identical hardware (Diagram D).
所有測試都在從生產環境 CM384 撥出的 16 台 Ascend 伺服器上執行,共 256 個 NPU die。模型是 Qwen3-30B、GLM-4.7、DeepSeek-R1 與 DeepSeek-V3.2,都用 top-8 路由。基準是 CANN EP 與「UBEP 無對應」;後者保留除了距離感知對應以外的一切。Table 4 在相同硬體上比較 dispatch(示意圖 D)。
Derived from Table 4:
由 Table 4 推導:
| Question問題 | Calculation算式 | Result結果 |
|---|---|---|
| Latency reduction at EP16EP16 的延遲降幅 | ||
| Latency reduction at EP256EP256 的延遲降幅 | ||
| UBEP's bandwidth as a share of the 392 GB/s linkUBEP 頻寬占 392 GB/s 鏈路的比例 | … | |
| Data per dispatch, latency × bandwidth (same in every row)每次 dispatch 的資料量,延遲 × 頻寬(每列都相同) | MB |
So dispatch runs far below the link rate: latency and synchronization, not bytes, set the time. The paper reports a bandwidth gain of 35.3–40.8% over CANN EP. Table 4 also has a DeepEP row, labeled "a protocol-capability reference on H800". Its values equal the dispatch table in DeepEP's own README (H800 with 400 Gb/s InfiniBand, 128 tokens, hidden 7,168, top-8, FP8), and the paper does not say that it measured them. We therefore do not compare UBEP with DeepEP.
所以 dispatch 遠低於鏈路速率:決定時間的是延遲與同步,而不是位元組。論文報告頻寬比 CANN EP 提高 35.3–40.8%。Table 4 還有一列 DeepEP,標示為「H800 上的協定能力參考」。這些數值與 DeepEP 自己 README 中的 dispatch 表相同(H800 搭配 400 Gb/s InfiniBand、128 個 token、hidden 7,168、top-8、FP8),論文也沒有說是自己量的。因此我們不拿 UBEP 與 DeepEP 比較。
| Test測試 | Setup設定 | Measured (dispatch)實測結果(dispatch) |
|---|---|---|
| Phase breakdown (Fig. 8)階段分解(Fig. 8) | 64 NPUs, 1 expert each, three batch sizes64 顆 NPU、各 1 個專家、三種批次 | 34.7–52.4% lower latency than CANN EP延遲比 CANN EP 低 34.7–52.4% |
| Batch sweep (Fig. 7a)批次掃描(Fig. 7a) | 128 ranks128 個 rank | 46.4% on average for batch 8–64; 35.9% at batch 128批次 8–64 平均 46.4%;批次 128 時 35.9% |
| Rank sweep (Fig. 7b)rank 掃描(Fig. 7b) | batch 64批次 64 | 43.9% on average; 35.1% at 256 ranks平均 43.9%;256 個 rank 時 35.1% |
| Expert sweep (Fig. 7c)專家掃描(Fig. 7c) | expert counts not stated專家數未說明 | Synchronization about 70% of runtime in CANN EP, about 30% in UBEP; 38.6–41.9% faster同步約占 CANN EP 執行時間的 70%、UBEP 的 30%;快 38.6–41.9% |
| Scheduling (Fig. 9)排程(Fig. 9) | 64 NPUs, 256 experts, top-8, 8 hot experts64 顆 NPU、256 個專家、top-8、8 個熱門專家 | Slowest AIV: CANN EP 62.2 µs, w/o mapping 48.1 µs, UBEP 43.5 µs最慢的 AIV:CANN EP 62.2 µs、無對應 48.1 µs、UBEP 43.5 µs |
| Data-as-Flag (Fig. 10)Data-as-Flag(Fig. 10) | vs stop-and-wait flags對照 stop-and-wait 旗標 | 31.0–57.1% lower latency; about 1 µs saved at about 10 KB granularity延遲低 31.0–57.1%;在約 10 KB 粒度下約省 1 µs |
Figure 8 of the paper (below) breaks the dispatch into its phases, the measured counterpart of the panel above.
論文 Figure 8(下圖)把 dispatch 拆成各個階段,是上面面板的實測對照。

End to end, with vLLM-Ascend, P99 time per output token (TPOT) fell by up to 11.1%. Profiling explains the gap: MoE communication is about 50% of per-token latency but only about 20% of the hardware execution time. Dependency stalls and runtime overhead fill the rest. The paper gives no absolute TPOT, input lengths or concurrency.
端到端使用 vLLM-Ascend 時,P99 每個輸出 token 的時間(TPOT)最多降低 11.1%。剖析解釋了這個落差:MoE 通訊約占每個 token 延遲的 50%,卻只占硬體實際執行時間的約 20%。其餘是依賴停頓與執行期開銷。論文沒有給出 TPOT 的絕對值、輸入長度或並行度。
6. Limits and open questions6. 限制與未解的問題
The paper's own: gains shrink at batch 128 and at 256 ranks, where 12 cores are reserved for routing and checksums; raw transmission is slightly slower, because cores move to counting; Sentinel Polling's deadlock risk is never zero. Its portability checklist (Table 5) needs per-core concurrency, hop-dependent latency and 512 B atomic writes. A careful reader adds:
論文自己的:在批次 128 與 256 個 rank 時增益縮小,此時有 12 個核心保留給路由與 checksum;原始傳輸稍微變慢,因為有核心移去計數;Sentinel Polling 的死結風險永遠不是零。它的可移植性清單(Table 5)需要核心層級的並行、隨跳數變化的延遲,以及 512 B 原子寫入。細心的讀者還應該補上:
- Inference, dispatch only. No training, no backward pass, no combine. Training's larger batches move toward the regime where the gains already shrink.只有推論、只有 dispatch。沒有訓練、沒有反向、沒有 combine。訓練的批次較大,會走向增益已經縮小的區間。
- One platform, one baseline. There is no same-hardware comparison with Hybrid-EP, the closest design.一個平台、一個基準。沒有與最接近的設計 Hybrid-EP 在相同硬體上比較。
- Unstated setups. The 15% SyncAll share, the 24-to-48-core test and Table 4 have no stated batch or message size.未說明的設定。15% 的 SyncAll 占比、24 到 48 個核心的測試與 Table 4 都沒有說明批次或訊息大小。
- Mixed headline. The 52.4% comes from Figure 8 (64 NPUs), while Table 4 shows 25.8–29.1%.混合的標題數字。52.4% 來自 Figure 8(64 顆 NPU),而 Table 4 顯示的是 25.8–29.1%。
7. How it connects7. 與其他內容的關聯
- Deep dive, section 5: the EP byte formula still holds, but inside a superpod the bytes are cheap, and barriers and hop distance set the time.第 3.7 節:EP 的位元組公式依然成立,但在 superpod 內位元組很便宜,決定時間的是 barrier 與跳數距離。
- Chapter 4, section 2: going from 50 to 392 GB/s shrinks only the term; a phase made of barriers keeps its .第 4.3 節:從 50 到 392 GB/s 只縮小 項;由 barrier 組成的階段仍保有它的 。
- The EPIC digest attacks the same dispatch on scale-out H20/H800 clusters, by removing duplicate inter-host bytes and expert imbalance.EPIC 導讀在 scale-out 的 H20/H800 叢集上處理同樣的 dispatch,做法是去除重複的跨主機位元組與專家不平衡。
- The PipeMorph digest shows the same rule for pipelines: the slowest element sets the pace.PipeMorph 導讀在管線上呈現同一條規則:最慢的元素決定步調。
- Rail-only measured the cross-rail detour of EP; inside a superpod, EP traffic never reaches the rails. TPU v4 is another very large scale-up domain.Rail-only 量過 EP 跨 rail 的繞路成本;在 superpod 內,EP 流量根本不會碰到 rail。TPU v4 是另一個非常大的 scale-up domain。
Key numbers關鍵數字
| Number | 數字 | Meaning (measured on CM384 unless noted) | 意義(除非註明,皆在 CM384 上量測) |
|---|---|---|---|
| 218 / 929 / 2,500 ns | Access latency: same NPU / one hop / two hops | 存取延遲:同一 NPU / 一跳 / 兩跳 | |
| ≈ 15% | Share of execution time in one SyncAll (setup not stated) | 一次 SyncAll 占執行時間的比例(設定未說明) | |
| 52.4% | Largest dispatch-latency cut against CANN EP; 64 NPUs | 相對 CANN EP 的最大 dispatch 延遲降幅;64 顆 NPU | |
| 151 → 112 µs | CANN EP → UBEP dispatch at 256 ranks (Table 4) | 256 個 rank 時 CANN EP → UBEP 的 dispatch(Table 4) | |
| 62.2 / 48.1 / 43.5 µs | Slowest AIV: CANN EP / w/o mapping / UBEP | 最慢的 AIV:CANN EP / 無對應 / UBEP | |
| 11.1% | Largest P99 TPOT cut, end to end in vLLM-Ascend | vLLM-Ascend 端到端的最大 P99 TPOT 降幅 |
Terms used on this page本頁用到的術語
- Superpod
- Tens to hundreds of accelerators on one scale-up fabric with a shared load/store address space.
- 數十到數百顆加速器共用一個 scale-up 網路與 load/store 位址空間。
- AIV
- A vector core of an Ascend AI Core; UBEP schedules work per AIV.
- Ascend AI Core 中的向量核心;UBEP 以 AIV 為單位排程。
- Dispatch
- Sending each token to the ranks of its top- experts.
- 把每個 token 送到其 top- 專家所在的 rank。
- SyncAll
- A global barrier across all cores in the Ascend programming model.
- Ascend 程式模型中跨所有核心的全域 barrier。
- CalCumSum
- The prefix sum over per-expert token counts that gives each token's offset.
- 對每個專家的 token 數做前綴和,得到每個 token 的位移。
- Data-as-Flag
- Synchronization carried by the data write itself, relying on 512 B atomicity.
- 依賴 512 B 原子性、由資料寫入本身攜帶的同步。