If you have ever watched a response stream stall while the GPU looked idle, the next useful question is not which kernel is slow. It is which process is not being fed. In vLLM, HTTP handling, scheduling and the forward pass have different owners.
The problem is following one request across those boundaries. By the end of this article, you will be able to trace an OpenAI-compatible request from JSON to server-sent events, choose between the two public entry points, explain what ZMQ carries, and calculate the process and CPU floors for TP=4 and TP=2 with DP=4.
Welcome to AI and Its Architecture. This first of 30 parts begins with the serving path; the next part, PagedAttention and vLLM’s KV-cache block economy, opens the memory system beneath it.
The sources were last checked on 30 November 2026. This article describes vLLM v0.34.0, published on 16 November, whose release record makes Model Runner V2 the only GPU runner. The repository showed just under 98,000 stars on that date and an Apache-2.0 licence. Code links below are pinned to the release tag.
1. The process map
The architecture has three steady-state roles, plus a coordinator when data parallelism is enabled. The key/value (KV) cache is the attention state retained between token steps.
client
| HTTP JSON request server-sent events
|---------------------------------> API server process
| FastAPI + AsyncLLM
| render + tokenise
| load/process media
| detokenise + stream
|
| ZMQ: EngineCoreRequest
| token IDs, mm features, sampling parameters, metadata
v
EngineCore process, one per DP rank
input queue -> Scheduler <-> KVCacheManager
|
| SchedulerOutput
| token counts, block IDs, request diffs
v
Executor
/ | \
GPU worker GPU worker GPU worker
Model Runner V2 per worker
weights + GPU memory + forward + sampling
\ | /
ModelRunnerOutput
|
ZMQ: EngineCoreOutputs: new token IDs, finish data, stats
|
+---------> API server -> client stream
DP coordinator, only when DP > 1:
load balancing and synchronised MoE forward passes
The architecture overview assigns the work as follows.
- The API server owns HTTP, input processing and the client stream. It does not choose the batch or run the model.
- EngineCore owns request queues, the scheduler, KV-cache bookkeeping and worker coordination. It does not render chat prompts or detokenise responses.
- Each GPU worker owns one accelerator, its model weights and its model runner. Workers execute forward passes and sampling; they do not make global admission decisions.
- With data parallelism, a DP coordinator balances ranks and coordinates mixture-of-experts (MoE) forward passes.
That last distinction matters: EngineCore decides which KV blocks a request receives, while workers hold and use device memory. I find “control plane in EngineCore, tensor execution in workers” the useful mental model.
2. Two entry points, one underlying engine
vllm/entrypoints/llm.py contains the LLM class for offline Python inference. Its constructor builds an LLMEngine; generate() accepts prompts and returns a list of RequestOutput objects in prompt order. There is no HTTP listener.
vllm/entrypoints/cli/main.py is the command-line dispatcher. It registers subcommands, including serve, and invokes the selected command’s dispatch function. The implementation in vllm/entrypoints/cli/serve.py selects single- or multi-API-server launch paths and defaults the ordinary internal-load-balancing API count to the data-parallel size.
Offline does not necessarily mean one process. LLMEngine honours VLLM_ENABLE_V1_MULTIPROCESSING, which defaults to 1, and core_client.py provides a synchronous ZMQ client with a background EngineCore for LLM. Your Python process then plays the frontend role without becoming a web server.
I would use LLM for an embedded batch job and vllm serve for remote clients, streaming and ordinary DP deployment. One final version-specific detail: python -m vllm.entrypoints.openai.api_server is deprecated in v0.34.0; use vllm serve.
3. From JSON to EngineCoreRequest
For chat, the FastAPI route in chat_completion/api_router.py calls OpenAIServingChat.create_chat_completion(). The frontend renders the conversation with the model’s chat template, tokenises the result and converts OpenAI sampling options into engine parameters.
InputProcessor.process_inputs() validates those parameters and model inputs, then returns an EngineCoreRequest. Its initialisation notes that tokenisation and multimodal processing block, so asynchronous callers run them on the renderer’s thread pool rather than on the event loop.
Multimodal input takes the same route with extra work. Media is loaded and processed in the API server. InputProcessor flattens each item’s processed data, modality, identifier, prompt position and hash into MultiModalFeatureSpec entries, sorted by position. The scheduler therefore receives token positions and processed features, not an OpenAI JSON message containing an image URL.
Caching can remove repeated transfers. With one API server per EngineCore, the default key-replicated IPC cache keeps keys in both processes but processed data only in EngineCore. With TP workers, mm_processor_cache_type="shm" instead places processed data in shared memory. The optimisation guide also notes that API-server scale-out disables multimodal IPC caching because it requires that one-to-one process relationship.
4. What ZMQ carries, and why it is there
ZeroMQ (ZMQ) is the inter-process messaging transport between the frontend and EngineCore. The payload is a typed structure, not a reserialised HTTP request.
On the way in, EngineCoreRequest can carry:
- request and client identifiers;
- prompt token IDs or embeddings;
- multimodal features;
- sampling or pooling parameters;
- arrival time, priority and optional DP rank;
- LoRA and cache-salt data;
- trace headers and prompt block hashes.
Long prompt lists are converted to 32-bit NumPy arrays and sent out of band. serial_utils.py implements MessagePack encoding with custom tensor and array handling: small arrays go inline, while larger ones travel as separate backing buffers instead of being copied into the top-level message.
On the way back, EngineCoreOutputs contains an engine index, scheduler statistics and a list of per-request outputs. Each output carries a request ID, new token IDs and optional logprobs, finish and stop data, events and other feature-specific results.
The reason for the boundary is overlap. vLLM’s V1 design post describes moving tokenisation, multimodal work, detokenisation and streaming outside the isolated EngineCore loop. My inference is that separate processes also keep that frontend CPU work from contending with the scheduler for one Python global interpreter lock (GIL); the design post speaks of overlap, not the GIL. EngineCore also has input and output threads: its source comments say ZMQ socket I/O releases the GIL, allowing it and some serialisation to overlap model execution.
My working read is that ZMQ is not the optimisation by itself. The win is the asynchronous process boundary; ZMQ supplies its transport and, with ordinary internal-load-balancing DP, a many-to-many topology in which every API server can reach every EngineCore.
Do not confuse this with the next hop. EngineCore reaches workers through an executor. The local multiprocess path uses MessageQueue, whose implementation includes a shared-memory ring buffer. Tensor-parallel collectives are yet another communication path.
5. Scheduling, KV blocks and GPU execution
EngineCore’s input thread places the decoded request on an internal queue. The scheduler admits it, then builds a step from running and waiting requests. It assigns token counts within max_num_batched_tokens; with chunked prefill, pending decodes go first and prefills consume the remaining budget.
Before execution, the scheduler asks KVCacheManager for already computed blocks and allocates slots for new work. SchedulerOutput then carries token counts, block IDs and encoder work to the executor. New requests include their full data; subsequent steps send diffs because workers cache request state.
This example is made up. Suppose a text request has 12 prompt tokens, three older requests are decoding, and the token budget is eight. Assume no prefix hit, speculation or KV shortage.
| Step | Work scheduled | New request afterwards |
|---|---|---|
| 1 | Three decodes + five prompt tokens = 8 | Five of 12 prompt tokens computed |
| 2 | Three decodes + five prompt tokens = 8 | Ten of 12 computed; no output token yet |
| 3 | Three decodes + two prompt tokens = 5 | Prefill finishes; first token is sampled |
| 4 | Four ordinary decodes = 4 | Second token is sampled |
The same pattern scales to real budgets: a long prefill shares steps with active decodes instead of forming a separate global phase. Worker results use ModelRunnerOutput to carry request IDs and sampled token IDs back to the scheduler process.
Every worker has a model runner that prepares inputs and runs the model. In this release that is Model Runner V2, examined in a later part, Model Runner V2: vLLM’s asynchronous GPU execution loop. Workers load weights and execute the forward and sampling work; EngineCore updates request state from their results.
6. The return path to streamed text
EngineCore packages new token IDs into EngineCoreOutputs and sends them over ZMQ. It does not send a freshly rendered chat response.
In the API server, OutputProcessor.process_outputs() updates statistics, incrementally detokenises IDs and creates RequestOutput objects for each waiting AsyncLLM.generate() task. The OpenAI layer turns those deltas into protocol responses, and the route returns them as text/event-stream, meaning server-sent events (SSE).
Stop strings expose an interesting ownership detail. Detokenisation detects them in the frontend; if EngineCore has not already finished the request, OutputProcessor adds its ID to reqs_to_abort so generation can stop there too.
One streaming caveat follows from RequestOutputCollector: when the producer gets ahead, delta outputs can merge. I would not treat one SSE event as a guarantee of exactly one model token.
7. Process arithmetic and operating consequences
Tensor parallelism (TP) shards model parameters across GPUs. Data parallelism (DP) replicates the model and processes different request batches. Pipeline parallelism (PP) splits layers. For N = DP × PP × TP GPUs and A API servers, the documented total is:
A + DP + N + (1 if DP > 1, otherwise 0).
These example launches use the model identifier from the optimisation guide. The model fits on one GPU, so read them as process-count illustrations, not sizing advice:
MODEL_ID=Qwen/Qwen3-8B
# One node, four GPUs: TP=4, DP=1, PP=1
vllm serve "$MODEL_ID" --tensor-parallel-size 4
# Eight GPUs: four replicas, each sharded across two GPUs
vllm serve "$MODEL_ID" --tensor-parallel-size 2 --data-parallel-size 4
| Configuration | API servers | EngineCores | GPU workers | DP coordinator | Total |
|---|---|---|---|---|---|
| TP=4, DP=1, PP=1 | 1 | 1 | 4 | 0 | 6 |
| TP=2, DP=4, PP=1 | 4 | 4 | 8 | 1 | 17 |
The second row is not one scheduler with eight workers. It is four EngineCores, each with its own scheduler, KV manager and two-worker TP group. Every API server connects to every EngineCore.
vLLM’s CPU guidance uses the same total as the minimum physical-core count. That gives six physical cores for TP=4 and 17 for TP=2 with DP=4, or 12 and 34 vCPUs respectively when two hyperthreads equal one physical core. These are floors, not generous production allocations: the OS and PyTorch threads also need time. Each API server additionally has eight media-loading threads by default, so four servers create capacity for 32 such threads.
My preference is TP or PP when the model does not fit, and DP only when it fits per replica and throughput is the goal. Scaling API servers makes sense after input processing proves to be the bottleneck; extra frontends cannot repair a GPU-bound forward pass, and the multimodal IPC-cache trade-off may change the decision.
For observability, the /metrics endpoint exposes queue depth, KV-cache usage, preemptions, queue time and time to first token (TTFT). A low GPU-utilisation reading alongside rising queue time points towards admission or CPU starvation before kernel tuning.
The process split is not a security boundary. The security guide says inter-node communications are insecure by default. It also warns that --api-key protects only selected path prefixes, not every endpoint. Use a reverse proxy with an endpoint allowlist, restrict media domains to prevent server-side request forgery, and isolate internal ports. Tenants sharing a server also share caches; cache_salt reduces a specific risk but is not tenant isolation. Finally, Apache-2.0 covers the vLLM code, not a substitute for reviewing the model artifact’s own terms.
8. What to do on Monday
- Pin the release and record the launch topology. Write down TP, PP, DP, API-server count and executor before comparing traces. Reapply the process formula after changing any of them.
- Trace one request by ID. Note when rendering finishes, when EngineCore admits it, when its first token returns and when SSE delivery ends. Keep prompt-body logging off unless you have explicitly accepted that data exposure.
- Budget CPUs from processes, then measure. Start with the documented physical-core floor, inspect EngineCore starvation, and account for media and PyTorch threads separately.
- Graph four metrics together. Plot
vllm:num_requests_waiting,vllm:kv_cache_usage_perc,rate(vllm:num_preemptions_total[5m])and thevllm:request_queue_time_secondshistogram, withvllm:time_to_first_token_secondsalongside. Counters gain a_totalsuffix on/metrics, so the docs table’svllm:num_preemptionsis scraped asvllm:num_preemptions_total. This separates queue pressure from a slow forward pass more usefully than GPU utilisation alone. - Review the boundary as an operator. Allowlist public routes and media domains, firewall internal communications, decide whether tenants require separate instances, and check both code and model licences.
9. The idle GPU, revisited
A stalled stream now has addresses: frontend preparation, EngineCore admission, worker execution, or the return stream. An idle GPU is only a symptom; the last completed hand-off tells you where to investigate next. The next part examines the KV blocks for which that hand-off may be waiting.
Built from public sources as of 30 November 2026. Any mistakes are mine alone, and nothing here speaks for the companies mentioned.