transcribe

Large clusters for small models — Daniel Svonava, Superlinked

AI Engineer · 24m · transcribed 1d ago
More from AI Engineer Business
𝕏 Share ▶ YouTube 📥 PDF 🤖 .md

Section Insights

# 0:00

Introduction to Small Open Source Models

What are small open source models and their advantages?

Small open source models can run on older Nvidia hardware and fit into one GPU, making them affordable and easy to serve. They can achieve competitive performance for specific tasks, offering cost savings and improved latency.

  • Small models are defined by their ability to run on older hardware.
  • They provide significant cost and latency benefits.
  • For specific tasks, small models can outperform larger models.
# 4:58

Availability of Open Source Models

What types of tasks can open source models handle?

There are numerous open source models available for various tasks such as OCR, question answering, image labeling, and code review. These models are often fine-tuned for specific tasks and can outperform proprietary solutions.

  • Open source models are available for a wide range of applications.
  • Fine-tuned models can excel in specific tasks due to extensive training data.
  • The bottleneck is not the availability of models, but their deployment.
# 9:56

Efficient Serving of Small Models

How can small models be efficiently served in a cluster?

The speaker discusses a cluster topology that utilizes a centralized queue for task management, allowing workers to pull tasks and form batches efficiently, which improves throughput significantly.

  • Centralized queueing can double the throughput of a model serving cluster.
  • Workers can optimize their own batch sizes based on real-time data.
  • The approach is open source and can be implemented by others.
# 14:54

Optimizing Batch Processing

What challenges arise in batch processing for model inference?

Predicting the optimal batch size for processing tasks is challenging. The system must allow for adjustments to avoid overloading the queue, especially in multi-GPU setups, to maintain efficiency.

  • Determining the optimal batch size is complex and requires dynamic adjustments.
  • Local queueing can enhance performance in multi-GPU environments.
  • Efficient batch processing is crucial for maximizing throughput.
# 19:52

Cost and Latency Benefits of Local Inference

What are the advantages of using local GPUs for embedding models?

Using local GPUs for embedding models can significantly reduce costs and latency compared to managed services. It allows for high throughput and low latency, making it an attractive option for businesses.

  • Local inference can process hundreds of thousands of tokens per second.
  • Costs are drastically lower compared to using managed APIs.
  • Low latency is achievable with local GPU setups, enhancing performance.

Transcript

0:12 All right, I think you guys can hear me. I can certainly hear myself. whoever came closer gets a t-shirt. I I meant it. There's like back full of t-shirts over here. and also for questions. Maybe there will be some questions at the end. If you ask a question, you get the t-shirt as well. And if you can guess what is on the background of this slide, you get a you get the t-shirt as well. Any guesses?

0:42 What does that visualize? This picture in the background? No. Anybody has seen a transformer model? >> yeah, positional encoding. Very good. You get the t-shirt, sir. All right. So, today we'll discuss u basically small open source models and how they are pretty good now and how they create unique challenges when you want to serve a bunch of them in your own cloud.

1:16 everything we'll discuss is kind of open source. do it yourself. This is the kind of stuff you can just you know run a command and own the stack. So there is no proprietary you know pieces of the puzzle here. let's get this underway. Well, this works. Okay. So small models. What do we mean by small models? you know depending who you ask, the way I think about it is basically models that you can run on two three generations old Nvidia hardware. The whole model fits into one GPU.

1:53 and therefore they are easy to serve those GPUs are available and they are affordable as well. and then most people think okay small models there will be some kind of tradeoff in terms of you know quality of the results and hopefully I'll be able to do a good job in this talk to convince you that actually for specific tasks you can be at frontier or beyond frontier performance and get all the other obvious benefits right orders of magnitudes of kind of cost savings and potentially quite big latency or throughput improvements of course.

2:35 so this is kind of one of the charts we like to show. This is the artificial analysis intelligence index over time. And what they typically don't show you is that there is like a breakdown of the open source models you should think about right there is the GLM 5.2 and so on those kind of frontier open source models with let's say 750 billion parameters. but then there are the small open source models kind of trailing the big ones and trailing the frontier. You can see the frontier is kind of getting diminishing returns these days and the small models are catching up right. So you see this kind of convergence saturation on top and and kind of growth of the of the small models and you know let's say quen 3627b somewhere around the performance of GPT 5.1. So if you have a workflow, if you have a pipeline that you know can run with GPT 5.1, now you can move that to a small model and you know get all the all the benefits we discussed. So small models not dumb anymore. now it is also about how you use the small models, right? So you can't just treat that 27 billion parameter quen 36 as your kind of totally generalized I can prompt it to do anything kind of model.

3:53 Now you need to adopt the approach where you basically figure out slice of tasks from the generalized model workload and then per task you figure out which model in the open source fits the task the best. You run some evals maybe some adaptation we'll discuss and then you know that's how you kind of reach the the right quality to actually push this into production. So here is some example of a contract review agent that uses you know nine different models. This is the kind of shape that you will see in your workloads in your agents as you move to using small models for your setup.

4:28 you'll start to see that okay instead of kind of hammering one API with bunch of different requests or one model you rather use a fleet of models and then your problem is okay how do I serve all of these different things in a way that my infra people don't go crazy right and this is just one of the agents that you might be running and there might be you know 10 of these in your company so how do how do we sort of you know that's the kind of expansion of infrastructure scope let's say Now all of those different tasks that I mentioned there is an open source model that's sitting there waiting to be used from you know OCR to question answering on top of documents to labeling images generating SQL you know reviewing code there are open source models fine-tuned and trained for those tasks you know if you use an open source model that's trained to do OCR on receipts in Vietnamese that project has seen the most receipts in Vietnamese, right? There's somebody who like took the time to gather as much data as possible and on that task that model will outperform pretty much anything else. and there is, you know, hundreds of thousands of models on hagging phase that look like that, right? So, it's just it's all sitting there and it's all free basically mostly quite permissive licenses. So the models exist you know that that's not the bottleneck and you know we've been talking about like open source AI since 2024 and it's so far still not really happening and to the extent it's happening in companies it basically equals like open source AI equals AWS bedrock except when you look at the model catalog in bedrock it's like very you know restrained in model types that are available these models are old often you two, three years behind the state-of-the-art. and when you do any kind of fine-tuning in bedrock, you don't actually own the fine-tuned or trained artifacts. So, you can't, you know, use it as an actual advantage in your business. It kind of stays serving from the bedrock infra.

6:33 so that's on the proprietary. Now if you do small models serving on open source infrastructure blm sglank different solutions just know that these things are not tuned for any specific model or any specific hardware model combination you'll have to do the tuning right this is the do-it-yourself all of these tools ship with guides on how to actually do the tuning the parameter sweep tailoring to your traffic and so on. This is a kind of open-ended research project every time you try to adopt one of these tools. So this is not really something that sort of you you take it and it's like an engineering project and a week later you have a high performance surveying infrastructure doesn't work like that. and that's kind of the typical problem with open source tools, right? This kind of like a little bit too much do it yourself.

7:24 and then on top of this not being kind of pre-tuned for small models, the small model workloads and traffic that uses a bunch of different models kind of flips the equation for inference kind of clusters, right? So normally when you try to serve one big model, your problems are how do I share that model across multiple GPUs? How do I have a router sitting on top that understands the state of all these workers? you know the KV cache state and so on and then makes a top- down routing decision of okay this request goes to this worker or this group of workers and and so on right it's very top down setup but if you have small and fast requests and you have many of them the this this sort of top down routing becomes the bottleneck right because the router has a little bit obsolete version of the worker state and it's just really hard to saturate the workers if you have that kind of upfront decision on that's that has to get it perfectly right in terms of u you know balancing the local cues on each of these workers because there's many small requests right and you know like we have experimented with the VLM and SGline routers for small models and this sort of traffic and it's very hard to get your GPU utilization beyond 20 30% under constant load and the problem is that those batches are just not correctly sized basically because you that routing bottleneck. and then the third problem is that with small models, you benefit a lot from Loras and just model adaptation in general. And so the traffic that you have to serve, you know, contains, you know, people coming to you and saying, "Hey, I have 10 loras. How do I, you know, use this with our serving stack? or I have this custom fine tune I made last night. You know, I I want to serve this in production." And this conversation between the AI engineer and the infrastructure person in getting those you know lauras up there custom models up there that's the thing that takes time and basically that's like the main killer in organizational velocity is talking right like ideally you would want the infrastructure engineers to do their job and you would want to those AI engineers to do their job and they don't have to talk to operate on the day-to-day mode. So, so you know they they are not blocking each other basically. and this kind of model adaptation desire around small models kind of breaks that and creates a lot of back and forth and that's a problem right so these are some challenges related to okay we have a bunch of small models how do we have a cluster how do we serve this efficiently so we have been playing with this problem for a while I'm Daniel actually from superl I kind of skip the intro so we are you know VC backed company out of SF and we have been building AI powered search and document processing systems and and agents for the last couple of years and our main painoint has always been inference.

10:24 specifically these problems that I have described. And so we have iterated and iterated and explored different topologies for clusters for running you know large wide fleets of small models in different environments because sometimes you need to deploy together with some platform in some environment where who knows what is available there. you know the small models make it easier because in whatever environment you can get some L4s or some kind of small GPU quota is much easier. So this is kind of I'll describe a little bit about the topology of the cluster that we have kind of converged to and by the way this whole thing is Apache 2.0 So completely open source. you guys can just take it and wrap it and now we are an inference startup. this is open source from kind of the control plane all the way down to the thing that runs on the GPU. so we we didn't pull any any punches. and the topology is basically there is a gateway and instead of having a router that kind of predecides what goes where there is a gateway that parses some of the request and attaches some metadata to the request inserts that request into a shared queue and into some side channels. I'll go a little bit into that and then the workers pull from that centralized queue instead of kind of pushing the data down to the workers.

11:44 And this way they can saturate themselves better. And then the worker setup I think I have a slide for that will describe how we basically absorb the complexity of different model architectures into kind of a coherent set of workers that you know don't have like competing Python requirements and stuff like that. so that's kind of the overall topology. and this is kind of life of a request. So maybe just I'll call out a couple of things from here.

12:17 we you know one of the things we don't like about the OpenAI kind of API standard is the B 64 encoded kind of JSON not good for small models not good for high throughput. So we use message pack throughout like a binary format. this way we can also push all the multimodel data through the actual API gateway. So there is no like hey you know binary data over here and then request over here and then the cluster needs access to your cloud storage to start loading some b some binary data images or videos. We kind of encode it all and we push it through the gateway.

12:53 and then the gateway kind of separates some of these heavier pieces to not clog the internal queue and differs it on cloud storage kind of inflight while the request is in Q. So it kind of splits up some of these requests that are let's say over a megabyte and then uses cloud storage in the back end. but as a user you push all your bits and byes into the API layer and it's kind of clean interface because of that.

13:20 basically the whole stack is rest. So gateway rest the the worker is rest and then over a socket locally it kind of attaches to different runtimes and we have basically pytorch kendle and sglank on the as as a runtime and and then when we do the optimization I'll kind of go into that on how we make sure that whichever runtime we are using and whichever code is running in that runtime is the most efficient one. we have an auto research loop for that basically. but yeah, so so life of a request kind of looks like that. And like one tidbit is that you really want to make sure that the gateway that's kind of the first thing that's hit by the request doesn't do too much work because then it becomes a bottleneck, right? So you don't even want to parse the whole request. You want to be able to kind of look at the packets and figure out the general shape of what's coming. do the annotation and then you have the workers however many workers you have hundreds of GPUs that that look at the queue state and then pull from there and and the queue we use u nats jetstream and that thing can do you know million requests per second like that's very hard for that to become a bottleneck so yeah like ideally you don't want to serialize this serialize as you go through all of these different components that's basically the kind of obvious thing. this is a little animation that shows the idea behind the centralized queuing, right? So instead of the top down router trying to you know fill in the local cues just right, which is basically impossible. you know the the whole idea is hey can we somehow centralize the queueing and can the workers rather pick up the task of forming their own batches with their own prediction of the cost of the batch and and then you know become much more efficient. Now one tidbit and kind of side note once you kind of start working on these things you realize that it's actually really hard to predict u how many things to pick up from that share queue for the batch to be really like really the optimal size and so you would want some mechanism that sort of allows you to put some things back into the queue if you figure out oh like I pulled a little bit too much and that's a network hop right so that's a problem and we have special optimization for that for machines that have multiple GPUs locally, right? So there is a there is additional kind of machine local queueing element that takes advantage of the fact that the local processes that run on the multiple GPUs on one machine can kind of negotiate with the queue a little bit back and forth which over the network you know there's like milliseconds extra that that would add and so we we don't do it over the network only when we collocate the workers on multiGPU machines and you know the I mean we are not talking about like 5% differences here Right? So like you centralize the queue and now you get double the throughput of the cluster. So this is this is significant. I mentioned three different runtimes. So basically it's either you know we write let's say for models that are encoder only we write the the PyTorch code and we kind of optimize it and we have a auto research loop that optimizes it. Same for Kendall. We started to play with Kendall not too long ago. We still can't get it to perform anywhere near the PyTorch performance. So it's a little bit more of a research project. It's just the dependency like you know the worker Docker image with PyTorch is like 12 GB and the worker do basically binary statically linked binary with Kendall is maybe like 10% of that right and if you care about kind of waking up from the cold state and loading these images on bunch of different machines the you know going from 12 gigs to a gigabyte or something like this makes makes a huge difference. So that's kind of the motivation behind Kendall. It's just the the getting the same performances from PyTorch is is is really hard. And then SG lang we have there as a kind of go to baseline like we should perform as at least as well as as SGANG with the optimal tuning of all of those parameters that I mentioned that you have to do the tuning. here is some numbers. So for example when we wrap SG lang with the socket and with our kind of RAS side car actually we can improve on the bare sglank performance just because we kind of do something on the batching side that natively sglang doesn't do and probably you can make it to do that if you do like if you develop custom plugins into sglang and stuff like that like probably you can match our performance because you know you can just push the same logic into the SG Glang core server but now you are developing custom code that only works with SGLAN and the whole lesson here from small models is that the runtimes are super diverse right you don't want to necessarily get staged with any one particular runtime because there is you know we have I think on the order of 50 different adapters now that that we parameterize for the different models and so you need to somehow deal with this kind of underlying complexity and it's probably not by building a bunch of plugins for one specific runtime it's probably some kind of abstraction which in our case is this rust site car concept and then the socket now I'll talk about couple different numbers but in terms of like language around benchmarking you know the knee is this concept of like when you ramp up traffic on a server when you sort of request more and more throughput from it and it gives you more and more throughput that's when you go kind of linearly up and And then at some point you hit this point where you kind of ask for more and more is not coming. So you kind of flatten out and the latency goes up. So we call that the the knee and it's it's like a useful concept in in benchmarking. because that's kind of the point of saturation, right? That's that's kind of the maximal performance without hurting latency.

19:27 so just to give you some ideas of what is possible on relatively small hardware, right? And different types of small models. So this is measured on the RTX Pro 6000. We we kind of work with Nvidia L4, you know, A100's, RTX Pro 6000, H100, that sort of range. again, those GPUs are much more readily available kind of on demand in any cloud. Basically, most continents have quota, you know. and on this kind of stuff you can basically get for embedding models even up to let's say hundreds of millions of parameters you can get hundreds of thousands of tokens per second encoded into the embedding right so imagine you are sitting there now like hitting your text embedding tree on open AAI API instead you could be like having one GPU and push half a million tokens per second into that thing and get the vectors out right like is this like connecting right you have half a million tokens that you are pushing into single GPU that's not even that big per second and you are getting out vector embeddings for your search system as opposed to like pushing all of that into a managed embeddings endpoint somewhere and paying like orders of magnitude more money right and you can get latencies like you know low tens of milliseconds for these calls like if you use you know cohhere openai APIs and so on these are hundreds of milliseconds right and and this is not rocket science you know you can have just like massive costsaving massive latency improvements and relatively e easy operation with with like handful of GPUs and some some infra around them right so this is like really low hanging fruit if you start anywhere with open source models small models embeddings are like no-brainer, right? but it doesn't end there. So let's say u you want to look at named entity recognition, you want to look at let's say multi vector search u even generation rate of text or structured outputs and so on. you you can be getting you know thousands of tokens per second output from you know task specific generative models as well per like let's say half a thousand per second for for one GPU there at the bottom and so let's say you are generating synthetic data you are generating annotations for your finetuning for your evals you know don't do that on a on a managed endpoint That's a perfect task because you have it kind of under control. You can survey the quality. That's a perfect task for open source model on your own infra.

22:22 and then you like if the infra you have around those GPUs is like reasonable you'll get linear scaling with with the number of those GPUs. now another sort of u idea if you are into small model serving is that you don't you know normally you have kind of worker pool per model right you have a set of workers set of nodes they have GPUs you kind of bring those up you preload the models the models load for tens of minutes because there are hundreds of billions of parameters and so you're happy okay they finally loaded now I have a worker pool this mentality doesn't really work with small models. Yeah. Yeah. Quickly. How how what's the time left?

23:07 >> Over. >> Oh, six minutes is over. Okay. All right. So, pack models on the same GPU is faster. this is a story of how you still want to pin some models, but you want to also do u basically lazy loading and eviction as a kind of function of memory pressure. You want to figure out how to combine the two. there is a little bit about kind of auto research. We have auto research loops for adding support for new models and for their performance. we build a lot of internal tooling to do the measurement to feed into those out research loops to basically push the numbers forward.

23:48 and maybe perhaps most importantly when we ship support for a model it has all the tuning done right. So there is no okay let's do a parameter sweep. We bundle basically a config for end to end the whole cluster. this is a setup for the auto research loop. There is like a meta loop that builds the harness that then runs the loop and there is a dashboard on top that helps you understand how it works. we have custom UIs for that. And one of the outputs of that was a Laura that took 80 cents to train and it improved 18 it improved quality of retrieval on German legalist STEX as a proof of concept by 18%. And that's it.

24:29 So small models are good. They are relatively easy to serve. they are actually much cheaper, faster, is as smart and that QR code goes to the GitHub repo of our cluster that I just described. Give us a star and happy self-hosting. Thank you.

Summary

The presentation discusses the advantages and challenges of using small open-source AI models, emphasizing their performance capabilities and cost-effectiveness compared to larger models. It highlights the importance of efficient infrastructure for serving multiple models and the need for tailored solutions to optimize performance.

- Small models can run on older Nvidia hardware and fit within a single GPU, making them affordable and accessible.
- They can achieve competitive performance for specific tasks, often matching or exceeding larger models.
- A shift in approach is needed to effectively utilize small models, focusing on task-specific models rather than a one-size-fits-all solution.
- The infrastructure for serving multiple small models requires a centralized queue system to optimize GPU utilization and manage requests efficiently.
- Open-source models are widely available and can be fine-tuned for specific tasks, offering significant cost and latency benefits.
- Challenges include the complexity of managing multiple models and the need for effective communication between AI engineers and infrastructure teams.
- The presentation introduces a new cluster topology that improves request handling and worker efficiency, utilizing message pack for better throughput.
- The speaker emphasizes the importance of auto-tuning and research loops to maintain optimal performance across different model architectures.

Questions Answered

What are small open source models and their advantages?

Small open source models can run on older Nvidia hardware and fit into one GPU, making them affordable and easy to serve. They can achieve competitive performance for specific tasks, offering cost savings and improved latency.

What types of tasks can open source models handle?

There are numerous open source models available for various tasks such as OCR, question answering, image labeling, and code review. These models are often fine-tuned for specific tasks and can outperform proprietary solutions.

How can small models be efficiently served in a cluster?

The speaker discusses a cluster topology that utilizes a centralized queue for task management, allowing workers to pull tasks and form batches efficiently, which improves throughput significantly.

What challenges arise in batch processing for model inference?

Predicting the optimal batch size for processing tasks is challenging. The system must allow for adjustments to avoid overloading the queue, especially in multi-GPU setups, to maintain efficiency.

What are the advantages of using local GPUs for embedding models?

Using local GPUs for embedding models can significantly reduce costs and latency compared to managed services. It allows for high throughput and low latency, making it an attractive option for businesses.

© transcribe · For agents Built with care and craft by Gokul Rajaram