Section Insights
Introduction to Distributed Inference Systems
What is the significance of distributed inference systems in AI?
Distributed inference systems are becoming essential as inference workloads grow rapidly, surpassing traditional microservices in scale and complexity. The evolution of AI mirrors the cloud era, moving from simple models to complex orchestration layers.
- Inference is a foundational workload in AI, growing faster than any other.
- The evolution of AI infrastructure is similar to the cloud's evolution but compressed into a shorter timeframe.
- Focus is shifting from just model performance to the entire ecosystem, including orchestration and control planes.
Challenges in Model Inference Scaling
What are the key challenges in scaling model inference?
Scaling model inference is challenging due to the high costs of GPU resources and the complexity of maintaining state during requests. Unlike traditional microservices, model inference requires careful orchestration to avoid bottlenecks and ensure reliability.
- Model inference requires expensive GPU resources, making scaling more complex than traditional microservices.
- State management during inference is critical; failures can lead to significant delays and resource wastage.
- The orchestration layer is crucial for managing the complexities of inference requests.
Reliability and Control in Inference Systems
How does reliability impact inference systems?
Reliability in inference systems must be built into the control plane rather than at the edge. This is essential to manage cascading failures and ensure that the system can handle preemptions and other disruptions without degrading user experience.
- Reliability must be a property of the control plane to manage the entire workflow effectively.
- Cascading failures can occur if not managed properly, leading to increased latency and resource saturation.
- Designing effective circuit breakers and admission controls is vital for maintaining system reliability.
Cost Economics in Inference Systems
What factors should be considered for cost optimization in inference systems?
Cost optimization in inference systems involves understanding various metrics beyond just GPU costs, including retries, storage, and operational expenses. The focus should be on optimizing the cost per successful task rather than per request.
- Cost optimization should focus on successful task completion rather than individual request costs.
- Understanding the full scope of costs, including retries and failures, is crucial for effective management.
- Reliability and performance are interconnected; optimizing one can impact the other.
Metrics and Optimization in Inference Systems
What metrics are important for optimizing inference systems?
Key metrics for optimizing inference systems include time to first token, utilization ratios, and end-to-end latency. Balancing latency, cost, and throughput is essential, as improvements in one area can negatively impact others.
- Important metrics include time to first token, utilization ratio, and end-to-end latency.
- There is a trade-off between latency, cost, and throughput that must be managed carefully.
- The industry is moving towards a unified inference control plane to streamline management and optimization.
Transcript
0:12 Good morning everyone. Welcome to the first infants talk on the last day of AI engineer world fair. My name is Nishan Gupta and I'm joined today by my co-speaker Naman Auja. We work on building the efficiency training and inference infrastructure at Meta. Today we're going to be talking about how do you operate distributed infence systems at scale. As we all know, inference is no longer just a research artifact boiled to a product. It's a foundational hypers scale infrastructure workload which is growing at a tremendous rate.
0:43 The infence traffic already outpaces the largest microservices in the world and the rate of growth is fastest of any workload we have ever seen. Let's rewind back to around 2008 and try to compare the AI era with the cloud era. In around 2008, the cloud started as virtual machine offerings. The interesting injuring was virtualization. Then over time, the value moved up to the stack to the scheduulers. Think bog, kubernetes, msos, then to service meshes, then to autoscalers, and then to various platforms that were built on top of it. The orchestation layer is what actually captured the value and the complexity. AI is on the exact same trajectory but just compressed into a last few years instead of a decade. We started with simple models running on GPUs. Then we saw the evolution of model serving frameworks like VLM to serve Triton and now we are watching the orchestration layer emerging in real time addressing the complex challenges of routing KV cache management prefield decode disagregation and multimodel multiplexing.
1:51 In this next phase of AI era, it's not just about the best models or the kernels or the optimizations. It's about the whole ecosystem. It's about the control plane and the orchestration. And this is what we're going to be focusing in this today's talk. So let's talk a little bit about agentic demand explosion. In the classical web serving before the AI inference workloads kicked off the capacity scaled roughly linearly with users depending upon the workload type double the users mostly double the QPS double the infrastructure fleet if there are no optimizations and capacity planning was mostly a spreadsheet exercise. In this new agentic serving capacity is scaling with number of users time number of calls per users times number of tokens which varies depending on the model the optimizations the hardware SKU you have a chatbot can have one model call per turn which is evolving now with 10 to 20 for co-pilots and 50 for research agents and now it's thousands of such calls for autonomous workflows with no human in the loop. The key to take away that you cannot plan capacity for the agents the same way we did for microservices. We need to think about elasticity and implement workload aware scheduling and admission control.
3:09 Now let's try to dive a little bit deep into the differences pros and cons differences between the traditional microser in serving versus the modern infence serving across these key dimensions. The request shape microservices assumes short uniform request wherever the LLM requests we are seeing in our workloads they can vary from 50 tokens to 100,000 tokens with vastly different compute profiles between prefill and decode stage for batching classical stacks for microservices was doing stacking batching mostly at the load balance layer if at all however LLM serving requires continuous inflight batching how otherwise the throughput collapses by an order of magnitude or state most of the classical microservices were stateless when we not talking about storage layer however LLM serving does require a huge per request state the KV cache which require which is very expensive to build and even more expensive to throw away scaling units when we think about traditional microservices we could run them in cheap CPUs in pods however for model inferencing we require to run on GPUs which are 100 times more expensive which are 10 times slower to acquire and we cannot overprovision them casually otherwise it will lead to a huge wastage.
4:23 failure mode. When you think about traditional microservices like most of us have built over the last couple of years, we could even if a micro even if a host crashed or a bot crash, we could restart it. We could rebuild the state if needed be. However, for the model inferencing, it takes a huge amount of time to go from cold to hot startup and these if and if a GPU is mid decode, it can drop thousands of in-flight tokens and it can lead to a queue buildup. The takeaway is that the bottleneck is not just the model, it's the orchestration itself.
4:58 Now, as we can see in these hidden decisions behind a prompt, when we go to any gentic application, it requires a bunch of steps which are behind the scenes. We have to authenticate. We have to choose a model depending on the request type. We have to select a region where it goes, we have to do admission control. We have to do caching lookup. We have to do the we have to run it on the GPU. We have to do batching. And there's a bunch of other steps involved.
5:19 And as we can see out of all these steps only one step requires the model which is the pre-filled decode. If it's disagreed inference or just if it's not disagreed inference other steps require infrastructure. The intelligence might lie in the model but the economics the reliability and the user experience are all in the infrastructure. And this is why a lot of platform teams across a lot of companies are having much more impact on the product quality and the success ra much more than before.
5:50 Now most of us in this room have a deep expertise across one or two or three layers. We might own kernels or kernel optimizations. We might own routing or the product itself or we might be operating the GPU infrastructure or the cluster itself. But very few of us have operated the whole stack or seen thought about it end to end. As you can see in these layers, these layers are not new. They have been around for 20 years or more. What is new is the combination and the coupling between them. A decision at the routing layer can change the cache hit rate at the model layer which can change the batch composition which can change the GP utilization which can change the autoscaling decision because of the change in GPUs simplization. So everything is entangled when we have any regressions in our inference workloads.
6:37 It's not just about understanding what happened at the caching layer admission control. We need to think about the stack top to bottom. And when we see any bottleneck, it's very very important to understand at which layer is that bottleneck so that we can invest properly. Now diving a little bit deep into a how a prompt works when we have a prompt for any application be it just if you want to generate an image or if you have a research task or if you have complex multi-agent orchestration more or less it involves a bunch of these steps. The prompt goes to the gateway. Then it goes to the router after which it does the cache lookup if the request was already seen before. Then it goes to the scheduulers which decides on which GPU cluster it should run on which hardware it can be on Nvidia or AMD or your in-house silicon chip which then goes to the appropriate serving runtime VLM SD lang or whatever we have we are working on and then we stream the response back to the user according to the SLO profiles of time to first token and time between each token and while making sure the throughput is what the users desired. Now as we can see this inference behaves like a distributed transaction. Each arrow in this diagram is a network hop. Every of every one of these hops can retry. It can time out.
7:52 It can fall back. It can even fail. And each of these hop will have an SLOs's and it will it it is streaming back to the user. So if it fails, the partial fail is mantics are much more harder to deal with than if for a regular RPC call. Think about what happens if we have already streamed 200 tokens back to the user and suddenly a GPU host is preempted due to a scheduled or a planned or unplanned maintenance event.
8:16 We cannot just retry. We have to think about it holistically. This is where this is why reliability we cannot build reliability at the edge. It has to be a property of the control plane because the control plane is the one which sees the whole workflow. Now let's talk about scheduulers and some of the optimizations and how we can think about it. So for the traditional microservices we used to think about bin packing of traditional microservices across three four dimensions could be across resource utilization CPU memory or could be across all domains depending upon if you're using AWS if you're using your own in-house cloud providers but for inference the schedule needs to be aware AC of across at least seven access when we schedule a particular request it has to be aware of the GPU type there can be any number of heterogeneous hardwarees in your cluster H00 versus E00 versus B200 with different network topologies.
9:09 It has to be aware of the HPM headroom, KV cache state, the model weights, whether they are already loaded, whether they're cold or we have to whether they have already warmed up, we have to cold start it. It has to be aware of the tenant priority. There can be any number of tenants running on that multi-tenant cluster with different SLO profiles. We have to also be aware of the workflow context. Are we in the third step of reasoning that has already spent X dollar or are we at the initial stages and we can terminate the workflow if it if we are overprovision. We have to also think about latency budget depending upon the type of agentic application we are building. So this brings us to the idea that we have to make sure that we implement agentic aware scheduling. We have to make sure that we place the work which will which will finish the in the fastest and the cheapest time as opposed to just placing it on a random GPU.
9:59 A concrete example might be that the skiller needs to be aware that request R is at step three of a five in a workflow and it has already and step one and two has already spent X plus Y dollar. So if a step three fails the whole workflow will be terminated and we have wasted all that compute resources. That's why workflow aware orchestration is very very important because it it will change the admission decisions the priority and how we retry.
10:25 Now let's talk about optimizations. I will not go too deep into a lot of optimizations. There's a lot of research which has already been done outside. But I would like to share a framework which at least I like to use when it comes to it. And we can place it into four quadrants. First, can we avoid the work? Meaning can we skip it entirely through caching through techniques like prefix caching, response caching, semantic caching. The second can we share the work? Can multiple requests share compute through batching? Think continuous patching, prefill decode, chunk prefill, specular decoding. Third, can we move away the work? Can we send it somewhere to a cheaper model or closer to the user through mostly routing? Can we route it to a smaller model or a cheaper region or some other techniques? And lastly, can we delay the work? Can we wait for a better moment through admission control and queueing which requires us to understand the priority classes of these requests and implement deadline aware scheduling. Now this framework is very powerful because it transfers to various stacks. You might be using VLM or SDG lang or tensor RT but every technique fits into one of these quadrants. So whenever we think about any optimization to our model we have to apply we have to do a comparison and contrast with the previous techniques and see how all these stack with each other.
11:47 Now whenever we think about scale it's not just important to think about the performance of the model. We have to think about the cost economics as well. This is where it's important to understand what metric we're trying to optimize because the cost is not just the cost of the GPU or the model. It is the cost of all these parameters retries, storage, failures, network and of course the operational cost of development and all that stuff. What is important is to understand what is the key key performance indicator for your product which will add value to the users. So it's not important to optimize just cost per token or cost per request.
12:22 We have to optimize cost per successful task because this is what actually users care about. And if you're able to optimize that, the cost for the overall product decreases and the users are much more happier. Now let's talk about reliability a little bit about reliability and what it means to prevent cascading failures. Now the failure story is never a GPU is preempted or GPU has died. The interesting stories is the feedback loop that follows. So a GPU can degrade, the latency can rise, the client retries, the Q depth increases, the healthy GPUs will saturate which will follow more retries, much more more full regional failures. This is the classic cascading failures. But for with a twist for agentic application, the KV cache, we cannot just casually restart or reroute to a different cluster. A cold pool has to warm up before it can absorb traffic during which the hot pool has to take on all that all those requests. This is why it's important to design the loop breakers very deliberately the circuit breakers at the routing layer the admission control which rejects rather than just queuing the load shedding tied to QEP not just CPU or memory utilization and we have to also think about retry budgets because if you don't think about all these things the cost can scale much much more quickly.
13:43 Now we'll hand it over to my co-speaker Naman to talk about the remaining talk.
14:56 Okay, this works I guess. Sorry for so once inference reach a production scale it starts looking much more like a distributed system. We are not longer just calling a model. It's more like a classic distributed system problem. So in distributed system we talk about cues, scheduuling, autoscaling, fault isolation. These are some of the dimensions. Inference has all these problems. But there are new constraints. Now instead of CPU, memory alone, we have CPU, HVM, KV cache and course per successful task. So the operating question becomes how the platform know what to do next. And that's where observability comes into play. It's not just about dashboards. It's about how to provide input signal to the control loop telemetry fields analysis analysis drive decisions is change of shoulduling and routing and finally we just rinse and repeat I'll just give an overview what are some important metrics first one is time to first token which tells me about how much time does it really take to get the first response then we have utilization ratio which tell me whether memory or compute is the bottleneck we have success per dollar that tests us whether platform is actually delivering and working efficiently. And finally, we have end to end race latency that tells us what's the time being spent across the full request path.
16:19 There's a core trader between latency, cost, and throughput. You cannot just get all of them. It's pretty analogous to cap theorem. If I increase the batch size, I improve the throughput and cost efficiency, but I may hurt tail latency. If I use speculative decoding, I may improve latency, but there are some extra compute. Ultimately, you know, we increase the cost per token. And finally, I can use a simple model, smaller model. I can reduce the latency and cost, but the response will be of low quality. Ultimately, I'll do failure analysis, do retries, which brings the cost back up. So, every serving decision moves system somewhere in this triangle.
16:56 And our job is to find the perfect setting. It's just an optimization problem. Now this is where the industry is heading right now. Inference needs its own control plane. Everything we discussed routing, batching, caching, scheduuling, reliability, they cannot be a separate knob. Now they're converging into a logical layer. Let's call it inference control plane. We used to manage VMs before in distributed system. We have autoscaling scheduulers and we had Kubernetes which turned these into control plane. Inference is going through the same transition now.
17:30 models are becoming resources. GPU, KV cache, token, latency, cost are now scheduled around. The control plane decides which models serve which request and how it is batched. So whether we build this layer internally, use open source or from a vendor, the key design is to assume layer will exist. Now let's discuss about where are some of the operating lessons we have experienced in a infra and how they are applicable here. The first lesson is that infrastructure bottlenecks usually show up before model bottlenecks in production. Many failures can come but there can be just aboutuling and routing or capacity breakdown. So these are not related to inference. It's about infrastructure problems. Then we have elasticity. We need elasticity in a system. We can have more GPUs but this will not really solve the problem. We are just hiding the problem. Then our solution to schedule the decision overpowered the efficiency. The same fleet can deliver very optimally depending on how you're shoulduling it or how you're batching it. Then we have control loops which beats the manual process. The platform has to sense, detect and automatically adapt to the system. So main takeaway is do not optimize for tokens. Optimize for successful task.
18:49 So this is a broader shift I want to leave you with. The first phase of a infrastructure was about better model. We invest a lot of time in improving our models, smarting, making the model smarter and coming with better benchmarks. The current phase right now is faster inference, lower latency, better batching and better GP utilization. But the next phase is about orchestration. That means GPU, memory, cache and everything. These are just resources and they need to be scheduled and controlled. The teams that understand this early on will build infrastructure for the future. So the closing idea is infrastructure is no longer a server problem. It's an orchestration problem.
19:29 Thank you.
Summary
- Inference is now a foundational hyperscale workload, outpacing traditional microservices in growth.
- The evolution of AI infrastructure mirrors the cloud era, with an emerging focus on orchestration layers.
- Capacity planning for AI inference must account for user interactions, model calls, and token variations, requiring a shift from traditional methods.
- Modern inference serving demands continuous inflight batching and state management, unlike traditional stateless microservices.
- The orchestration of AI workloads involves complex interactions across multiple layers, necessitating a holistic understanding of the entire stack.
- Optimizations in inference can be categorized into avoiding, sharing, moving, and delaying work, each impacting performance and cost.
- Reliability in AI systems must be built into the control plane to prevent cascading failures during inference processes.
- The future of AI infrastructure lies in developing a dedicated inference control plane that integrates various operational dimensions for optimal performance.
Questions Answered
What is the significance of distributed inference systems in AI?
Distributed inference systems are becoming essential as inference workloads grow rapidly, surpassing traditional microservices in scale and complexity. The evolution of AI mirrors the cloud era, moving from simple models to complex orchestration layers.
What are the key challenges in scaling model inference?
Scaling model inference is challenging due to the high costs of GPU resources and the complexity of maintaining state during requests. Unlike traditional microservices, model inference requires careful orchestration to avoid bottlenecks and ensure reliability.
How does reliability impact inference systems?
Reliability in inference systems must be built into the control plane rather than at the edge. This is essential to manage cascading failures and ensure that the system can handle preemptions and other disruptions without degrading user experience.
What factors should be considered for cost optimization in inference systems?
Cost optimization in inference systems involves understanding various metrics beyond just GPU costs, including retries, storage, and operational expenses. The focus should be on optimizing the cost per successful task rather than per request.
What metrics are important for optimizing inference systems?
Key metrics for optimizing inference systems include time to first token, utilization ratios, and end-to-end latency. Balancing latency, cost, and throughput is essential, as improvements in one area can negatively impact others.