Skip to content

Commit 6e55860

Browse files
authored
Update 1-overview-and-build.md
1 parent 9ce3c65 commit 6e55860

1 file changed

Lines changed: 58 additions & 31 deletions

File tree

content/learning-paths/servers-and-cloud-computing/vllm-acceleration/1-overview-and-build.md

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,101 +8,128 @@ layout: learningpathall
88

99
## What is vLLM?
1010

11-
vLLM is an open‑source, high‑throughput inference and serving engine for large language models. It focuses on efficient execution of the LLM inference prefill and decode phases with:
12-
13-
- Continuous batching to keep hardware busy across many requests.
14-
- KV cache management to sustain concurrency during generation.
15-
- Token streaming so results appear as they are produced.
16-
17-
You interact with vLLM in multiple ways:
18-
19-
- OpenAI‑compatible server: expose `/v1/chat/completions` for easy integration.
20-
- Python API: load a model and generate locally when needed.
21-
22-
vLLM works well with Hugging Face models, supports single‑prompt and batch workloads, and scales from quick tests to production serving.
11+
vLLM is an open-source, high-throughput inference and serving engine for large language models (LLMs).
12+
It’s designed to make LLM inference faster, more memory-efficient, and scalable, particularly during the prefill (context processing) and decode (token generation) phases of inference.
13+
14+
### Key Features
15+
* Continuous Batching – Dynamically combines incoming inference requests into a single large batch, maximizing CPU/GPU utilization and throughput.
16+
* KV Cache Management – Efficiently stores and reuses key-value attention states, sustaining concurrency across multiple active sessions while minimizing memory overhead.
17+
* Token Streaming – Streams generated tokens as they are produced, enabling real-time responses for chat or API scenarios.
18+
### Interaction Modes
19+
You can use vLLM in two main ways:
20+
* OpenAI-Compatible REST Server:
21+
vLLM provides a /v1/chat/completions endpoint compatible with the OpenAI API schema, making it drop-in ready for tools like LangChain, LlamaIndex, and the official OpenAI Python SDK.
22+
* Python API:
23+
Load and serve models programmatically within your own Python scripts for flexible local inference and evaluation.
24+
25+
vLLM supports Hugging Face Transformer models out-of-the-box and scales seamlessly from single-prompt testing to production batch inference.
2326

2427
## What you build
2528

26-
You build a CPU‑optimized vLLM for aarch64 with oneDNN and the Arm Compute Library (ACL). You then validate the build with a quick offline chat example.
29+
In this learning path, you will build a CPU-optimized version of vLLM targeting the Arm64 architecture, integrated with oneDNN and the Arm Compute Library (ACL).
30+
This build enables high-performance LLM inference on Arm servers, leveraging specialized Arm math libraries and kernel optimizations.
31+
After compiling, you’ll validate your build by running a local chat example to confirm functionality and measure baseline inference speed.
2732

2833
## Why this is fast on Arm
2934

35+
vLLM’s performance on Arm servers is driven by both software optimization and hardware-level acceleration.
36+
Each component of this optimized build contributes to higher throughput and lower latency during inference:
37+
3038
- Optimized kernels: The aarch64 vLLM build uses direct oneDNN with the Arm Compute Library for key operations.
31-
- 4‑bit weight quantization: INT4 quantization support & acceleration by Arm KleidiAI microkernels.
32-
- Efficient MoE execution: Fused INT4 quantized expert layers reduce memory traffic and improve throughput.
33-
- Optimized Paged attention: Arm SIMD tuned paged attention implementation in vLLM.
34-
- System tuning: Thread affinity and `tcmalloc` help keep latency and allocator overhead low under load.
39+
- 4‑bit weight quantization: vLLM supports INT4 quantized models, and Arm accelerates this using KleidiAI microkernels, which take advantage of DOT-product (SDOT/UDOT) and SME2 (Scalable Matrix Extension) instructions.
40+
- Efficient MoE execution: For Mixture-of-Experts (MoE) models, vLLM fuses INT4 quantized expert layers to reduce intermediate memory transfers, which minimizes bandwidth bottlenecks
41+
- Optimized Paged attention: The paged attention mechanism, which handles token reuse during long-sequence generation, is SIMD-tuned for Arm’s NEON and SVE (Scalable Vector Extension) pipelines.
42+
- System tuning: Using thread affinity ensures efficient CPU core pinning and balanced thread scheduling across Arm clusters.
43+
Additionally, enabling tcmalloc (Thread-Caching Malloc) reduces allocator contention and memory fragmentation under high-throughput serving loads.
3544

3645
## Before you begin
3746

38-
- Use Python 3.12 on Ubuntu 22.04+
39-
- Make sure you have at least 32 vCPUs, 64 GB RAM, and 32 GB free disk.
47+
Verify that your environment meets the following requirements:
48+
49+
Python version: Use Python 3.12 on Ubuntu 22.04 LTS or later.
50+
Hardware requirements: At least 32 vCPUs, 64 GB RAM, and 64 GB of free disk space.
51+
52+
This Learning Path was validated on an AWS Graviton4 c8g.12xlarge instance with 64 GB of attached storage.
4053

41-
Install the minimum system package used by vLLM on Arm:
54+
### Install Build Dependencies
4255

56+
Install the following packages required for compiling vLLM and its dependencies on Arm64:
4357
```bash
4458
sudo apt-get update -y
4559
sudo apt-get install -y build-essential cmake libnuma-dev
4660
sudo apt install -y python3.12-venv python3.12-dev
4761
```
4862

49-
Optional performance helper you can install now or later:
63+
You can optionally install tcmalloc, a fast memory allocator from Google’s gperftools, which improves performance under high concurrency:
5064

5165
```bash
5266
sudo apt-get install -y libtcmalloc-minimal4
5367
```
5468

5569
{{% notice Note %}}
56-
On aarch64, vLLM’s CPU backend automatically builds with Arm Compute Library via oneDNN.
70+
On aarch64, vLLM’s CPU backend automatically builds with the Arm Compute Library (ACL) through oneDNN.
71+
This ensures optimized Arm kernels are used for matrix multiplications, layer normalization, and activation functions without additional configuration.
5772
{{% /notice %}}
5873

59-
## Build vLLM for aarch64 CPU
74+
## Build vLLM for Arm64 CPU
75+
You’ll now build vLLM optimized for Arm (aarch64) servers with oneDNN and the Arm Compute Library (ACL) automatically enabled in the CPU backend.
6076

61-
Create and activate a virtual environment:
77+
1. Create and Activate a Python Virtual Environment
78+
It’s best practice to build vLLM inside an isolated environment to prevent conflicts between system and project dependencies:
6279

6380
```bash
6481
python3.12 -m venv vllm_env
6582
source vllm_env/bin/activate
6683
python3 -m pip install --upgrade pip
6784
```
6885

69-
Clone vLLM and install build requirements:
86+
2. Clone vLLM and Install Build Requirements
87+
Download the official vLLM source code and install its CPU-specific build dependencies:
7088

7189
```bash
7290
git clone https://github.com/vllm-project/vllm.git
7391
cd vllm
7492
git checkout 5fb4137
7593
pip install -r requirements/cpu.txt -r requirements/cpu-build.txt
7694
```
95+
The specific commit (5fb4137) pins a verified version of vLLM that officially adds Arm CPUs to the list of supported build targets, ensuring full compatibility and optimized performance for Arm-based systems.
7796

78-
Build a wheel targeted at CPU:
97+
3. Build the vLLM Wheel for CPU
98+
Run the following command to compile and package vLLM as a Python wheel optimized for CPU inference:
7999

80100
```bash
81101
VLLM_TARGET_DEVICE=cpu python3 setup.py bdist_wheel
82102
```
103+
The output wheel will appear under dist/ and include all compiled C++/PyBind modules.
83104

84-
Install the wheel. Use `--no-deps` for incremental installs to avoid clobbering your environment:
105+
4. Install the Wheel
106+
Install the freshly built wheel into your active environment:
85107

86108
```bash
87109
pip install --force-reinstall dist/*.whl # fresh install
88110
# pip install --no-deps --force-reinstall dist/*.whl # incremental build
89111
```
90112

91113
{{% notice Tip %}}
92-
Do NOT delete vLLM repo. Local vLLM repository is required for corect inferencing on aarch64 CPU after installing the wheel.
114+
Do not delete the local vLLM source directory.
115+
The repository contains C++ extensions and runtime libraries required for correct CPU inference on aarch64 after wheel installation.
93116
{{% /notice %}}
94117

95-
## Quick validation via offline inferencing
118+
## Quick validation via Offline Inferencing
96119

97-
Run the built‑in chat example to confirm the build:
120+
Once your Arm-optimized vLLM build completes, you can validate it by running a small offline inference example. This ensures that the CPU-specific backend and oneDNN and ACL optimizations were correctly compiled into your build.
121+
Run the built-in chat example included in the vLLM repository:
98122

99123
```bash
100124
python examples/offline_inference/basic/chat.py \
101125
--dtype=bfloat16 \
102126
--model TinyLlama/TinyLlama-1.1B-Chat-v1.0
103127
```
104128

105-
You should see tokens streaming and a final response. This verifies the optimized vLLM build on your Arm server.
129+
Explanation:
130+
--dtype=bfloat16 runs inference in bfloat16 precision. Recent Arm processors support the BFloat16 (BF16) number format in PyTorch. For example, AWS Graviton3 and Graviton3 processors support BFloat16.
131+
--model specifies a small Hugging Face model for testing (TinyLlama-1.1B-Chat), ideal for functional validation before deploying larger models.
132+
You should see token streaming in the console, followed by a generated output confirming that vLLM’s inference pipeline is working correctly.
106133

107134
```output
108135
Generated Outputs:

0 commit comments

Comments
 (0)