You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/vllm-acceleration/3-run-inference-and-serve.md
+34-10Lines changed: 34 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,20 @@ weight: 4
6
6
layout: learningpathall
7
7
---
8
8
9
-
## About batch sizing in vLLM
9
+
## Batch Sizing in vLLM
10
10
11
-
vLLM enforces two limits to balance memory use and throughput: a per‑sequence length (`max_model_len`) and a per‑batch token limit (`max_num_batched_tokens`). No single request can exceed the sequence limit, and the sum of tokens in a batch must stay within the batch limit.
11
+
vLLM uses dynamic continuous batching to maximize hardware utilization. Two key parameters govern this process:
12
+
*`max_model_len` — The maximum sequence length (number of tokens per request).
13
+
No single prompt or generated sequence can exceed this limit.
14
+
*`max_num_batched_tokens` — The total number of tokens processed in one batch across all requests.
15
+
The sum of input and output tokens from all concurrent requests must stay within this limit.
16
+
17
+
Together, these parameters determine how much memory the model can use and how effectively CPU threads are saturated.
18
+
On Arm-based servers, tuning them helps achieve stable throughput while avoiding excessive paging or cache thrashing.
12
19
13
20
## Serve an OpenAI‑compatible API
14
21
15
-
Start the server with sensible CPU default parameters and a quantized model:
22
+
Start vLLM’s OpenAI-compatible API server using the quantized INT4 model and environment variables optimized for performance.
The server now exposes the standard OpenAI-compatible /v1/chat/completions endpoint.
38
+
39
+
You can test it using any OpenAI-style client library to measure tokens-per-second throughput and response latency on your Arm-based server.
40
+
30
41
## Run multi‑request batch
42
+
After verifying a single request in the previous section, simulate concurrent load against the OpenAI-compatible server to exercise vLLM’s continuous batching scheduler.
43
+
44
+
About the client:
45
+
Uses AsyncOpenAI with base_url="http://localhost:8000/v1" to target the vLLM server.
46
+
A semaphore caps concurrency to 8 simultaneous requests (adjust CONCURRENCY to scale load).
47
+
max_tokens limits generated tokens per request—this directly affects batch size and KV cache use.
31
48
32
-
After confirming a single request works explained in previous example, simulate concurrent load with a small OpenAI API compatible client. Save this as`batch_test.py`:
49
+
Save the code below in a file named`batch_test.py`:
33
50
34
51
```python
35
52
import asyncio
@@ -88,7 +105,7 @@ if __name__ == "__main__":
88
105
asyncio.run(main())
89
106
```
90
107
91
-
Run 8 concurrent requests against your server:
108
+
Run 8 concurrent requests:
92
109
93
110
```bash
94
111
python3 batch_test.py
@@ -108,19 +125,26 @@ This validates multi‑request behavior and shows aggregate throughput in the se
108
125
(APIServer pid=4474) INFO: 127.0.0.1:44120 - "POST /v1/chat/completions HTTP/1.1" 200 OK
For a BF16 pathon Arm, vLLM is acclerated by direct oneDNN integration in vLLM which allows aarch64 model to be hyperoptimized.
130
+
For a non-quantized path, vLLM on Arm can run BF16 end-to-end using its oneDNN integration (which routes to Arm-optimized kernels via ACL under aarch64).
114
131
115
132
```bash
116
133
vllm serve deepseek-ai/DeepSeek-V2-Lite \
117
134
--dtype bfloat16 --max-model-len 4096 \
118
135
--max-num-batched-tokens 4096
119
136
```
137
+
Use this BF16 setup to establish a quality reference baseline, then compare throughput and latency against your INT4 deployment to quantify the performance/accuracy trade-offs on your Arm system.
120
138
121
139
## Go Beyond: Power Up Your vLLM Workflow
122
-
Now that you’ve successfully quantizedand served a model using vLLM on Arm, here are some further ways to explore:
140
+
Now that you’ve successfully quantized, served, and benchmarked a model using vLLM on Arm, you can build on what you’ve learned to push performance, scalability, and usability even further.
123
141
124
-
***Try different models:** Apply the same steps to other [Hugging Face models](https://huggingface.co/models) like Llama, Qwen or Gemma.
142
+
**Try Different Models**
143
+
Extend your workflow to other models on Hugging Face that are compatible with vLLM and can benefit from Arm acceleration:
144
+
* Meta Llama 2 / Llama 3 – Strong general-purpose baselines; excellent for comparing BF16 vs INT4 performance.
145
+
* Qwen / Qwen-Chat – High-quality multilingual and instruction-tuned models.
146
+
* Gemma (Google) – Compact and efficient architecture; ideal for edge or cost-optimized serving.
147
+
148
+
You can quantize and serve them using the same `quantize_vllm_models.py` recipe, just update the model name.
125
149
126
-
***Connect a chat client:** Link your server with OpenAI-compatible UIs like [Open WebUI](https://github.com/open-webui/open-webui)
150
+
***Connect a chat client:** Link your server with OpenAI-compatible UIs like [Open WebUI](https://github.com/open-webui/open-webui)
0 commit comments