IBM Research IBM ★ 72 5 min

How distributed inference keeps large AI models moving

AI for CodeExplainerGenerative AIOpen Source

🔗 https://research.ibm.com/blog/distributed-inference?utm_medium=rss&utm_source=rss

📌 LLM 推論也需要塔臺調度:IBM 拆解分散式推論六大關鍵技術

TL;DR:當 LLM 要同時服務上萬使用者與 AI agent,光把模型塞進 GPU 還不夠,你需要一層跨伺服器的流量調度機制。

一個模型伺服器把單次推論做得再快,碰到數千個並發請求、agent 突然爆發式呼叫工具再回來、長短任務混雜在一起的場景,照樣會塞車。IBM Research 用「塔臺調度飛機」比喻這個問題:機場不能把每架飛機都丟給第一條空跑道,得同時考慮位置、目的地、機體大小與油量。LLM 推論系統面對的,其實是同一類排程難題。

🤔 問題出在哪:vLLM、SGLang 管得好單機,管不了叢集

像 vLLM、SGLang 這類服務引擎,負責的是「在單一伺服器上有效率地跑模型」。但當請求量放大到需要一整個叢集的 model server,還需要一層更上層的協調角色:決定每個請求該被送到哪一臺伺服器、什麼時候送、要不要先排隊。這正是「分散式推論」(distributed inference)要解決的問題,IBM Research 以開源、Kubernetes-native 的 llm-d 框架為例,拆解了六項技術:prefix-cache-aware routing、KV-cache offloading、flow control、batch inference optimization、prefill/decode disaggregation,以及 wide expert parallelism。

🧩 核心機制:先問「快取在哪」,再問「誰有餘力」

Prefix-cache-aware routing:語言模型讀 prompt 時會把中間狀態存進 KV cache。如果下一個請求的開頭文字(例如系統提示、同一份程式碼庫、agent 的歷史步驟)跟之前重複,理論上可以直接重用快取,不必重新計算。但傳統負載平衡器只看「哪臺伺服器比較閒」,不管那臺伺服器有沒有相關快取,結果模型得重新讀一次早就算過的內容。llm-d 的 router 改成同時評分「哪臺伺服器已經持有最多這個 prompt 的 prefix」與「哪臺伺服器有餘力處理」,並提供近似索引與基於實際 token 資料的精確兩種實作方式。

KV-cache offloading:快取感知路由要有效,前提是快取還留在記憶體裡。但加速器(GPU)記憶體容量有限,長 prompt、多並發使用者、長時間的 agent session 很快就會把舊快取擠掉,一旦被擠掉,模型就得重新算一次,浪費運算資源。KV-cache offloading 的做法是把不是最急需的快取搬到較大但較慢的層級,例如 CPU 記憶體、本機 SSD 或共享檔案系統,並用一個快取索引追蹤「什麼存在哪」,讓路由層把 offload 出去的資料也納入決策。從 CPU 記憶體讀比從 GPU 記憶體讀慢,但遠比整段重新計算便宜。

素材中提到的 flow control、batch inference optimization、prefill/decode disaggregation、wide expert parallelism 四項,文章列出了名稱與角色定位(分別對應「決定什麼時候該動」「填滿閒置產能但不塞車」「把兩種不同性質的工作拆開處理」「把巨型模型攤開到整個叢集」),但這份摘要未進一步展開細節,此處不做延伸猜測。

📊 實測數據:97% 的可重用快取被抓到了

在 llm-d 團隊的一次示範中,prefix-aware routing 在測試工作負載中捕捉到 97% 的可重用快取機會;另一項示範裡,128 個並發請求下,GPU 記憶體就能供應約 90% 到 92% 的可重用 prefill prefix,CPU offloading 則負責撐住超出 GPU 容量的部分,並在一個長時間、agent 驅動的 benchmark 中維持高吞吐量與低首個 token 延遲。

💡 llm-d 的身世:從五家共同發起者到 CNCF Sandbox

llm-d 於 2025 年 5 月由 IBM Research、Red Hat、Google Cloud、NVIDIA、CoreWeave 共同發起,創始夥伴還包括 AMD、Cisco、Hugging Face、Intel、Lambda、Mistral AI,以及加州大學柏克萊分校與芝加哥大學的學術支持者。IBM Research、Red Hat、Google Cloud 目前仍持續主導其開發。2026 年 3 月,創始成員將 llm-d 捐贈給雲端原生計算基金會(CNCF)作為 sandbox 專案,目標是讓任何模型都能在任何加速器、任何雲端上部署推論堆疊。

🎯 實務啟示

如果你的團隊正在自建 LLM 推論服務,單機引擎選型(vLLM/SGLang)只解決了一半問題;當流量規模跨出單機,prefix-cache-aware routing 與 KV-cache offloading 這類「叢集層」的調度能力,才是決定吞吐量與延遲的關鍵,尤其是 agent 類工作負載因為反覆重用長上下文,從這類最佳化中受益特別明顯。

🔗 來源

#LLMInference #DistributedSystems #KVCache #vLLM #SGLang #Kubernetes #MLOps #AIInfrastructure #IBMResearch #llm-d

原始資料 IBM Research · 收集於 2026-10-12
來源原標題
How distributed inference keeps large AI models moving
機構
IBM
原始標籤
AI · AI for Code · Explainer · Generative AI · Open Source
原始連結
https://research.ibm.com/blog/distributed-inference?utm_medium=rss&utm_source=rss

摘要原文

When an AI model answers a question or completes a task, it performs inference, i.e., using a trained model to generate an output in response to some input. Doing that at scale, however, is more challenging than it sounds. Running a large language model on a GPU is one thing. Serving that model to thousands or even millions of people and AI agents at the same time is quite another. Requests arrive with different priorities and lengths, which have unique computing needs. Some users expect an immediate response to simple queries, while others submit large jobs that can run in the background. AI agent traffic adds a new pattern: Agents may send bursts of related requests, pause to call a tool, and then return with nearly the same context. Meanwhile, the system must make efficient use of expensive accelerators without creating long queues or repeatedly performing the same computations. This challenge resembles air traffic control. A busy airport cannot simply send each arriving aircraft to the first available runway. Controllers in the tower must account for the aircraft’s location, destination, size, and fuel needs, as well as the traffic already moving through the system. The challenge might be simple if all air traffic controllers had to do was keep every runway busy, but an airport isn’t a parking lot, and not every airplane can be treated the same way. Distributed inference plays a similar coordinating role for LLM inference, working a layer above model servers like vLLM and SGLang , where it orchestrates and optimizes real-world traffic. While those serving engines run models efficiently on individual servers, a distributed inference serving framework coordinates groups of model servers across a cluster. Its router can consider queue depth, cache availability, and server roles before deciding where a request should go. To understand how distributed inference works, we’ll look at six notable technical innovations—prefix-cache-aware routing, KV-cache offloading, flow control, batch inference optimization, prefill/decode disaggregation, and wide expert parallelism. We’ll also see how each comes together in llm-d, an open-source, Kubernetes-native inference framework. Prefix-cache-aware routing: Sending work where context already lives KV-cache offloading: Extending a model’s working memory Flow control: Deciding what moves and when Batch inference optimization: Filling spare capacity without clogging the system Prefill/decode disaggregation: Separating two different types of work Wide expert parallelism: Spreading a giant model across the cluster Coordinating the whole inference system Prefix-cache-aware routing: Sending work where context already lives When a language model reads a prompt, it produces an internal representation of the words and their relationships, storing much of this intermediate state in a key-value cache, or KV cache. If a later request begins with the same text, or even portions of the same text, the model may be able to reuse that stored computation rather than re-process the shared text. For example, if an existing prompt is “What is the capital of Kansas?” then later on you ask, “What is the capital of California?” the KV cache for the "what is the capital of" portion is reused. This opportunity arises frequently in real workloads. A chatbot receives the same system instructions at the beginning of every conversation. A coding assistant repeatedly examines the same repository. An AI agent may revisit a long record of previous steps while testing different solutions. In each case, much of the prompt remains unchanged from turn to turn. A conventional load balancer may send the next request to whichever server appears least busy, whether or not its cache contains the relevant context. As a result, the model must reread material that another server has already processed. Prefix-cache-aware routing instead asks two questions: Which server already holds the greatest portion of this prompt’s prefix, and which server has enough capacity to handle the request? The llm-d router uses cache information and operating conditions to score the available model servers and select a suitable destination. There is both an approximate implementation that includes a lightweight index of recent routing decisions, and a precise implementation based on actual token data and cache-state updates from model servers. If an aircraft already has its passengers, baggage, and ground crew waiting at one gate, sending the plane to another gate would introduce needless work. In the same way, a distributed inference system tries to send a request to the model server that already contains the required context. The payoff is less redundant prefill computation, lower latency, and greater throughput. In a recent demonstration from the team behind llm-d, prefix-aware routing captured 97% of the available reuse in the tested workload. More broadly, the technique is especially useful for agentic systems because their requests often share long instructions, source material, conversation histories, and tool outputs. llm-d was launched in May 2025 as a collaborative effort by founding members IBM Research, Red Hat, Google Cloud, NVIDIA, and CoreWeave. Several founding partners also took part from the start, including industry leaders like AMD, Cisco, Hugging Face, Intel, Lambda, and Mistral AI, and academic supporters at the University of California, Berkeley, and the University of Chicago. IBM Research, Red Hat, and Google Cloud continue to lead llm-d's development today, and its community of partners and contributors has grown considerably. In March 2026, the founders donated llm-d to the Cloud Native Computing Foundation as a sandbox project, to further the mission of deploying inference stacks for any model, on any accelerator, in any cloud. KV-cache offloading: Extending a model’s working memory Cache-aware routing is most valuable when cached information remains available. The problem is that although accelerator memory is fast, its space can be quickly filled by long prompts, many concurrent users, and extended agent sessions. When space runs short, a model server may evict older KV-cache entries. If a later request needs that material, the model must calculate it again, wasting accelerator cycles rebuilding context that existed moments earlier. Distributed inference addresses this problem through KV-cache offloading . Rather than treating accelerator memory as the only place where cached context can live, it chooses an offloading target based on workload requirements. The most immediately useful entries can remain in high-bandwidth accelerator memory, while other entries can move to larger but slower tiers such as CPU memory, local solid-state storage, or a shared file system. A cache index tracks what is stored and where, allowing the routing layer to incorporate offloaded data into its decisions. Retrieving cached information from CPU memory or storage is slower than reading it directly from accelerator memory, but it is much faster and less expensive than recomputing the entire prompt. Offloading therefore expands the system’s effective cache capacity beyond the physical memory available on its accelerators. This matters most for workloads with long, reusable contexts and many simultaneous sessions. In the same llm-d demonstration mentioned in the previous section, GPU memory supplied about 90% to 92% of reusable prefill prefixes for 128 concurrent requests, with CPU offloading helping to preserve prefixes beyond GPU capacity. In another demonstration , CPU offloading helped the system sustain high throughput and low time to first token across a long, agent-driven benchmark. Because offloading runs during prefill and writes to slower tiers happen asynchronously, these gains come without slowing token generation. Flow control: Deciding what moves and when Routing answers where a request should go.

由 claude-code/sonnet 自動生成