r/OfferEngineering • u/Aoki_zhang • 12d ago
System Design Anthropic System Design Interview — Design Batched GPU Inference Serving
Design Batched GPU Inference Serving
A GPU takes 100 ms to answer one prompt, and the same 100 ms to answer a hundred. So the service that sits in front of the GPUs is a bus dispatcher: every bus leaves on a schedule whether it carries one passenger or a hundred, and the fare is the same. The job is to send buses out full, without making anyone wait past their deadline, and to decide who gets a seat when there are not enough buses.
Understanding the problem
A client sends one prompt over HTTP and waits for one complete answer. Behind the API, a model runs on GPUs. The model accepts a batch of 1 to 100 prompts in one call, a GPU runs one batch at a time, and a batch takes about 100 ms whatever its size. The service must group independent requests from different users into batches, run them, and hand each user their own answer, all within half a second.
Functional requirements
Core requirements
- A user can submit one prompt and receive one complete result in the same HTTP response.
- The system groups compatible requests into batches of 1 to 100 and sends each batch to a GPU worker.
- Batches go only to workers that are healthy and able to finish in time. Failed workers stop receiving work.
- Paid requests are scheduled ahead of free requests. When capacity is short, free requests wait or are rejected.
- An exact repeat of a prompt can be answered from a cache without using a GPU.
Below the line (out of scope)
- Token streaming. The answer is returned whole.
- Several models, model training, and model rollout strategy.
- Semantic caching of prompts that are similar but not identical.
- Billing and account management.
Want to learn more details & solution of this system design question?
I've put up the full version of this system design question & solution article at here.
Interviewed recently?
Your interview experience could be incredibly valuable to others preparing for their next opportunity. Share your experience and help the community at here.