Skip to content

Commit 48754ac

Browse files
committed
minor polish
renamed: docs/hpc/08_ml_ai_hpc/LLM Inference/01_llm_inferenceoverview.md -> docs/hpc/08_ml_ai_hpc/08_LLM inference/01_llm_inferenceoverview.md renamed: docs/hpc/08_ml_ai_hpc/LLM Inference/02_run_hf_model.md -> docs/hpc/08_ml_ai_hpc/08_LLM inference/02_run_hf_model.md renamed: docs/hpc/08_ml_ai_hpc/LLM Inference/03_vLLM.md -> docs/hpc/08_ml_ai_hpc/08_LLM inference/03_vLLM.md
1 parent a0659a3 commit 48754ac

3 files changed

Lines changed: 40 additions & 34 deletions

File tree

docs/hpc/08_ml_ai_hpc/LLM Inference/01_llm_inferenceoverview.md renamed to docs/hpc/08_ml_ai_hpc/08_LLM inference/01_llm_inferenceoverview.md

File renamed without changes.

docs/hpc/08_ml_ai_hpc/LLM Inference/02_run_hf_model.md renamed to docs/hpc/08_ml_ai_hpc/08_LLM inference/02_run_hf_model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Run a Hugging Face model
1+
# Basic LLM Inference with Hugging Face transformers
22

33
Here we provide an example of how one can run a Hugging Face Large-language model (LLM) on the NYU Torch cluster
44

docs/hpc/08_ml_ai_hpc/LLM Inference/03_vLLM.md renamed to docs/hpc/08_ml_ai_hpc/08_LLM inference/03_vLLM.md

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,49 @@
1-
# vLLM - A Command Line LLM Tool
1+
# High-performance LLM inference with `vLLM`
2+
23
## What is vLLM?
3-
[vLLM](https://docs.vllm.ai/en/latest/) is a fast and easy-to-use library for LLM inference and serving.
4-
5-
## Why vLLM?
6-
We tested vLLM and llama-cpp on Torch, and found vLLM performs better on Torch:
7-
Model: Qwen2.5-7B-Instruct
8-
Prompt Tokens:512
9-
Output Tokens: 256
10-
|Backend|Peak Throughput|Median Latency(ms)|Recommendation
4+
[`vLLM`](https://docs.vllm.ai/en/latest/) is an easy-to-use library for LLM inference and serving which support a wide variety of models with optimized kernels ensuring optimal utilization of GPUs.
5+
6+
## Why `vLLM`?
7+
We tested `vLLM` and `llama-cpp` (the inference framework behind `ollama`) on Torch, and found `vLLM` performs better on Torch with the following model and token configuration:
8+
9+
Model: `Qwen2.5-7B-Instruct`
10+
11+
Prompt Tokens: `512`
12+
13+
Output Tokens: `256`
14+
15+
|Inference Server|Peak Throughput|Median Latency(ms)|Recommendation
1116
|-----|-----|-----|-----|
12-
|vLLM|~4689.6|~48.0|Best for Batch/Research|
13-
|llama-cpp|~115.0|~280.0|Best for Single User|
17+
|`vLLM`|~4689.6|~48.0|Best for Batch/Research|
18+
|`llama-cpp`|~115.0|~280.0|Best for Single User|
1419

1520
## vLLM Installation Instructions
16-
Create a vLLM directory in your /scratch directory, then install the vLLM image:
21+
Create a `vLLM` directory in your /scratch directory, then install the vLLM image:
1722
```
1823
apptainer pull docker://vllm/vllm-openai:latest
1924
```
20-
### Use High-Performance SCRATCH Storage
21-
LLMs require very fast storage. On Torch, the SCRATCH filesystem is an all-flash system designed for AI workloads, providing excellent performance.To avoid exceeding your $HOME quota (50GB) and inode limits (30,000 files), you should redirect vLLM's cache and Hugging Face's model downloads to your scratch space:
22-
```
25+
### Avoid filling up your `$HOME` directory
26+
To avoid exceeding your `$HOME` quota (50GB) and inode limits (30,000 files), you should redirect `vLLM`'s cache and Hugging Face's model downloads to your scratch space:
27+
```sh
2328
export HF_HOME=/scratch/$USER/hf_cache
2429
export VLLM_CACHE_ROOT=/scratch/$USER/vllm_cache
2530
```
26-
You should run this to configure vLLM to always use your SCRATCH storage for consistent use:
27-
```
31+
You should run this to configure `vLLM` to always use your `$SCRATCH` storage for consistent use:
32+
```sh
2833
echo "export HF_HOME=/scratch/\$USER/hf_cache" >> ~/.bashrc
2934
echo "export VLLM_CACHE_ROOT=/scratch/\$USER/vllm_cache" >> ~/.bashrc
3035
```
3136

32-
Note: Files on $SCRATCH are not backed up and will be deleted after 60 days of inactivity. Always keep your source code and .slurm scripts in $HOME!
37+
:::note
38+
Files on `$SCRATCH` are not backed up and will be deleted after 60 days of inactivity. Always keep your source code and .slurm scripts in `$HOME`!
39+
:::
3340

3441
## Run vLLM
3542
### Online Serving (OpenAI-Compatible API)
36-
vLLM implements the OpenAI API protocol, allowing it to be a drop-in replacement for applications using OpenAI's services. By default, it starts the server at http://localhost:8000. You can specify the address with --host and --port arguments.
43+
`vLLM` implements the OpenAI API protocol, allowing it to be a drop-in replacement for applications using OpenAI's services. By default, it starts the server at `http://localhost:8000`. You can specify the address with `--host` and `--port` arguments.
3744
**In Terminal 1:**
3845
Start vLLM server (In this example we use Qwen model):
39-
```
46+
```sh
4047
apptainer exec --nv vllm-openai_latest.sif vllm serve "Qwen/Qwen2.5-0.5B-Instruct"
4148
```
4249
When you see:
@@ -46,7 +53,7 @@ Application startup complete.
4653
Open another terminal and log in to the same computing node as in terminal 1.
4754

4855
**In Terminal 2**
49-
```
56+
```sh
5057
curl http://localhost:8000/v1/chat/completions \
5158
-H "Content-Type: application/json" \
5259
-d '{
@@ -58,33 +65,32 @@ curl http://localhost:8000/v1/chat/completions \
5865
```
5966

6067
### Offline Inference
61-
If you need to process a large dataset at once without setting up a server, you can use vLLM's LLM class.
62-
For example, the following code downloads the facebook/opt-125m model from HuggingFace and runs it in vLLM using the default configuration.
63-
```
68+
If you need to process a large dataset at once without setting up a server, you can use `vLLM`'s LLM class.
69+
For example, the following code downloads the `facebook/opt-125m` model from HuggingFace and runs it in `vLLM` using the default configuration.
70+
```python
6471
from vllm import LLM
6572

6673
# Initialize the vLLM engine.
6774
llm = LLM(model="facebook/opt-125m")
6875
```
6976
After initializing the LLM instance, use the available APIs to perform model inference.
7077

71-
### SGLang: A Simple Option for Offline Batch Inference (Supplement Material)
78+
### SGLang: A Simple Option for Offline Batch Inference
7279
For cases where users only want to run batch inference and do not need an HTTP endpoint, SGLang provides a much simpler offline engine API compared to running a full vLLM server. It is particularly suitable for dataset processing, evaluation pipelines, and one-off large-scale inference jobs.
73-
For more details and examples, see the official SGLang offline engine documentation:
74-
https://docs.sglang.io/basic_usage/offline_engine_api.html
80+
For more details and examples, see the official SGLang offline engine documentation here: https://docs.sglang.io/basic_usage/offline_engine_api.html
7581

7682

77-
## vLLM CLI
78-
The vllm command-line tool is used to run and manage vLLM models. You can start by viewing the help message with:
79-
```
83+
## `vLLM` CLI
84+
The `vllm` command-line tool is used to run and manage `vLLM` models. You can start by viewing the help message with:
85+
```sh
8086
vllm --help
8187
```
8288
Serve - Starts the vLLM OpenAI Compatible API server.
83-
```
89+
```sh
8490
vllm serve meta-llama/Llama-2-7b-hf
8591
```
8692
Chat - Generate chat completions via the running API server.
87-
```
93+
```sh
8894
# Directly connect to localhost API without arguments
8995
vllm chat
9096

@@ -95,7 +101,7 @@ vllm chat --url http://{vllm-serve-host}:{vllm-serve-port}/v1
95101
vllm chat --quick "hi"
96102
```
97103
Complete - Generate text completions based on the given prompt via the running API server.
98-
```
104+
```sh
99105
# Directly connect to localhost API without arguments
100106
vllm complete
101107

0 commit comments

Comments
 (0)