Efficient LLM inference on Slurm clusters using vLLM.
Project description
Vector Inference: Easy inference on Slurm clusters
This repository provides an easy-to-use solution to run inference servers on Slurm-managed computing clusters using vLLM. All scripts in this repository runs natively on the Vector Institute cluster environment. To adapt to other environments, update the environment variables in cli/_helper.py, cli/_config.py, vllm.slurm, multinode_vllm.slurm and models.yaml accordingly.
Installation
If you are using the Vector cluster environment, and you don't need any customization to the inference server environment, run the following to install package:
pip install vec-inf
Otherwise, we recommend using the provided Dockerfile to set up your own environment with the package
Usage
launch command
The launch command allows users to deploy a model as a slurm job. If the job successfully launches, a URL endpoint is exposed for the user to send requests for inference.
We will use the Llama 3.1 model as example, to launch an OpenAI compatible inference server for Meta-Llama-3.1-8B-Instruct, run:
vec-inf launch Meta-Llama-3.1-8B-Instruct
You should see an output like the following:
Overrides
Models that are already supported by vec-inf would be launched using the cached configuration or default configuration. You can override these values by providing additional parameters. Use vec-inf launch --help to see the full list of parameters that can be
overriden. For example, if qos is to be overriden:
vec-inf launch Meta-Llama-3.1-8B-Instruct --qos <new_qos>
Custom models
You can also launch your own custom model as long as the model architecture is supported by vLLM, and make sure to follow the instructions below:
- Your model weights directory naming convention should follow
$MODEL_FAMILY-$MODEL_VARIANT($MODEL_VARIANT is OPTIONAL). - Your model weights directory should contain HuggingFace format weights.
- You should specify your model configuration by:
- Creating a custom configuration file for your model and specify its path via setting the environment variable
VEC_INF_CONFIG. Check the default parameters file for the format of the config file. All the parameters for the model should be specified in that config file. - Using launch command options to specify your model setup.
- Creating a custom configuration file for your model and specify its path via setting the environment variable
- For other model launch parameters you can reference the default values for similar models using the
listcommand .
Here is an example to deploy a custom Qwen2.5-7B-Instruct-1M model which is not
supported in the default list of models using a user custom config. In this case, the model weights are assumed to be downloaded to
a model-weights directory inside the user's home directory. The weights directory of the model follows the naming convention so it
would be named Qwen2.5-7B-Instruct-1M. The following yaml file would need to be created, lets say it is named /h/<username>/my-model-config.yaml.
models:
Qwen2.5-7B-Instruct-1M:
model_family: Qwen2.5
model_variant: 7B-Instruct-1M
model_type: LLM
gpus_per_node: 1
num_nodes: 1
vocab_size: 152064
max_model_len: 1010000
max_num_seqs: 256
pipeline_parallelism: true
enforce_eager: false
qos: m2
time: 08:00:00
partition: a40
model_weights_parent_dir: /h/<username>/model-weights
You would then set the VEC_INF_CONFIG path using:
export VEC_INF_CONFIG=/h/<username>/my-model-config.yaml
Note that there are other parameters that can also be added to the config but not shown in this example, such as data_type and log_dir.
status command
You can check the inference server status by providing the Slurm job ID to the status command:
vec-inf status 15373800
If the server is pending for resources, you should see an output like this:
When the server is ready, you should see an output like this:
There are 5 possible states:
- PENDING: Job submitted to Slurm, but not executed yet. Job pending reason will be shown.
- LAUNCHING: Job is running but the server is not ready yet.
- READY: Inference server running and ready to take requests.
- FAILED: Inference server in an unhealthy state. Job failed reason will be shown.
- SHUTDOWN: Inference server is shutdown/cancelled.
Note that the base URL is only available when model is in READY state, and if you've changed the Slurm log directory path, you also need to specify it when using the status command.
metrics command
Once your server is ready, you can check performance metrics by providing the Slurm job ID to the metrics command:
vec-inf metrics 15373800
And you will see the performance metrics streamed to your console, note that the metrics are updated with a 2-second interval.
shutdown command
Finally, when you're finished using a model, you can shut it down by providing the Slurm job ID:
vec-inf shutdown 15373800
> Shutting down model with Slurm Job ID: 15373800
list command
You call view the full list of available models by running the list command:
vec-inf list
NOTE: The above screenshot does not represent the full list of models supported.
You can also view the default setup for a specific supported model by providing the model name, for example Meta-Llama-3.1-70B-Instruct:
vec-inf list Meta-Llama-3.1-70B-Instruct
launch, list, and status command supports --json-mode, where the command output would be structured as a JSON string.
Send inference requests
Once the inference server is ready, you can start sending in inference requests. We provide example scripts for sending inference requests in examples folder. Make sure to update the model server URL and the model weights location in the scripts. For example, you can run python examples/inference/llm/chat_completions.py, and you should expect to see an output like the following:
{
"id":"chatcmpl-387c2579231948ffaf66cdda5439d3dc",
"choices": [
{
"finish_reason":"stop",
"index":0,
"logprobs":null,
"message": {
"content":"Arrr, I be Captain Chatbeard, the scurviest chatbot on the seven seas! Ye be wantin' to know me identity, eh? Well, matey, I be a swashbucklin' AI, here to provide ye with answers and swappin' tales, savvy?",
"role":"assistant",
"function_call":null,
"tool_calls":[],
"reasoning_content":null
},
"stop_reason":null
}
],
"created":1742496683,
"model":"Meta-Llama-3.1-8B-Instruct",
"object":"chat.completion",
"system_fingerprint":null,
"usage": {
"completion_tokens":66,
"prompt_tokens":32,
"total_tokens":98,
"prompt_tokens_details":null
},
"prompt_logprobs":null
}
NOTE: For multimodal models, currently only ChatCompletion is available, and only one image can be provided for each prompt.
SSH tunnel from your local device
If you want to run inference from your local device, you can open a SSH tunnel to your cluster environment like the following:
ssh -L 8081:172.17.8.29:8081 username@v.vectorinstitute.ai -N
Where the last number in the URL is the GPU number (gpu029 in this case). The example provided above is for the vector cluster, change the variables accordingly for your environment
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vec_inf-0.5.0.tar.gz.
File metadata
- Download URL: vec_inf-0.5.0.tar.gz
- Upload date:
- Size: 337.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b944f12679de386bfd694ca9db96f1acda4ef15fff0a4018cb19342b6b23b80
|
|
| MD5 |
a9132614274119265813246dd6f89379
|
|
| BLAKE2b-256 |
691d686832d16045e246c355530d860e30a124fad926645c1b38d1f06590d635
|
File details
Details for the file vec_inf-0.5.0-py3-none-any.whl.
File metadata
- Download URL: vec_inf-0.5.0-py3-none-any.whl
- Upload date:
- Size: 26.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5a1d50cc21e3f8556b5bf01e8ede9e9230f010ddb7e66677b704080c2e32052
|
|
| MD5 |
86a510c72dfd9a3da2169cd0d96ec794
|
|
| BLAKE2b-256 |
a3d38dbd93225fb91468361e8ec085dd93d978cca450aecb49de126915c0a71c
|