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
Please refer to [Feature support through NxD Inference backend][feature-support-through-nxd-inference-backend] for features supported on AWS Neuron hardware
vLLM 0.3.3 onwards supports model inferencing and serving on AWS Trainium/Inferentia with Neuron SDK with continuous batching.
4
-
Paged Attention and Chunked Prefill are currently in development and will be available soon.
5
-
Data types currently supported in Neuron SDK are FP16 and BF16.
3
+
[AWS Neuron](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/) is the software development kit (SDK) used to run deep learning and
4
+
generative AI workloads on AWS Inferentia and AWS Trainium powered Amazon EC2 instances and UltraServers (Inf1, Inf2, Trn1, Trn2,
5
+
and Trn2 UltraServer). Both Trainium and Inferentia are powered by fully-independent heterogeneous compute-units called NeuronCores.
6
+
This tab describes how to set up your environment to run vLLM on Neuron.
6
7
7
8
!!! warning
8
9
There are no pre-built wheels or images for this device, so you must build vLLM from source.
@@ -11,58 +12,30 @@ Data types currently supported in Neuron SDK are FP16 and BF16.
11
12
# --8<-- [start:requirements]
12
13
13
14
- OS: Linux
14
-
- Python: 3.9 -- 3.11
15
-
-Accelerator: NeuronCore_v2 (in trn1/inf2 instances)
16
-
-Pytorch 2.0.1/2.1.1
17
-
- AWS Neuron SDK 2.16/2.17 (Verified on python 3.8)
15
+
- Python: 3.9 or newer
16
+
-Pytorch 2.5/2.6
17
+
-Accelerator: NeuronCore-v2 (in trn1/inf2 chips) or NeuronCore-v3 (in trn2 chips)
18
+
- AWS Neuron SDK 2.23
18
19
19
20
## Configure a new environment
20
21
21
-
### Launch Trn1/Inf2 instances
22
+
### Launch a Trn1/Trn2/Inf2 instance and verify Neuron dependencies
22
23
23
-
Here are the steps to launch trn1/inf2 instances, in order to install [PyTorch Neuron ("torch-neuronx") Setup on Ubuntu 22.04 LTS](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/general/setup/neuron-setup/pytorch/neuronx/ubuntu/torch-neuronx-ubuntu22.html).
24
+
The easiest way to launch a Trainium or Inferentia instance with pre-installed Neuron dependencies is to follow this
25
+
[quick start guide](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/general/setup/neuron-setup/multiframework/multi-framework-ubuntu22-neuron-dlami.html#setup-ubuntu22-multi-framework-dlami) using the Neuron Deep Learning AMI (Amazon machine image).
24
26
25
-
- Please follow the instructions at [launch an Amazon EC2 Instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html#ec2-launch-instance) to launch an instance. When choosing the instance type at the EC2 console, please make sure to select the correct instance type.
26
-
- To get more information about instances sizes and pricing see: [Trn1 web page](https://aws.amazon.com/ec2/instance-types/trn1/), [Inf2 web page](https://aws.amazon.com/ec2/instance-types/inf2/)
27
-
- Select Ubuntu Server 22.04 TLS AMI
28
-
- When launching a Trn1/Inf2, please adjust your primary EBS volume size to a minimum of 512GB.
29
27
- After launching the instance, follow the instructions in [Connect to your instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html) to connect to the instance
30
-
31
-
### Install drivers and tools
32
-
33
-
The installation of drivers and tools wouldn't be necessary, if [Deep Learning AMI Neuron](https://docs.aws.amazon.com/dlami/latest/devguide/appendix-ami-release-notes.html) is installed. In case the drivers and tools are not installed on the operating system, follow the steps below:
34
-
28
+
- Once inside your instance, activate the pre-installed virtual environment for inference by running
35
29
```console
36
-
# Configure Linux for Neuron repository updates
37
-
. /etc/os-release
38
-
sudo tee /etc/apt/sources.list.d/neuron.list > /dev/null <<EOF
39
-
deb https://apt.repos.neuron.amazonaws.com ${VERSION_CODENAME} main
Refer to the [NxD Inference Setup Guide](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/libraries/nxd-inference/nxdi-setup.html)
34
+
for alternative setup instructions including using Docker and manually installing dependencies.
62
35
63
-
# Add PATH
64
-
export PATH=/opt/aws/neuron/bin:$PATH
65
-
```
36
+
!!! note
37
+
NxD Inference is the default recommended backend to run inference on Neuron. If you are looking to use the legacy [transformers-neuronx](https://github.com/aws-neuron/transformers-neuronx)
38
+
library, refer to [Transformers NeuronX Setup](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/libraries/transformers-neuronx/setup/index.html).
66
39
67
40
# --8<-- [end:requirements]
68
41
# --8<-- [start:set-up-using-python]
@@ -75,60 +48,37 @@ Currently, there are no pre-built Neuron wheels.
75
48
# --8<-- [end:pre-built-wheels]
76
49
# --8<-- [start:build-wheel-from-source]
77
50
78
-
!!! note
79
-
The currently supported version of Pytorch for Neuron installs `triton` version `2.1.0`. This is incompatible with `vllm >= 0.5.3`. You may see an error `cannot import name 'default_dump_dir...`. To work around this, run a `pip install --upgrade triton==3.0.0` after installing the vLLM wheel.
80
-
81
-
Following instructions are applicable to Neuron SDK 2.16 and beyond.
82
-
83
-
#### Install transformers-neuronx and its dependencies
51
+
#### Install vLLM from source
84
52
85
-
[transformers-neuronx](https://github.com/aws-neuron/transformers-neuronx) will be the backend to support inference on trn1/inf2 instances.
86
-
Follow the steps below to install transformer-neuronx package and its dependencies.
53
+
Install vllm as follows:
87
54
88
55
```console
89
-
# Install Python venv
90
-
sudo apt-get install -y python3.10-venv g++
91
-
92
-
# Create Python venv
93
-
python3.10 -m venv aws_neuron_venv_pytorch
94
-
95
-
# Activate Python venv
96
-
source aws_neuron_venv_pytorch/bin/activate
97
-
98
-
# Install Jupyter notebook kernel
99
-
pip install ipykernel
100
-
python3.10 -m ipykernel install \
101
-
--user \
102
-
--name aws_neuron_venv_pytorch \
103
-
--display-name "Python (torch-neuronx)"
104
-
pip install jupyter notebook
105
-
pip install environment_kernels
106
-
107
-
# Set pip repository pointing to the Neuron repository
AWS Neuron maintains a [Github fork of vLLM](https://github.com/aws-neuron/upstreaming-to-vllm/tree/neuron-2.23-vllm-v0.7.2) at
63
+
[https://github.com/aws-neuron/upstreaming-to-vllm/tree/neuron-2.23-vllm-v0.7.2](https://github.com/aws-neuron/upstreaming-to-vllm/tree/neuron-2.23-vllm-v0.7.2), which contains several features in addition to what's
64
+
available on vLLM V0. Please utilize the AWS Fork for the following features:
65
+
66
+
- Llama-3.2 multi-modal support
67
+
- Multi-node distributed inference
121
68
122
-
Once neuronx-cc and transformers-neuronx packages are installed, we will be able to install vllm as follows:
69
+
Refer to [vLLM User Guide for NxD Inference](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/libraries/nxd-inference/developer_guides/vllm-user-guide.html)
70
+
for more details and usage examples.
71
+
72
+
To install the AWS Neuron fork, run the following:
The current vLLM and Neuron integration relies on either the `neuronx-distributed-inference` (preferred) or `transformers-neuronx` backend
105
+
to perform most of the heavy lifting which includes PyTorch model initialization, compilation, and runtime execution. Therefore, most
106
+
[features supported on Neuron](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/libraries/nxd-inference/developer_guides/feature-guide.html) are also available via the vLLM integration.
107
+
108
+
To configure NxD Inference features through the vLLM entrypoint, use the `override_neuron_config` setting. Provide the configs you want to override
109
+
as a dictionary (or JSON object when starting vLLM from the CLI). For example, to disable auto bucketing, include
to quantize and compile your model using NxD Inference, and then load the compiled artifacts into vLLM.
131
+
- Multi-LoRA serving: NxD Inference only supports loading of LoRA adapters at server startup. Dynamic loading of LoRA adapters at
132
+
runtime is not currently supported. Refer to [multi-lora example](https://github.com/aws-neuron/upstreaming-to-vllm/blob/neuron-2.23-vllm-v0.7.2/examples/offline_inference/neuron_multi_lora.py)
133
+
- Multi-modal support: multi-modal support is only available through the AWS Neuron fork. This feature has not been upstreamed
134
+
to vLLM main because NxD Inference currently relies on certain adaptations to the core vLLM logic to support this feature.
135
+
- Multi-node support: distributed inference across multiple Trainium/Inferentia instances is only supported on the AWS Neuron fork. Refer
136
+
to this [multi-node example](https://github.com/aws-neuron/upstreaming-to-vllm/tree/neuron-2.23-vllm-v0.7.2/examples/neuron/multi_node)
137
+
to run. Note that tensor parallelism (distributed inference across NeuronCores) is available in vLLM main.
138
+
- Known edge case bug in speculative decoding: An edge case failure may occur in speculative decoding when sequence length approaches
139
+
max model length (e.g. when requesting max tokens up to the max model length and ignoring eos). In this scenario, vLLM may attempt
140
+
to allocate an additional block to ensure there is enough memory for number of lookahead slots, but since we do not have good support
141
+
for paged attention, there isn't another Neuron block for vLLM to allocate. A workaround fix (to terminate 1 iteration early) is
142
+
implemented in the AWS Neuron fork but is not upstreamed to vLLM main as it modifies core vLLM logic.
143
+
144
+
145
+
### Environment variables
146
+
-`NEURON_COMPILED_ARTIFACTS`: set this environment variable to point to your pre-compiled model artifacts directory to avoid
147
+
compilation time upon server initialization. If this variable is not set, the Neuron module will perform compilation and save the
148
+
artifacts under `neuron-compiled-artifacts/{unique_hash}/` sub-directory in the model path. If this environment variable is set,
149
+
but the directory does not exist, or the contents are invalid, Neuron will also fallback to a new compilation and store the artifacts
150
+
under this specified path.
151
+
-`NEURON_CONTEXT_LENGTH_BUCKETS`: Bucket sizes for context encoding. (Only applicable to `transformers-neuronx` backend).
152
+
-`NEURON_TOKEN_GEN_BUCKETS`: Bucket sizes for token generation. (Only applicable to `transformers-neuronx` backend).
0 commit comments