Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2df915a145 | ||
|
|
aadc025849 | ||
|
|
8b4a49073d | ||
|
|
4e10641d69 | ||
|
|
6e8696c12a | ||
|
|
b49e81a75a | ||
|
|
65932f85e1 | ||
|
|
94840cfbbb | ||
|
|
ce47c41f4a | ||
|
|
c03ecc42fe | ||
|
|
ae56b9f43d | ||
|
|
891699be1e | ||
|
|
c28aa02576 | ||
|
|
eba20c0704 | ||
|
|
677a01e8f3 | ||
|
|
5cd12ba331 | ||
|
|
850c686538 | ||
|
|
de2876e659 | ||
|
|
d3ee3236c0 | ||
|
|
0781e93054 | ||
|
|
251e807012 | ||
|
|
29346769ed | ||
|
|
1420091588 | ||
|
|
d46adeaee9 | ||
|
|
5c0dca44bd | ||
|
|
cc301ac123 | ||
|
|
2ac6a0108f | ||
|
|
b1554ea10f | ||
|
|
0d794a3914 | ||
|
|
3dad3a754c | ||
|
|
44cef385df | ||
|
|
814f50af38 | ||
|
|
f3a530b7fe | ||
|
|
cdf78e7c89 | ||
|
|
ab40d9c9a8 | ||
|
|
3293245c81 | ||
|
|
5e1c8c8128 | ||
|
|
286d6ba702 | ||
|
|
8d734f8340 | ||
|
|
4fa4a8e0e6 | ||
|
|
39ce8a64c0 | ||
|
|
825ef25b60 | ||
|
|
1e9aeb6e8f | ||
|
|
e6172dddd4 | ||
|
|
21a1e138b4 | ||
|
|
a40e7803ee | ||
|
|
5e245793bc | ||
|
|
2111c9e7a5 | ||
|
|
0ae11ea6df | ||
|
|
7f46582949 | ||
|
|
571ef2b805 | ||
|
|
967eaba573 | ||
|
|
eb75a3ac03 | ||
|
|
9cb9336cf5 | ||
|
|
6a15a9e750 | ||
|
|
f023f57217 | ||
|
|
673597fd46 | ||
|
|
c50543ebd9 | ||
|
|
17a2d844ec | ||
|
|
3498e99b2f | ||
|
|
5da96ce9a6 | ||
|
|
e32626ca9d | ||
|
|
37d140aba6 | ||
|
|
66ed2a2a5f | ||
|
|
e846ecae9d | ||
|
|
9f066be620 | ||
|
|
8a010c3804 | ||
|
|
14cacd55fe | ||
|
|
e1b41795f7 | ||
|
|
0814d76654 | ||
|
|
f3534a4ea7 | ||
|
|
b61ea5ea46 | ||
|
|
0f8657e58d | ||
|
|
bd96b5e0de | ||
|
|
5bd6f3a75e | ||
|
|
a08d83f600 | ||
|
|
0e1e38326a | ||
|
|
c8458fef2b | ||
|
|
bad5ddd892 | ||
|
|
f19ce12ab0 | ||
|
|
1bb6f84541 | ||
|
|
30cb56a3df | ||
|
|
00add8707a | ||
|
|
ec7ea0b760 | ||
|
|
9f2cb7b1d0 | ||
|
|
4abe494635 | ||
|
|
4f61b04afe | ||
|
|
874379a0c5 | ||
|
|
f06a64d5b9 | ||
|
|
0a5b5bc095 | ||
|
|
2936e4d95d | ||
|
|
cee4e484d5 | ||
|
|
6160769996 | ||
|
|
d25b6f9628 | ||
|
|
c8ee100d80 | ||
|
|
fee8d8eee4 | ||
|
|
db7167d57f | ||
|
|
d91ccb866f | ||
|
|
36e9b670ee | ||
|
|
91167b873a | ||
|
|
819102cfd6 | ||
|
|
985bbf1cb5 | ||
|
|
6f5718f191 | ||
|
|
235d0d31d0 | ||
|
|
708f68d7f8 | ||
|
|
b42d45ce0f | ||
|
|
7221caceff | ||
|
|
a2d9535652 | ||
|
|
9129d0a252 | ||
|
|
6bcd9d7c67 | ||
|
|
b4204c612c | ||
|
|
7993818f5f | ||
|
|
e97917cc14 | ||
|
|
3549cf24d5 | ||
|
|
aed0408f19 | ||
|
|
e191149259 | ||
|
|
2941db0fb8 | ||
|
|
bfeb60c54e | ||
|
|
7b3fd05542 | ||
|
|
b0e7b575f3 | ||
|
|
4f5e0d37c4 | ||
|
|
a94ef66f71 | ||
|
|
45081e4037 | ||
|
|
fef8c81cb9 | ||
|
|
15b06bb687 | ||
|
|
2b5b8dfb61 | ||
|
|
8de10468dd | ||
|
|
b7051d37ca | ||
|
|
b1720a154d | ||
|
|
afa33a2875 | ||
|
|
068303ce8f | ||
|
|
3bbcf0021b | ||
|
|
dab8bad906 | ||
|
|
f4d7c75504 | ||
|
|
3adc9e3336 | ||
|
|
fd00a1ece3 | ||
|
|
664dd35782 | ||
|
|
370698442c | ||
|
|
3e2cd080a2 | ||
|
|
e7b340d73b | ||
|
|
46eee12819 | ||
|
|
12d6f0778e | ||
|
|
fa5556434c | ||
|
|
97726372c0 | ||
|
|
9fc8e1e54c | ||
|
|
4cebe66b36 | ||
|
|
368c5f87fb | ||
|
|
15cc7cd36f | ||
|
|
ef3c303743 | ||
|
|
584852f0f6 | ||
|
|
65454c024a | ||
|
|
f023e2e097 |
@@ -1,3 +0,0 @@
|
|||||||
MODEL_NAME="mistralai/Mistral-7B-Instruct-v0.1"
|
|
||||||
MODEL_BASE_PATH="./models"
|
|
||||||
DISABLE_LOG_STATS=0
|
|
||||||
@@ -19,32 +19,49 @@ jobs:
|
|||||||
|
|
||||||
- name: Check for new package version and update
|
- name: Check for new package version and update
|
||||||
run: |
|
run: |
|
||||||
# Get current version
|
echo "Fetching the current runpod version from requirements.txt..."
|
||||||
current_version=$(grep -oP 'runpod==\K[^"]+' ./builder/requirements.txt)
|
|
||||||
|
# Get current version, allowing both == and ~= in the search pattern
|
||||||
|
current_version=$(grep -oP 'runpod[~=]{1,2}\K[^"]+' ./builder/requirements.txt)
|
||||||
|
echo "Current version: $current_version"
|
||||||
|
|
||||||
# Get new version
|
# Extract major and minor from current version
|
||||||
|
current_major_minor=$(echo $current_version | cut -d. -f1,2)
|
||||||
|
echo "Current major.minor: $current_major_minor"
|
||||||
|
|
||||||
|
echo "Fetching the latest runpod version from PyPI..."
|
||||||
|
|
||||||
|
# Get new version from PyPI
|
||||||
new_version=$(curl -s https://pypi.org/pypi/runpod/json | jq -r .info.version)
|
new_version=$(curl -s https://pypi.org/pypi/runpod/json | jq -r .info.version)
|
||||||
echo "NEW_VERSION_ENV=$new_version" >> $GITHUB_ENV
|
echo "NEW_VERSION_ENV=$new_version" >> $GITHUB_ENV
|
||||||
|
echo "New version: $new_version"
|
||||||
|
|
||||||
|
# Extract major and minor from new version
|
||||||
|
new_major_minor=$(echo $new_version | cut -d. -f1,2)
|
||||||
|
echo "New major.minor: $new_major_minor"
|
||||||
|
|
||||||
if [ -z "$new_version" ]; then
|
if [ -z "$new_version" ]; then
|
||||||
echo "Failed to fetch the new version."
|
echo "ERROR: Failed to fetch the new version from PyPI."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the version is already up-to-date
|
# Check if the major or minor version is different
|
||||||
if [ "$current_version" = "$new_version" ]; then
|
if [ "$current_major_minor" = "$new_major_minor" ]; then
|
||||||
echo "The package version is already up-to-date."
|
echo "No update needed. The new version ($new_major_minor) is within the allowed range (~= $current_major_minor)."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update requirements.txt
|
echo "New major/minor detected ($new_major_minor). Updating requirements.txt..."
|
||||||
sed -i "s/runpod==.*/runpod==$new_version/" ./builder/requirements.txt
|
|
||||||
|
# Update requirements.txt, preserving the existing constraint type (~= or ==)
|
||||||
|
sed -i "s/runpod[~=][^ ]*/runpod~=$new_version/" ./builder/requirements.txt
|
||||||
|
echo "requirements.txt has been updated."
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v3
|
uses: peter-evans/create-pull-request@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
commit-message: Update package version
|
commit-message: Update runpod package version
|
||||||
title: Update runpod package version
|
title: Update runpod package version
|
||||||
body: The package version has been updated to ${{ env.NEW_VERSION_ENV }}
|
body: The package version has been updated to ${{ env.NEW_VERSION_ENV }}
|
||||||
branch: runpod-package-update
|
branch: runpod-package-update
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
name: CD | Docker-Build-Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- "main"
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
image_tag:
|
|
||||||
description: "Docker Image Tag"
|
|
||||||
required: false
|
|
||||||
default: "dev"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker-build:
|
|
||||||
runs-on: DO
|
|
||||||
# DO is a custom runner deployed on DigitalOcean, only available for workflows under the runpod-workers organization.
|
|
||||||
# If you would like to use this workflow, you can replace DO with ubuntu-latest or any other runner.
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v2
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
# Build and push step
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v4
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
tags: ${{ vars.DOCKERHUB_REPO }}/${{ vars.DOCKERHUB_IMG }}:${{ (github.event_name == 'release' && github.event.release.tag_name) || (github.event_name == 'workflow_dispatch' && github.event.inputs.image_tag) || 'dev' }}
|
|
||||||
+2
-1
@@ -2,4 +2,5 @@
|
|||||||
runpod.toml
|
runpod.toml
|
||||||
*.pyc
|
*.pyc
|
||||||
.env
|
.env
|
||||||
test/*
|
test/*
|
||||||
|
vllm-base/vllm-*
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "vllm-base-image/vllm"]
|
||||||
|
path = vllm-base-image/vllm
|
||||||
|
url = https://github.com/runpod/vllm-fork-for-sls-worker.git
|
||||||
+35
-34
@@ -1,49 +1,50 @@
|
|||||||
# Base image - Set default to CUDA 11.8
|
FROM nvidia/cuda:12.1.0-base-ubuntu22.04
|
||||||
ARG WORKER_CUDA_VERSION=11.8
|
|
||||||
FROM runpod/base:0.4.2-cuda${WORKER_CUDA_VERSION}.0 as builder
|
|
||||||
|
|
||||||
ARG WORKER_CUDA_VERSION=11.8 # Required duplicate to keep in scope
|
RUN apt-get update -y \
|
||||||
|
&& apt-get install -y python3-pip
|
||||||
# Set Environment Variables
|
|
||||||
ENV WORKER_CUDA_VERSION=${WORKER_CUDA_VERSION} \
|
|
||||||
HF_DATASETS_CACHE="/runpod-volume/huggingface-cache/datasets" \
|
|
||||||
HUGGINGFACE_HUB_CACHE="/runpod-volume/huggingface-cache/hub" \
|
|
||||||
TRANSFORMERS_CACHE="/runpod-volume/huggingface-cache/hub" \
|
|
||||||
HF_TRANSFER=1
|
|
||||||
|
|
||||||
|
RUN ldconfig /usr/local/cuda-12.1/compat/
|
||||||
|
|
||||||
# Install Python dependencies
|
# Install Python dependencies
|
||||||
COPY builder/requirements.txt /requirements.txt
|
COPY builder/requirements.txt /requirements.txt
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||||
python3.11 -m pip install --upgrade pip && \
|
python3 -m pip install --upgrade pip && \
|
||||||
python3.11 -m pip install --upgrade -r /requirements.txt && \
|
python3 -m pip install --upgrade -r /requirements.txt
|
||||||
rm /requirements.txt
|
|
||||||
|
|
||||||
# Install torch and vllm based on CUDA version
|
# Install vLLM (switching back to pip installs since issues that required building fork are fixed and space optimization is not as important since caching) and FlashInfer
|
||||||
RUN if [[ "${WORKER_CUDA_VERSION}" == 11.8* ]]; then \
|
RUN python3 -m pip install vllm==0.6.4 && \
|
||||||
python3.11 -m pip install -U --force-reinstall torch==2.1.2 xformers==0.0.23.post1 --index-url https://download.pytorch.org/whl/cu118; \
|
python3 -m pip install flashinfer -i https://flashinfer.ai/whl/cu121/torch2.3
|
||||||
python3.11 -m pip install -e git+https://github.com/runpod/vllm-fork-for-sls-worker.git@cuda-11.8#egg=vllm; \
|
|
||||||
else \
|
|
||||||
python3.11 -m pip install -e git+https://github.com/runpod/vllm-fork-for-sls-worker.git#egg=vllm; \
|
|
||||||
fi && \
|
|
||||||
rm -rf /root/.cache/pip
|
|
||||||
|
|
||||||
# Add source files
|
|
||||||
COPY src .
|
|
||||||
|
|
||||||
# Setup for Option 2: Building the Image with the Model included
|
# Setup for Option 2: Building the Image with the Model included
|
||||||
ARG MODEL_NAME=""
|
ARG MODEL_NAME=""
|
||||||
ARG MODEL_BASE_PATH="/runpod-volume/"
|
ARG TOKENIZER_NAME=""
|
||||||
ARG HF_TOKEN=""
|
ARG BASE_PATH="/runpod-volume"
|
||||||
ARG QUANTIZATION=""
|
ARG QUANTIZATION=""
|
||||||
RUN if [ -n "$MODEL_NAME" ]; then \
|
ARG MODEL_REVISION=""
|
||||||
export MODEL_BASE_PATH=$MODEL_BASE_PATH && \
|
ARG TOKENIZER_REVISION=""
|
||||||
export MODEL_NAME=$MODEL_NAME && \
|
|
||||||
python3.11 /download_model.py --model $MODEL_NAME; \
|
ENV MODEL_NAME=$MODEL_NAME \
|
||||||
|
MODEL_REVISION=$MODEL_REVISION \
|
||||||
|
TOKENIZER_NAME=$TOKENIZER_NAME \
|
||||||
|
TOKENIZER_REVISION=$TOKENIZER_REVISION \
|
||||||
|
BASE_PATH=$BASE_PATH \
|
||||||
|
QUANTIZATION=$QUANTIZATION \
|
||||||
|
HF_DATASETS_CACHE="${BASE_PATH}/huggingface-cache/datasets" \
|
||||||
|
HUGGINGFACE_HUB_CACHE="${BASE_PATH}/huggingface-cache/hub" \
|
||||||
|
HF_HOME="${BASE_PATH}/huggingface-cache/hub" \
|
||||||
|
HF_HUB_ENABLE_HF_TRANSFER=1
|
||||||
|
|
||||||
|
ENV PYTHONPATH="/:/vllm-workspace"
|
||||||
|
|
||||||
|
|
||||||
|
COPY src /src
|
||||||
|
RUN --mount=type=secret,id=HF_TOKEN,required=false \
|
||||||
|
if [ -f /run/secrets/HF_TOKEN ]; then \
|
||||||
|
export HF_TOKEN=$(cat /run/secrets/HF_TOKEN); \
|
||||||
fi && \
|
fi && \
|
||||||
if [ -n "$QUANTIZATION" ]; then \
|
if [ -n "$MODEL_NAME" ]; then \
|
||||||
export QUANTIZATION=$QUANTIZATION; \
|
python3 /src/download_model.py; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start the handler
|
# Start the handler
|
||||||
CMD ["python3.11", "/handler.py"]
|
CMD ["python3", "/src/handler.py"]
|
||||||
@@ -1,137 +1,603 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
<h1>vLLM 0.2.6 Endpoint | Serverless Worker </h1>
|
# OpenAI-Compatible vLLM Serverless Endpoint Worker
|
||||||
|
Deploy OpenAI-Compatible Blazing-Fast LLM Endpoints powered by the [vLLM](https://github.com/vllm-project/vllm) Inference Engine on RunPod Serverless with just a few clicks.
|
||||||
|
<!--
|
||||||
|

|
||||||
|

|
||||||
|
\
|
||||||
|
 -->
|
||||||
|
<!--
|
||||||
|
 -->
|
||||||
|
|
||||||
[](https://github.com/runpod-workers/worker-vllm/actions/workflows/docker-build-release.yml)
|
|
||||||
|
|
||||||
🚀 | This serverless worker utilizes vLLM behind the scenes and is integrated into RunPod's serverless environment. It supports dynamic auto-scaling using the built-in RunPod autoscaling feature.
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Setting up the Serverless Worker
|
# News:
|
||||||
|
|
||||||
|
### 1. UI for Deploying vLLM Worker on RunPod console:
|
||||||
|

|
||||||
|
|
||||||
|
### 2. Worker vLLM `v1.6.0` with vLLM `0.6.3` now available under `stable` tags
|
||||||
|
|
||||||
|
Update v1.6.0 is now available, use the image tag `runpod/worker-v1-vllm:v1.6.0stable-cuda12.1.0`.
|
||||||
|
|
||||||
|
### 3. OpenAI-Compatible [Embedding Worker](https://github.com/runpod-workers/worker-infinity-embedding) Released
|
||||||
|
Deploy your own OpenAI-compatible Serverless Endpoint on RunPod with multiple embedding models and fast inference for RAG and more!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### 4. Caching Accross RunPod Machines
|
||||||
|
Worker vLLM is now cached on all RunPod machines, resulting in near-instant deployment! Previously, downloading and extracting the image took 3-5 minutes on average.
|
||||||
|
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
- [Setting up the Serverless Worker](#setting-up-the-serverless-worker)
|
||||||
|
- [Option 1: Deploy Any Model Using Pre-Built Docker Image **[RECOMMENDED]**](#option-1-deploy-any-model-using-pre-built-docker-image-recommended)
|
||||||
|
- [Prerequisites](#prerequisites)
|
||||||
|
- [Environment Variables](#environment-variables)
|
||||||
|
- [LLM Settings](#llm-settings)
|
||||||
|
- [Tokenizer Settings](#tokenizer-settings)
|
||||||
|
- [Tensor Parallelism (Multi-GPU) Settings](#tensor-parallelism-multi-gpu-settings)
|
||||||
|
- [System Settings](#system-settings)
|
||||||
|
- [Streaming Batch Size](#streaming-batch-size)
|
||||||
|
- [OpenAI Settings](#openai-settings)
|
||||||
|
- [Serverless Settings](#serverless-settings)
|
||||||
|
- [Option 2: Build Docker Image with Model Inside](#option-2-build-docker-image-with-model-inside)
|
||||||
|
- [Prerequisites](#prerequisites-1)
|
||||||
|
- [Arguments](#arguments)
|
||||||
|
- [Example: Building an image with OpenChat-3.5](#example-building-an-image-with-openchat-35)
|
||||||
|
- [(Optional) Including Huggingface Token](#optional-including-huggingface-token)
|
||||||
|
- [Compatible Model Architectures](#compatible-model-architectures)
|
||||||
|
- [Usage: OpenAI Compatibility](#usage-openai-compatibility)
|
||||||
|
- [Modifying your OpenAI Codebase to use your deployed vLLM Worker](#modifying-your-openai-codebase-to-use-your-deployed-vllm-worker)
|
||||||
|
- [OpenAI Request Input Parameters](#openai-request-input-parameters)
|
||||||
|
- [Chat Completions](#chat-completions)
|
||||||
|
- [Examples: Using your RunPod endpoint with OpenAI](#examples-using-your-runpod-endpoint-with-openai)
|
||||||
|
- [Usage: standard](#non-openai-usage)
|
||||||
|
- [Input Request Parameters](#input-request-parameters)
|
||||||
|
- [Text Input Formats](#text-input-formats)
|
||||||
|
- [Sampling Parameters](#sampling-parameters)
|
||||||
|
- [Worker Config](#worker-config)
|
||||||
|
- [Writing your worker-config.json](#writing-your-worker-configjson)
|
||||||
|
- [Example of schema](#example-of-schema)
|
||||||
|
- [Example of versions](#example-of-versions)
|
||||||
|
|
||||||
|
# Setting up the Serverless Worker
|
||||||
|
|
||||||
|
### Option 1: Deploy Any Model Using Pre-Built Docker Image [Recommended]
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> You can now deploy from the dedicated UI on the RunPod console with all of the settings and choices listed.
|
||||||
|
> Try now by accessing in Explore or Serverless pages on the RunPod console!
|
||||||
|
|
||||||
|
|
||||||
### Option 1: Deploy Any Model Using Pre-Built Docker Image
|
|
||||||
We now offer a pre-built Docker Image for the vLLM Worker that you can configure entirely with Environment Variables when creating the RunPod Serverless Endpoint:
|
We now offer a pre-built Docker Image for the vLLM Worker that you can configure entirely with Environment Variables when creating the RunPod Serverless Endpoint:
|
||||||
|
|
||||||
<div align="center">
|
---
|
||||||
|
|
||||||
```runpod/worker-vllm:dev```
|
## RunPod Worker Images
|
||||||
|
|
||||||
</div>
|
Below is a summary of the available RunPod Worker images, categorized by image stability and CUDA version compatibility.
|
||||||
|
|
||||||
#### Environment Variables
|
| CUDA Version | Stable Image Tag | Development Image Tag | Note |
|
||||||
- **Required**:
|
|--------------|-----------------------------------|-----------------------------------|----------------------------------------------------------------------|
|
||||||
- `MODEL_NAME`: Hugging Face Model Repository (e.g., `openchat/openchat-3.5-1210`).
|
| 12.1.0 | `runpod/worker-v1-vllm:v1.6.0stable-cuda12.1.0` | `runpod/worker-v1-vllm:v1.6.0dev-cuda12.1.0` | When creating an Endpoint, select CUDA Version 12.3, 12.2 and 12.1 in the filter. |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### Prerequisites
|
||||||
|
- RunPod Account
|
||||||
|
|
||||||
|
#### Environment Variables/Settings
|
||||||
|
> Note: `0` is equivalent to `False` and `1` is equivalent to `True` for boolean as int values.
|
||||||
|
|
||||||
|
| `Name` | `Default` | `Type/Choices` | `Description` |
|
||||||
|
|-------------------------------------------|-----------------------|--------------------------------------------|---------------|
|
||||||
|
| `MODEL_NAME` | 'facebook/opt-125m' | `str` | Name or path of the Hugging Face model to use. |
|
||||||
|
| `TOKENIZER` | None | `str` | Name or path of the Hugging Face tokenizer to use. |
|
||||||
|
| `SKIP_TOKENIZER_INIT` | False | `bool` | Skip initialization of tokenizer and detokenizer. |
|
||||||
|
| `TOKENIZER_MODE` | 'auto' | ['auto', 'slow'] | The tokenizer mode. |
|
||||||
|
| `TRUST_REMOTE_CODE` | `False` | `bool` | Trust remote code from Hugging Face. |
|
||||||
|
| `DOWNLOAD_DIR` | None | `str` | Directory to download and load the weights. |
|
||||||
|
| `LOAD_FORMAT` | 'auto' | `str` | The format of the model weights to load. |
|
||||||
|
| `HF_TOKEN` | - | `str` | Hugging Face token for private and gated models.|
|
||||||
|
| `DTYPE` | 'auto' | ['auto', 'half', 'float16', 'bfloat16', 'float', 'float32'] | Data type for model weights and activations. |
|
||||||
|
| `KV_CACHE_DTYPE` | 'auto' | ['auto', 'fp8'] | Data type for KV cache storage. |
|
||||||
|
| `QUANTIZATION_PARAM_PATH` | None | `str` | Path to the JSON file containing the KV cache scaling factors. |
|
||||||
|
| `MAX_MODEL_LEN` | None | `int` | Model context length. |
|
||||||
|
| `GUIDED_DECODING_BACKEND` | 'outlines' | ['outlines', 'lm-format-enforcer'] | Which engine will be used for guided decoding by default. |
|
||||||
|
| `DISTRIBUTED_EXECUTOR_BACKEND` | None | ['ray', 'mp'] | Backend to use for distributed serving. |
|
||||||
|
| `WORKER_USE_RAY` | False | `bool` | Deprecated, use --distributed-executor-backend=ray. |
|
||||||
|
| `PIPELINE_PARALLEL_SIZE` | 1 | `int` | Number of pipeline stages. |
|
||||||
|
| `TENSOR_PARALLEL_SIZE` | 1 | `int` | Number of tensor parallel replicas. |
|
||||||
|
| `MAX_PARALLEL_LOADING_WORKERS` | None | `int` | Load model sequentially in multiple batches. |
|
||||||
|
| `RAY_WORKERS_USE_NSIGHT` | False | `bool` | If specified, use nsight to profile Ray workers. |
|
||||||
|
| `ENABLE_PREFIX_CACHING` | False | `bool` | Enables automatic prefix caching. |
|
||||||
|
| `DISABLE_SLIDING_WINDOW` | False | `bool` | Disables sliding window, capping to sliding window size. |
|
||||||
|
| `USE_V2_BLOCK_MANAGER` | False | `bool` | Use BlockSpaceMangerV2. |
|
||||||
|
| `NUM_LOOKAHEAD_SLOTS` | 0 | `int` | Experimental scheduling config necessary for speculative decoding. |
|
||||||
|
| `SEED` | 0 | `int` | Random seed for operations. |
|
||||||
|
| `NUM_GPU_BLOCKS_OVERRIDE` | None | `int` | If specified, ignore GPU profiling result and use this number of GPU blocks. |
|
||||||
|
| `MAX_NUM_BATCHED_TOKENS` | None | `int` | Maximum number of batched tokens per iteration. |
|
||||||
|
| `MAX_NUM_SEQS` | 256 | `int` | Maximum number of sequences per iteration. |
|
||||||
|
| `MAX_LOGPROBS` | 20 | `int` | Max number of log probs to return when logprobs is specified in SamplingParams. |
|
||||||
|
| `DISABLE_LOG_STATS` | False | `bool` | Disable logging statistics. |
|
||||||
|
| `QUANTIZATION` | None | ['awq', 'squeezellm', 'gptq'] | Method used to quantize the weights. |
|
||||||
|
| `ROPE_SCALING` | None | `dict` | RoPE scaling configuration in JSON format. |
|
||||||
|
| `ROPE_THETA` | None | `float` | RoPE theta. Use with rope_scaling. |
|
||||||
|
| `TOKENIZER_POOL_SIZE` | 0 | `int` | Size of tokenizer pool to use for asynchronous tokenization. |
|
||||||
|
| `TOKENIZER_POOL_TYPE` | 'ray' | `str` | Type of tokenizer pool to use for asynchronous tokenization. |
|
||||||
|
| `TOKENIZER_POOL_EXTRA_CONFIG` | None | `dict` | Extra config for tokenizer pool. |
|
||||||
|
| `ENABLE_LORA` | False | `bool` | If True, enable handling of LoRA adapters. |
|
||||||
|
| `MAX_LORAS` | 1 | `int` | Max number of LoRAs in a single batch. |
|
||||||
|
| `MAX_LORA_RANK` | 16 | `int` | Max LoRA rank. |
|
||||||
|
| `LORA_EXTRA_VOCAB_SIZE` | 256 | `int` | Maximum size of extra vocabulary for LoRA adapters. |
|
||||||
|
| `LORA_DTYPE` | 'auto' | ['auto', 'float16', 'bfloat16', 'float32'] | Data type for LoRA. |
|
||||||
|
| `LONG_LORA_SCALING_FACTORS` | None | `tuple` | Specify multiple scaling factors for LoRA adapters. |
|
||||||
|
| `MAX_CPU_LORAS` | None | `int` | Maximum number of LoRAs to store in CPU memory. |
|
||||||
|
| `FULLY_SHARDED_LORAS` | False | `bool` | Enable fully sharded LoRA layers. |
|
||||||
|
| `SCHEDULER_DELAY_FACTOR` | 0.0 | `float` | Apply a delay before scheduling next prompt. |
|
||||||
|
| `ENABLE_CHUNKED_PREFILL` | False | `bool` | Enable chunked prefill requests. |
|
||||||
|
| `SPECULATIVE_MODEL` | None | `str` | The name of the draft model to be used in speculative decoding. |
|
||||||
|
| `NUM_SPECULATIVE_TOKENS` | None | `int` | The number of speculative tokens to sample from the draft model. |
|
||||||
|
| `SPECULATIVE_DRAFT_TENSOR_PARALLEL_SIZE` | None | `int` | Number of tensor parallel replicas for the draft model. |
|
||||||
|
| `SPECULATIVE_MAX_MODEL_LEN` | None | `int` | The maximum sequence length supported by the draft model. |
|
||||||
|
| `SPECULATIVE_DISABLE_BY_BATCH_SIZE` | None | `int` | Disable speculative decoding if the number of enqueue requests is larger than this value. |
|
||||||
|
| `NGRAM_PROMPT_LOOKUP_MAX` | None | `int` | Max size of window for ngram prompt lookup in speculative decoding. |
|
||||||
|
| `NGRAM_PROMPT_LOOKUP_MIN` | None | `int` | Min size of window for ngram prompt lookup in speculative decoding. |
|
||||||
|
| `SPEC_DECODING_ACCEPTANCE_METHOD` | 'rejection_sampler' | ['rejection_sampler', 'typical_acceptance_sampler'] | Specify the acceptance method for draft token verification in speculative decoding. |
|
||||||
|
| `TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_THRESHOLD` | None | `float` | Set the lower bound threshold for the posterior probability of a token to be accepted. |
|
||||||
|
| `TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_ALPHA` | None | `float` | A scaling factor for the entropy-based threshold for token acceptance. |
|
||||||
|
| `MODEL_LOADER_EXTRA_CONFIG` | None | `dict` | Extra config for model loader. |
|
||||||
|
| `PREEMPTION_MODE` | None | `str` | If 'recompute', the engine performs preemption-aware recomputation. If 'save', the engine saves activations into the CPU memory as preemption happens. |
|
||||||
|
| `PREEMPTION_CHECK_PERIOD` | 1.0 | `float` | How frequently the engine checks if a preemption happens. |
|
||||||
|
| `PREEMPTION_CPU_CAPACITY` | 2 | `float` | The percentage of CPU memory used for the saved activations. |
|
||||||
|
| `DISABLE_LOGGING_REQUEST` | False | `bool` | Disable logging requests. |
|
||||||
|
| `MAX_LOG_LEN` | None | `int` | Max number of prompt characters or prompt ID numbers being printed in log. |
|
||||||
|
**Tokenizer Settings**
|
||||||
|
| `TOKENIZER_NAME` | `None` | `str` |Tokenizer repository to use a different tokenizer than the model's default. |
|
||||||
|
| `TOKENIZER_REVISION` | `None` | `str` |Tokenizer revision to load. |
|
||||||
|
| `CUSTOM_CHAT_TEMPLATE` | `None` | `str` of single-line jinja template |Custom chat jinja template. [More Info](https://huggingface.co/docs/transformers/chat_templating) |
|
||||||
|
**System, GPU, and Tensor Parallelism(Multi-GPU) Settings**
|
||||||
|
| `GPU_MEMORY_UTILIZATION` | `0.95` | `float` |Sets GPU VRAM utilization. |
|
||||||
|
| `MAX_PARALLEL_LOADING_WORKERS` | `None` | `int` |Load model sequentially in multiple batches, to avoid RAM OOM when using tensor parallel and large models. |
|
||||||
|
| `BLOCK_SIZE` | `16` | `8`, `16`, `32` |Token block size for contiguous chunks of tokens. |
|
||||||
|
| `SWAP_SPACE` | `4` | `int` |CPU swap space size (GiB) per GPU. |
|
||||||
|
| `ENFORCE_EAGER` | False | `bool` |Always use eager-mode PyTorch. If False(`0`), will use eager mode and CUDA graph in hybrid for maximal performance and flexibility. |
|
||||||
|
| `MAX_SEQ_LEN_TO_CAPTURE` | `8192` | `int` |Maximum context length covered by CUDA graphs. When a sequence has context length larger than this, we fall back to eager mode.|
|
||||||
|
| `DISABLE_CUSTOM_ALL_REDUCE` | `0` | `int` |Enables or disables custom all reduce. |
|
||||||
|
**Streaming Batch Size Settings**:
|
||||||
|
| `DEFAULT_BATCH_SIZE` | `50` | `int` |Default and Maximum batch size for token streaming to reduce HTTP calls. |
|
||||||
|
| `DEFAULT_MIN_BATCH_SIZE` | `1` | `int` |Batch size for the first request, which will be multiplied by the growth factor every subsequent request. |
|
||||||
|
| `DEFAULT_BATCH_SIZE_GROWTH_FACTOR` | `3` | `float` |Growth factor for dynamic batch size. |
|
||||||
|
The way this works is that the first request will have a batch size of `DEFAULT_MIN_BATCH_SIZE`, and each subsequent request will have a batch size of `previous_batch_size * DEFAULT_BATCH_SIZE_GROWTH_FACTOR`. This will continue until the batch size reaches `DEFAULT_BATCH_SIZE`. E.g. for the default values, the batch sizes will be `1, 3, 9, 27, 50, 50, 50, ...`. You can also specify this per request, with inputs `max_batch_size`, `min_batch_size`, and `batch_size_growth_factor`. This has nothing to do with vLLM's internal batching, but rather the number of tokens sent in each HTTP request from the worker |
|
||||||
|
**OpenAI Settings**
|
||||||
|
| `RAW_OPENAI_OUTPUT` | `1` | boolean as `int` |Enables raw OpenAI SSE format string output when streaming. **Required** to be enabled (which it is by default) for OpenAI compatibility. |
|
||||||
|
| `OPENAI_SERVED_MODEL_NAME_OVERRIDE` | `None` | `str` |Overrides the name of the served model from model repo/path to specified name, which you will then be able to use the value for the `model` parameter when making OpenAI requests |
|
||||||
|
| `OPENAI_RESPONSE_ROLE` | `assistant` | `str` |Role of the LLM's Response in OpenAI Chat Completions. |
|
||||||
|
**Serverless Settings**
|
||||||
|
| `MAX_CONCURRENCY` | `300` | `int` |Max concurrent requests per worker. vLLM has an internal queue, so you don't have to worry about limiting by VRAM, this is for improving scaling/load balancing efficiency |
|
||||||
|
| `DISABLE_LOG_STATS` | False | `bool` |Enables or disables vLLM stats logging. |
|
||||||
|
| `DISABLE_LOG_REQUESTS` | False | `bool` |Enables or disables vLLM request logging. |
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> If you are facing issues when using Mixtral 8x7B, Quantized models, or handling unusual models/architectures, try setting `TRUST_REMOTE_CODE` to `1`.
|
||||||
|
|
||||||
- **Optional**:
|
|
||||||
- `MAX_MODEL_LENGTH`: Maximum number of tokens for the engine to be able to handle. (default: maximum supported by the model)
|
|
||||||
- `MODEL_BASE_PATH`: Model storage directory (default: `/runpod-volume`).
|
|
||||||
- `HF_TOKEN`: Hugging Face token for private and gated models (e.g., Llama, Falcon).
|
|
||||||
- `NUM_GPU_SHARD`: Number of GPUs to split the model across. (default: `1`)
|
|
||||||
- `QUANTIZATION`: AWQ (`awq`), SqueezeLLM (`squeezellm`) or GPTQ (`gptq`) Quantization. The specified Model Repo must be of a quantized model. (default: `None`)
|
|
||||||
- `TRUST_REMOTE_CODE`: Whether to trust remote code with Hugging Face. (default: `0`)
|
|
||||||
- `MAX_CONCURRENCY`: Max concurrent requests. (default: `100`)
|
|
||||||
- `DEFAULT_BATCH_SIZE`: Token streaming batch size (default: `30`). This reduces the number of HTTP calls, increasing speed 8-10x vs non-batching, matching non-streaming performance.
|
|
||||||
- `DISABLE_LOG_STATS`: Enable (`0`) or disable (`1`) vLLM stats logging.
|
|
||||||
- `DISABLE_LOG_REQUESTS`: Enable (`0`) or disable (`1`) request logging.
|
|
||||||
|
|
||||||
### Option 2: Build Docker Image with Model Inside
|
### Option 2: Build Docker Image with Model Inside
|
||||||
[!WARNING] If you are getting errors while building the image, try adding `ENV MAX_JOBS` to the Dockerfile and increase Docker memory limit to at least 25GB.
|
To build an image with the model baked in, you must specify the following docker arguments when building the image.
|
||||||
|
|
||||||
To build an image with the model baked in, you must specify the following docker arguments when building the image:
|
#### Prerequisites
|
||||||
|
- RunPod Account
|
||||||
|
- Docker
|
||||||
|
|
||||||
#### Arguments:
|
#### Arguments:
|
||||||
- **Required**
|
- **Required**
|
||||||
- `MODEL_NAME`
|
- `MODEL_NAME`
|
||||||
- **Optional**
|
- **Optional**
|
||||||
- `MODEL_BASE_PATH`: Defaults to `/runpod-volume` for network storage. Use `/models` or for local container storage.
|
- `MODEL_REVISION`: Model revision to load (default: `main`).
|
||||||
|
- `BASE_PATH`: Storage directory where huggingface cache and model will be located. (default: `/runpod-volume`, which will utilize network storage if you attach it or create a local directory within the image if you don't. If your intention is to bake the model into the image, you should set this to something like `/models` to make sure there are no issues if you were to accidentally attach network storage.)
|
||||||
- `QUANTIZATION`
|
- `QUANTIZATION`
|
||||||
- `HF_TOKEN`
|
- `WORKER_CUDA_VERSION`: `12.1.0` (`12.1.0` is recommended for optimal performance).
|
||||||
- `WORKER_CUDA_VERSION`: `11.8` or `12.1` (default: `11.8` due to a small amount of workers not having CUDA 12.1 support yet. `12.1` is recommended for optimal performance).
|
- `TOKENIZER_NAME`: Tokenizer repository if you would like to use a different tokenizer than the one that comes with the model. (default: `None`, which uses the model's tokenizer)
|
||||||
|
- `TOKENIZER_REVISION`: Tokenizer revision to load (default: `main`).
|
||||||
|
|
||||||
|
For the remaining settings, you may apply them as environment variables when running the container. Supported environment variables are listed in the [Environment Variables](#environment-variables) section.
|
||||||
|
|
||||||
#### Example: Building an image with OpenChat-3.5
|
#### Example: Building an image with OpenChat-3.5
|
||||||
`sudo docker build -t username/image:tag --build-arg MODEL_NAME="openchat/openchat_3.5" --build-arg MODEL_BASE_PATH="/models" .`
|
```bash
|
||||||
|
sudo docker build -t username/image:tag --build-arg MODEL_NAME="openchat/openchat_3.5" --build-arg BASE_PATH="/models" .
|
||||||
|
```
|
||||||
|
|
||||||
|
##### (Optional) Including Huggingface Token
|
||||||
|
If the model you would like to deploy is private or gated, you will need to include it during build time as a Docker secret, which will protect it from being exposed in the image and on DockerHub.
|
||||||
|
1. Enable Docker BuildKit (required for secrets).
|
||||||
|
```bash
|
||||||
|
export DOCKER_BUILDKIT=1
|
||||||
|
```
|
||||||
|
2. Export your Hugging Face token as an environment variable
|
||||||
|
```bash
|
||||||
|
export HF_TOKEN="your_token_here"
|
||||||
|
```
|
||||||
|
2. Add the token as a secret when building
|
||||||
|
```bash
|
||||||
|
docker build -t username/image:tag --secret id=HF_TOKEN --build-arg MODEL_NAME="openchat/openchat_3.5" .
|
||||||
|
```
|
||||||
|
|
||||||
|
## Compatible Model Architectures
|
||||||
|
Below are all supported model architectures (and examples of each) that you can deploy using the vLLM Worker. You can deploy **any model on HuggingFace**, as long as its base architecture is one of the following:
|
||||||
|
|
||||||
### Compatible Models
|
|
||||||
- LLaMA & LLaMA-2 (`meta-llama/Llama-2-70b-hf`, `lmsys/vicuna-13b-v1.3`, `young-geng/koala`, `openlm-research/open_llama_13b`, etc.)
|
|
||||||
- Mistral (`mistralai/Mistral-7B-v0.1`, `mistralai/Mistral-7B-Instruct-v0.1`, etc.)
|
|
||||||
- Mixtral (`mistralai/Mixtral-8x7B-v0.1`, `mistralai/Mixtral-8x7B-Instruct-v0.1`, etc.)
|
|
||||||
- Aquila & Aquila2 (`BAAI/AquilaChat2-7B`, `BAAI/AquilaChat2-34B`, `BAAI/Aquila-7B`, `BAAI/AquilaChat-7B`, etc.)
|
- Aquila & Aquila2 (`BAAI/AquilaChat2-7B`, `BAAI/AquilaChat2-34B`, `BAAI/Aquila-7B`, `BAAI/AquilaChat-7B`, etc.)
|
||||||
- Baichuan & Baichuan2 (`baichuan-inc/Baichuan2-13B-Chat`, `baichuan-inc/Baichuan-7B`, etc.)
|
- Baichuan & Baichuan2 (`baichuan-inc/Baichuan2-13B-Chat`, `baichuan-inc/Baichuan-7B`, etc.)
|
||||||
- BLOOM (`bigscience/bloom`, `bigscience/bloomz`, etc.)
|
- BLOOM (`bigscience/bloom`, `bigscience/bloomz`, etc.)
|
||||||
- ChatGLM (`THUDM/chatglm2-6b`, `THUDM/chatglm3-6b`, etc.)
|
- ChatGLM (`THUDM/chatglm2-6b`, `THUDM/chatglm3-6b`, etc.)
|
||||||
|
- Command-R (`CohereForAI/c4ai-command-r-v01`, etc.)
|
||||||
|
- DBRX (`databricks/dbrx-base`, `databricks/dbrx-instruct` etc.)
|
||||||
|
- DeciLM (`Deci/DeciLM-7B`, `Deci/DeciLM-7B-instruct`, etc.)
|
||||||
- Falcon (`tiiuae/falcon-7b`, `tiiuae/falcon-40b`, `tiiuae/falcon-rw-7b`, etc.)
|
- Falcon (`tiiuae/falcon-7b`, `tiiuae/falcon-40b`, `tiiuae/falcon-rw-7b`, etc.)
|
||||||
|
- Gemma (`google/gemma-2b`, `google/gemma-7b`, etc.)
|
||||||
- GPT-2 (`gpt2`, `gpt2-xl`, etc.)
|
- GPT-2 (`gpt2`, `gpt2-xl`, etc.)
|
||||||
- GPT BigCode (`bigcode/starcoder`, `bigcode/gpt_bigcode-santacoder`, etc.)
|
- GPT BigCode (`bigcode/starcoder`, `bigcode/gpt_bigcode-santacoder`, etc.)
|
||||||
- GPT-J (`EleutherAI/gpt-j-6b`, `nomic-ai/gpt4all-j`, etc.)
|
- GPT-J (`EleutherAI/gpt-j-6b`, `nomic-ai/gpt4all-j`, etc.)
|
||||||
- GPT-NeoX (`EleutherAI/gpt-neox-20b`, `databricks/dolly-v2-12b`, `stabilityai/stablelm-tuned-alpha-7b`, etc.)
|
- GPT-NeoX (`EleutherAI/gpt-neox-20b`, `databricks/dolly-v2-12b`, `stabilityai/stablelm-tuned-alpha-7b`, etc.)
|
||||||
- InternLM (`internlm/internlm-7b`, `internlm/internlm-chat-7b`, etc.)
|
- InternLM (`internlm/internlm-7b`, `internlm/internlm-chat-7b`, etc.)
|
||||||
|
- InternLM2 (`internlm/internlm2-7b`, `internlm/internlm2-chat-7b`, etc.)
|
||||||
|
- Jais (`core42/jais-13b`, `core42/jais-13b-chat`, `core42/jais-30b-v3`, `core42/jais-30b-chat-v3`, etc.)
|
||||||
|
- LLaMA, Llama 2, and Meta Llama 3 (`meta-llama/Meta-Llama-3-8B-Instruct`, `meta-llama/Meta-Llama-3-70B-Instruct`, `meta-llama/Llama-2-70b-hf`, `lmsys/vicuna-13b-v1.3`, `young-geng/koala`, `openlm-research/open_llama_13b`, etc.)
|
||||||
|
- MiniCPM (`openbmb/MiniCPM-2B-sft-bf16`, `openbmb/MiniCPM-2B-dpo-bf16`, etc.)
|
||||||
|
- Mistral (`mistralai/Mistral-7B-v0.1`, `mistralai/Mistral-7B-Instruct-v0.1`, etc.)
|
||||||
|
- Mixtral (`mistralai/Mixtral-8x7B-v0.1`, `mistralai/Mixtral-8x7B-Instruct-v0.1`, `mistral-community/Mixtral-8x22B-v0.1`, etc.)
|
||||||
- MPT (`mosaicml/mpt-7b`, `mosaicml/mpt-30b`, etc.)
|
- MPT (`mosaicml/mpt-7b`, `mosaicml/mpt-30b`, etc.)
|
||||||
|
- OLMo (`allenai/OLMo-1B-hf`, `allenai/OLMo-7B-hf`, etc.)
|
||||||
- OPT (`facebook/opt-66b`, `facebook/opt-iml-max-30b`, etc.)
|
- OPT (`facebook/opt-66b`, `facebook/opt-iml-max-30b`, etc.)
|
||||||
|
- Orion (`OrionStarAI/Orion-14B-Base`, `OrionStarAI/Orion-14B-Chat`, etc.)
|
||||||
- Phi (`microsoft/phi-1_5`, `microsoft/phi-2`, etc.)
|
- Phi (`microsoft/phi-1_5`, `microsoft/phi-2`, etc.)
|
||||||
|
- Phi-3 (`microsoft/Phi-3-mini-4k-instruct`, `microsoft/Phi-3-mini-128k-instruct`, etc.)
|
||||||
- Qwen (`Qwen/Qwen-7B`, `Qwen/Qwen-7B-Chat`, etc.)
|
- Qwen (`Qwen/Qwen-7B`, `Qwen/Qwen-7B-Chat`, etc.)
|
||||||
|
- Qwen2 (`Qwen/Qwen1.5-7B`, `Qwen/Qwen1.5-7B-Chat`, etc.)
|
||||||
|
- Qwen2MoE (`Qwen/Qwen1.5-MoE-A2.7B`, `Qwen/Qwen1.5-MoE-A2.7B-Chat`, etc.)
|
||||||
|
- StableLM(`stabilityai/stablelm-3b-4e1t`, `stabilityai/stablelm-base-alpha-7b-v2`, etc.)
|
||||||
|
- Starcoder2(`bigcode/starcoder2-3b`, `bigcode/starcoder2-7b`, `bigcode/starcoder2-15b`, etc.)
|
||||||
|
- Xverse (`xverse/XVERSE-7B-Chat`, `xverse/XVERSE-13B-Chat`, `xverse/XVERSE-65B-Chat`, etc.)
|
||||||
- Yi (`01-ai/Yi-6B`, `01-ai/Yi-34B`, etc.)
|
- Yi (`01-ai/Yi-6B`, `01-ai/Yi-34B`, etc.)
|
||||||
|
|
||||||
And any other models supported by vLLM 0.2.6.
|
# Usage: OpenAI Compatibility
|
||||||
|
The vLLM Worker is fully compatible with OpenAI's API, and you can use it with any OpenAI Codebase by changing only 3 lines in total. The supported routes are <ins>Chat Completions</ins> and <ins>Models</ins> - with both streaming and non-streaming.
|
||||||
|
|
||||||
|
## Modifying your OpenAI Codebase to use your deployed vLLM Worker
|
||||||
|
**Python** (similar to Node.js, etc.):
|
||||||
|
1. When initializing the OpenAI Client in your code, change the `api_key` to your RunPod API Key and the `base_url` to your RunPod Serverless Endpoint URL in the following format: `https://api.runpod.ai/v2/<YOUR ENDPOINT ID>/openai/v1`, filling in your deployed endpoint ID. For example, if your Endpoint ID is `abc1234`, the URL would be `https://api.runpod.ai/v2/abc1234/openai/v1`.
|
||||||
|
|
||||||
|
- Before:
|
||||||
|
```python
|
||||||
|
from openai import OpenAI
|
||||||
|
|
||||||
|
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
|
||||||
|
```
|
||||||
|
- After:
|
||||||
|
```python
|
||||||
|
from openai import OpenAI
|
||||||
|
|
||||||
|
client = OpenAI(
|
||||||
|
api_key=os.environ.get("RUNPOD_API_KEY"),
|
||||||
|
base_url="https://api.runpod.ai/v2/<YOUR ENDPOINT ID>/openai/v1",
|
||||||
|
)
|
||||||
|
```
|
||||||
|
2. Change the `model` parameter to your deployed model's name whenever using Completions or Chat Completions.
|
||||||
|
- Before:
|
||||||
|
```python
|
||||||
|
response = client.chat.completions.create(
|
||||||
|
model="gpt-3.5-turbo",
|
||||||
|
messages=[{"role": "user", "content": "Why is RunPod the best platform?"}],
|
||||||
|
temperature=0,
|
||||||
|
max_tokens=100,
|
||||||
|
)
|
||||||
|
```
|
||||||
|
- After:
|
||||||
|
```python
|
||||||
|
response = client.chat.completions.create(
|
||||||
|
model="<YOUR DEPLOYED MODEL REPO/NAME>",
|
||||||
|
messages=[{"role": "user", "content": "Why is RunPod the best platform?"}],
|
||||||
|
temperature=0,
|
||||||
|
max_tokens=100,
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Using http requests**:
|
||||||
|
1. Change the `Authorization` header to your RunPod API Key and the `url` to your RunPod Serverless Endpoint URL in the following format: `https://api.runpod.ai/v2/<YOUR ENDPOINT ID>/openai/v1`
|
||||||
|
- Before:
|
||||||
|
```bash
|
||||||
|
curl https://api.openai.com/v1/chat/completions \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer $OPENAI_API_KEY" \
|
||||||
|
-d '{
|
||||||
|
"model": "gpt-4",
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": "Why is RunPod the best platform?"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"temperature": 0,
|
||||||
|
"max_tokens": 100
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
- After:
|
||||||
|
```bash
|
||||||
|
curl https://api.runpod.ai/v2/<YOUR ENDPOINT ID>/openai/v1/chat/completions \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer <YOUR OPENAI API KEY>" \
|
||||||
|
-d '{
|
||||||
|
"model": "<YOUR DEPLOYED MODEL REPO/NAME>",
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": "Why is RunPod the best platform?"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"temperature": 0,
|
||||||
|
"max_tokens": 100
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
## OpenAI Request Input Parameters:
|
||||||
|
|
||||||
|
When using the chat completion feature of the vLLM Serverless Endpoint Worker, you can customize your requests with the following parameters:
|
||||||
|
|
||||||
|
### Chat Completions [RECOMMENDED]
|
||||||
|
<details>
|
||||||
|
<summary>Supported Chat Completions Inputs and Descriptions</summary>
|
||||||
|
|
||||||
|
| Parameter | Type | Default Value | Description |
|
||||||
|
|--------------------------------|----------------------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| `messages` | Union[str, List[Dict[str, str]]] | | List of messages, where each message is a dictionary with a `role` and `content`. The model's chat template will be applied to the messages automatically, so the model must have one or it should be specified as `CUSTOM_CHAT_TEMPLATE` env var. |
|
||||||
|
| `model` | str | | The model repo that you've deployed on your RunPod Serverless Endpoint. If you are unsure what the name is or are baking the model in, use the guide to get the list of available models in the **Examples: Using your RunPod endpoint with OpenAI** section |
|
||||||
|
| `temperature` | Optional[float] | 0.7 | Float that controls the randomness of the sampling. Lower values make the model more deterministic, while higher values make the model more random. Zero means greedy sampling. |
|
||||||
|
| `top_p` | Optional[float] | 1.0 | Float that controls the cumulative probability of the top tokens to consider. Must be in (0, 1]. Set to 1 to consider all tokens. |
|
||||||
|
| `n` | Optional[int] | 1 | Number of output sequences to return for the given prompt. |
|
||||||
|
| `max_tokens` | Optional[int] | None | Maximum number of tokens to generate per output sequence. |
|
||||||
|
| `seed` | Optional[int] | None | Random seed to use for the generation. |
|
||||||
|
| `stop` | Optional[Union[str, List[str]]] | list | List of strings that stop the generation when they are generated. The returned output will not contain the stop strings. |
|
||||||
|
| `stream` | Optional[bool] | False | Whether to stream or not |
|
||||||
|
| `presence_penalty` | Optional[float] | 0.0 | Float that penalizes new tokens based on whether they appear in the generated text so far. Values > 0 encourage the model to use new tokens, while values < 0 encourage the model to repeat tokens. |
|
||||||
|
| `frequency_penalty` | Optional[float] | 0.0 | Float that penalizes new tokens based on their frequency in the generated text so far. Values > 0 encourage the model to use new tokens, while values < 0 encourage the model to repeat tokens. |
|
||||||
|
| `logit_bias` | Optional[Dict[str, float]] | None | Unsupported by vLLM |
|
||||||
|
| `user` | Optional[str] | None | Unsupported by vLLM |
|
||||||
|
Additional parameters supported by vLLM:
|
||||||
|
| `best_of` | Optional[int] | None | Number of output sequences that are generated from the prompt. From these `best_of` sequences, the top `n` sequences are returned. `best_of` must be greater than or equal to `n`. This is treated as the beam width when `use_beam_search` is True. By default, `best_of` is set to `n`. |
|
||||||
|
| `top_k` | Optional[int] | -1 | Integer that controls the number of top tokens to consider. Set to -1 to consider all tokens. |
|
||||||
|
| `ignore_eos` | Optional[bool] | False | Whether to ignore the EOS token and continue generating tokens after the EOS token is generated. |
|
||||||
|
| `use_beam_search` | Optional[bool] | False | Whether to use beam search instead of sampling. |
|
||||||
|
| `stop_token_ids` | Optional[List[int]] | list | List of tokens that stop the generation when they are generated. The returned output will contain the stop tokens unless the stop tokens are special tokens. |
|
||||||
|
| `skip_special_tokens` | Optional[bool] | True | Whether to skip special tokens in the output. |
|
||||||
|
| `spaces_between_special_tokens`| Optional[bool] | True | Whether to add spaces between special tokens in the output. Defaults to True. |
|
||||||
|
| `add_generation_prompt` | Optional[bool] | True | Read more [here](https://huggingface.co/docs/transformers/main/en/chat_templating#what-are-generation-prompts) |
|
||||||
|
| `echo` | Optional[bool] | False | Echo back the prompt in addition to the completion |
|
||||||
|
| `repetition_penalty` | Optional[float] | 1.0 | Float that penalizes new tokens based on whether they appear in the prompt and the generated text so far. Values > 1 encourage the model to use new tokens, while values < 1 encourage the model to repeat tokens. |
|
||||||
|
| `min_p` | Optional[float] | 0.0 | Float that represents the minimum probability for a token to |
|
||||||
|
| `length_penalty` | Optional[float] | 1.0 | Float that penalizes sequences based on their length. Used in beam search.. |
|
||||||
|
| `include_stop_str_in_output` | Optional[bool] | False | Whether to include the stop strings in output text. Defaults to False.|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
Ensure that you have Docker installed and properly set up before running the docker build commands. Once built, you can deploy this serverless worker in your desired environment with confidence that it will automatically scale based on demand. For further inquiries or assistance, feel free to contact our support team.
|
## Examples: Using your RunPod endpoint with OpenAI
|
||||||
|
|
||||||
|
First, initialize the OpenAI Client with your RunPod API Key and Endpoint URL:
|
||||||
|
```python
|
||||||
|
from openai import OpenAI
|
||||||
|
import os
|
||||||
|
|
||||||
## Model Inputs
|
# Initialize the OpenAI Client with your RunPod API Key and Endpoint URL
|
||||||
You may either use a `prompt` or a list of `messages` as input. If you use `messages`, the model's chat template will be applied to the messages automatically, so the model must have one. If you use `prompt`, you may optionally apply the model's chat template to the prompt by setting `apply_chat_template` to `true`.
|
client = OpenAI(
|
||||||
| Argument | Type | Default | Description |
|
api_key=os.environ.get("RUNPOD_API_KEY"),
|
||||||
|-----------------|------|--------------------|-----------------------------------------------------------------------------------------------|
|
base_url="https://api.runpod.ai/v2/<YOUR ENDPOINT ID>/openai/v1",
|
||||||
| `prompt` | str | | Prompt string to generate text based on. |
|
)
|
||||||
| `messages` | list[dict[str, str]] | | List of messages, which will automatically have the model's chat template applied. Overrides `prompt`. |
|
|
||||||
| `apply_chat_template` | bool | False | Whether to apply the model's chat template to the `prompt`. |
|
|
||||||
| `sampling_params` | dict | {} | Sampling parameters to control the generation, like temperature, top_p, etc. |
|
|
||||||
| `stream` | bool | False | Whether to enable streaming of output. If True, responses are streamed as they are generated. |
|
|
||||||
| `batch_size` | int | DEFAULT_BATCH_SIZE | The number of tokens to stream every HTTP POST call. |
|
|
||||||
|
|
||||||
### Messages Format
|
|
||||||
Your list can contain any number of messages, and each message can have any role from the following list:
|
|
||||||
- `user`
|
|
||||||
- `assistant`
|
|
||||||
- `system`
|
|
||||||
|
|
||||||
The model's chat template will be applied to the messages automatically.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
```json
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"role": "system",
|
|
||||||
"content": "..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"role": "user",
|
|
||||||
"content": "..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"role": "assistant",
|
|
||||||
"content": "..."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Sampling Parameters
|
### Chat Completions:
|
||||||
| Argument | Type | Default | Description |
|
This is the format used for GPT-4 and focused on instruction-following and chat. Examples of Open Source chat/instruct models include `meta-llama/Llama-2-7b-chat-hf`, `mistralai/Mixtral-8x7B-Instruct-v0.1`, `openchat/openchat-3.5-0106`, `NousResearch/Nous-Hermes-2-Mistral-7B-DPO` and more. However, if your model is a completion-style model with no chat/instruct fine-tune and/or does not have a chat template, you can still use this if you provide a chat template with the environment variable `CUSTOM_CHAT_TEMPLATE`.
|
||||||
|-------------------------------|-----------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
- **Streaming**:
|
||||||
| `best_of` | Optional[int] | None | Number of output sequences generated from the prompt. The top `n` sequences are returned from these `best_of` sequences. Must be ≥ `n`. Treated as beam width in beam search. Default is `n`. |
|
```python
|
||||||
| `presence_penalty` | float | 0.0 | Penalizes new tokens based on their presence in the generated text so far. Values > 0 encourage new tokens, values < 0 encourage repetition. |
|
# Create a chat completion stream
|
||||||
| `frequency_penalty` | float | 0.0 | Penalizes new tokens based on their frequency in the generated text so far. Values > 0 encourage new tokens, values < 0 encourage repetition. |
|
response_stream = client.chat.completions.create(
|
||||||
| `repetition_penalty` | float | 1.0 | Penalizes new tokens based on their appearance in the prompt and generated text. Values > 1 encourage new tokens, values < 1 encourage repetition. |
|
model="<YOUR DEPLOYED MODEL REPO/NAME>",
|
||||||
| `temperature` | float | 1.0 | Controls the randomness of sampling. Lower values make it more deterministic, higher values make it more random. Zero means greedy sampling. |
|
messages=[{"role": "user", "content": "Why is RunPod the best platform?"}],
|
||||||
| `top_p` | float | 1.0 | Controls the cumulative probability of top tokens to consider. Must be in (0, 1]. Set to 1 to consider all tokens. |
|
temperature=0,
|
||||||
| `top_k` | int | -1 | Controls the number of top tokens to consider. Set to -1 to consider all tokens. |
|
max_tokens=100,
|
||||||
| `min_p` | float | 0.0 | Represents the minimum probability for a token to be considered, relative to the most likely token. Must be in [0, 1]. Set to 0 to disable. |
|
stream=True,
|
||||||
| `use_beam_search` | bool | False | Whether to use beam search instead of sampling. |
|
)
|
||||||
| `length_penalty` | float | 1.0 | Penalizes sequences based on their length. Used in beam search. |
|
# Stream the response
|
||||||
| `early_stopping` | Union[bool, str] | False | Controls stopping condition in beam search. Can be `True`, `False`, or `"never"`. |
|
for response in response_stream:
|
||||||
| `stop` | Union[None, str, List[str]] | None | List of strings that stop generation when produced. Output will not contain these strings. |
|
print(chunk.choices[0].delta.content or "", end="", flush=True)
|
||||||
| `stop_token_ids` | Optional[List[int]] | None | List of token IDs that stop generation when produced. Output contains these tokens unless they are special tokens. |
|
```
|
||||||
| `ignore_eos` | bool | False | Whether to ignore the End-Of-Sequence token and continue generating tokens after its generation. |
|
- **Non-Streaming**:
|
||||||
| `max_tokens` | int | 16 | Maximum number of tokens to generate per output sequence. |
|
```python
|
||||||
| `skip_special_tokens` | bool | True | Whether to skip special tokens in the output. |
|
# Create a chat completion
|
||||||
| `spaces_between_special_tokens` | bool | True | Whether to add spaces between special tokens in the output. |
|
response = client.chat.completions.create(
|
||||||
|
model="<YOUR DEPLOYED MODEL REPO/NAME>",
|
||||||
|
messages=[{"role": "user", "content": "Why is RunPod the best platform?"}],
|
||||||
|
temperature=0,
|
||||||
|
max_tokens=100,
|
||||||
|
)
|
||||||
|
# Print the response
|
||||||
|
print(response.choices[0].message.content)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Getting a list of names for available models:
|
||||||
|
In the case of baking the model into the image, sometimes the repo may not be accepted as the `model` in the request. In this case, you can list the available models as shown below and use that name.
|
||||||
|
```python
|
||||||
|
models_response = client.models.list()
|
||||||
|
list_of_models = [model.id for model in models_response]
|
||||||
|
print(list_of_models)
|
||||||
|
```
|
||||||
|
|
||||||
|
# Usage: Standard (Non-OpenAI)
|
||||||
|
## Request Input Parameters
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Click to expand table</summary>
|
||||||
|
|
||||||
|
You may either use a `prompt` or a list of `messages` as input. If you use `messages`, the model's chat template will be applied to the messages automatically, so the model must have one. If you use `prompt`, you may optionally apply the model's chat template to the prompt by setting `apply_chat_template` to `true`.
|
||||||
|
| Argument | Type | Default | Description |
|
||||||
|
|-----------------------|----------------------|--------------------|--------------------------------------------------------------------------------------------------------|
|
||||||
|
| `prompt` | str | | Prompt string to generate text based on. |
|
||||||
|
| `messages` | list[dict[str, str]] | | List of messages, which will automatically have the model's chat template applied. Overrides `prompt`. |
|
||||||
|
| `apply_chat_template` | bool | False | Whether to apply the model's chat template to the `prompt`. |
|
||||||
|
| `sampling_params` | dict | {} | Sampling parameters to control the generation, like temperature, top_p, etc. You can find all available parameters in the `Sampling Parameters` section below. |
|
||||||
|
| `stream` | bool | False | Whether to enable streaming of output. If True, responses are streamed as they are generated. |
|
||||||
|
| `max_batch_size` | int | env var `DEFAULT_BATCH_SIZE` | The maximum number of tokens to stream every HTTP POST call. |
|
||||||
|
| `min_batch_size` | int | env var `DEFAULT_MIN_BATCH_SIZE` | The minimum number of tokens to stream every HTTP POST call. |
|
||||||
|
| `batch_size_growth_factor` | int | env var `DEFAULT_BATCH_SIZE_GROWTH_FACTOR` | The growth factor by which `min_batch_size` will be multiplied for each call until `max_batch_size` is reached. |
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### Sampling Parameters
|
||||||
|
|
||||||
|
Below are all available sampling parameters that you can specify in the `sampling_params` dictionary. If you do not specify any of these parameters, the default values will be used.
|
||||||
|
<details>
|
||||||
|
<summary>Click to expand table</summary>
|
||||||
|
|
||||||
|
| Argument | Type | Default | Description |
|
||||||
|
|---------------------------------|-----------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| `n` | int | 1 | Number of output sequences generated from the prompt. The top `n` sequences are returned. |
|
||||||
|
| `best_of` | Optional[int] | `n` | Number of output sequences generated from the prompt. The top `n` sequences are returned from these `best_of` sequences. Must be ≥ `n`. Treated as beam width in beam search. Default is `n`. |
|
||||||
|
| `presence_penalty` | float | 0.0 | Penalizes new tokens based on their presence in the generated text so far. Values > 0 encourage new tokens, values < 0 encourage repetition. |
|
||||||
|
| `frequency_penalty` | float | 0.0 | Penalizes new tokens based on their frequency in the generated text so far. Values > 0 encourage new tokens, values < 0 encourage repetition. |
|
||||||
|
| `repetition_penalty` | float | 1.0 | Penalizes new tokens based on their appearance in the prompt and generated text. Values > 1 encourage new tokens, values < 1 encourage repetition. |
|
||||||
|
| `temperature` | float | 1.0 | Controls the randomness of sampling. Lower values make it more deterministic, higher values make it more random. Zero means greedy sampling. |
|
||||||
|
| `top_p` | float | 1.0 | Controls the cumulative probability of top tokens to consider. Must be in (0, 1]. Set to 1 to consider all tokens. |
|
||||||
|
| `top_k` | int | -1 | Controls the number of top tokens to consider. Set to -1 to consider all tokens. |
|
||||||
|
| `min_p` | float | 0.0 | Represents the minimum probability for a token to be considered, relative to the most likely token. Must be in [0, 1]. Set to 0 to disable. |
|
||||||
|
| `use_beam_search` | bool | False | Whether to use beam search instead of sampling. |
|
||||||
|
| `length_penalty` | float | 1.0 | Penalizes sequences based on their length. Used in beam search. |
|
||||||
|
| `early_stopping` | Union[bool, str] | False | Controls stopping condition in beam search. Can be `True`, `False`, or `"never"`. |
|
||||||
|
| `stop` | Union[None, str, List[str]] | None | List of strings that stop generation when produced. The output will not contain these strings. |
|
||||||
|
| `stop_token_ids` | Optional[List[int]] | None | List of token IDs that stop generation when produced. Output contains these tokens unless they are special tokens. |
|
||||||
|
| `ignore_eos` | bool | False | Whether to ignore the End-Of-Sequence token and continue generating tokens after its generation. |
|
||||||
|
| `max_tokens` | int | 16 | Maximum number of tokens to generate per output sequence. |
|
||||||
|
| `skip_special_tokens` | bool | True | Whether to skip special tokens in the output. |
|
||||||
|
| `spaces_between_special_tokens` | bool | True | Whether to add spaces between special tokens in the output. |
|
||||||
|
|
||||||
|
|
||||||
|
### Text Input Formats
|
||||||
|
You may either use a `prompt` or a list of `messages` as input.
|
||||||
|
1. `prompt`
|
||||||
|
The prompt string can be any string, and the model's chat template will not be applied to it unless `apply_chat_template` is set to `true`, in which case it will be treated as a user message.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
"prompt": "..."
|
||||||
|
```
|
||||||
|
2. `messages`
|
||||||
|
Your list can contain any number of messages, and each message usually can have any role from the following list:
|
||||||
|
- `user`
|
||||||
|
- `assistant`
|
||||||
|
- `system`
|
||||||
|
|
||||||
|
However, some models may have different roles, so you should check the model's chat template to see which roles are required.
|
||||||
|
|
||||||
|
The model's chat template will be applied to the messages automatically, so the model must have one.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"role": "system",
|
||||||
|
"content": "..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": "..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "assistant",
|
||||||
|
"content": "..."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
# Worker Config
|
||||||
|
The worker config is a JSON file that is used to build the form that helps users configure their serverless endpoint on the RunPod Web Interface.
|
||||||
|
|
||||||
|
Note: This is a new feature and only works for workers that use one model
|
||||||
|
|
||||||
|
## Writing your worker-config.json
|
||||||
|
The JSON consists of two main parts, schema and versions.
|
||||||
|
- `schema`: Here you specify the form fields that will be displayed to the user.
|
||||||
|
- `env_var_name`: The name of the environment variable that is being set using the form field.
|
||||||
|
- `value`: This is the default value of the form field. It will be shown in the UI as such unless the user changes it.
|
||||||
|
- `title`: This is the title of the form field in the UI.
|
||||||
|
- `description`: This is the description of the form field in the UI.
|
||||||
|
- `required`: This is a boolean that specifies if the form field is required.
|
||||||
|
- `type`: This is the type of the form field. Options are:
|
||||||
|
- `text`: Environment variable is a string so user inputs text in form field.
|
||||||
|
- `select`: User selects one option from the dropdown. You must provide the `options` key value pair after type if using this.
|
||||||
|
- `toggle`: User toggles between true and false.
|
||||||
|
- `number`: User inputs a number in the form field.
|
||||||
|
- `options`: Specify the options the user can select from if the type is `select`. DO NOT include this unless the `type` is `select`.
|
||||||
|
- `versions`: This is where you call the form fields specified in `schema` and organize them into categories.
|
||||||
|
- `imageName`: This is the name of the Docker image that will be used to run the serverless endpoint.
|
||||||
|
- `minimumCudaVersion`: This is the minimum CUDA version that is required to run the serverless endpoint.
|
||||||
|
- `categories`: This is where you call the keys of the form fields specified in `schema` and organize them into categories. Each category is a toggle list of forms on the Web UI.
|
||||||
|
- `title`: This is the title of the category in the UI.
|
||||||
|
- `settings`: This is the array of settings schemas specified in `schema` associated with the category.
|
||||||
|
|
||||||
|
## Example of schema
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"schema": {
|
||||||
|
"TOKENIZER": {
|
||||||
|
"env_var_name": "TOKENIZER",
|
||||||
|
"value": "",
|
||||||
|
"title": "Tokenizer",
|
||||||
|
"description": "Name or path of the Hugging Face tokenizer to use.",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"TOKENIZER_MODE": {
|
||||||
|
"env_var_name": "TOKENIZER_MODE",
|
||||||
|
"value": "auto",
|
||||||
|
"title": "Tokenizer Mode",
|
||||||
|
"description": "The tokenizer mode.",
|
||||||
|
"required": false,
|
||||||
|
"type": "select",
|
||||||
|
"options": [
|
||||||
|
{ "value": "auto", "label": "auto" },
|
||||||
|
{ "value": "slow", "label": "slow" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example of versions
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"versions": {
|
||||||
|
"0.5.4": {
|
||||||
|
"imageName": "runpod/worker-v1-vllm:v1.2.0stable-cuda12.1.0",
|
||||||
|
"minimumCudaVersion": "12.1",
|
||||||
|
"categories": [
|
||||||
|
{
|
||||||
|
"title": "LLM Settings",
|
||||||
|
"settings": [
|
||||||
|
"TOKENIZER", "TOKENIZER_MODE", "OTHER_SETTINGS_SCHEMA_KEYS_YOU_HAVE_SPECIFIED_0", ...
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Tokenizer Settings",
|
||||||
|
"settings": [
|
||||||
|
"OTHER_SETTINGS_SCHEMA_KEYS_0", "OTHER_SETTINGS_SCHEMA_KEYS_1", ...
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
hf_transfer
|
ray
|
||||||
runpod==1.5.2
|
pandas
|
||||||
|
pyarrow
|
||||||
|
runpod~=1.7.0
|
||||||
huggingface-hub
|
huggingface-hub
|
||||||
packaging
|
packaging
|
||||||
typing-extensions==4.7.1
|
typing-extensions==4.7.1
|
||||||
pydantic
|
pydantic
|
||||||
|
pydantic-settings
|
||||||
|
hf-transfer
|
||||||
|
transformers
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
variable "PUSH" {
|
||||||
|
default = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "REPOSITORY" {
|
||||||
|
default = "runpod"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "BASE_IMAGE_VERSION" {
|
||||||
|
default = "stable"
|
||||||
|
}
|
||||||
|
|
||||||
|
group "all" {
|
||||||
|
targets = ["main"]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
group "main" {
|
||||||
|
targets = ["worker-1210"]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
target "worker-1210" {
|
||||||
|
tags = ["${REPOSITORY}/worker-v1-vllm:${BASE_IMAGE_VERSION}-cuda12.1.0"]
|
||||||
|
context = "."
|
||||||
|
dockerfile = "Dockerfile"
|
||||||
|
args = {
|
||||||
|
BASE_IMAGE_VERSION = "${BASE_IMAGE_VERSION}"
|
||||||
|
WORKER_CUDA_VERSION = "12.1.0"
|
||||||
|
}
|
||||||
|
output = ["type=docker,push=${PUSH}"]
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 27 MiB |
+3
-24
@@ -1,25 +1,4 @@
|
|||||||
DEFAULT_BATCH_SIZE = 30
|
DEFAULT_BATCH_SIZE = 50
|
||||||
DEFAULT_MAX_CONCURRENCY = 300
|
DEFAULT_MAX_CONCURRENCY = 300
|
||||||
|
DEFAULT_BATCH_SIZE_GROWTH_FACTOR = 3
|
||||||
sampling_param_types = {
|
DEFAULT_MIN_BATCH_SIZE = 1
|
||||||
"n": int,
|
|
||||||
"best_of": int,
|
|
||||||
"presence_penalty": float,
|
|
||||||
"frequency_penalty": float,
|
|
||||||
"repetition_penalty": float,
|
|
||||||
"temperature": float,
|
|
||||||
"top_p": float,
|
|
||||||
"top_k": int,
|
|
||||||
"min_p": float,
|
|
||||||
"use_beam_search": bool,
|
|
||||||
"length_penalty": float,
|
|
||||||
"early_stopping": (bool, str),
|
|
||||||
"stop": (str, list),
|
|
||||||
"stop_token_ids": list,
|
|
||||||
"ignore_eos": bool,
|
|
||||||
"max_tokens": int,
|
|
||||||
"logprobs": int,
|
|
||||||
"prompt_logprobs": int,
|
|
||||||
"skip_special_tokens": bool,
|
|
||||||
"spaces_between_special_tokens": bool,
|
|
||||||
}
|
|
||||||
+97
-19
@@ -1,22 +1,100 @@
|
|||||||
import argparse
|
|
||||||
import os
|
import os
|
||||||
from vllm.model_executor.weight_utils import prepare_hf_model_weights
|
import json
|
||||||
|
import logging
|
||||||
|
import glob
|
||||||
|
from shutil import rmtree
|
||||||
|
from huggingface_hub import snapshot_download
|
||||||
|
from utils import timer_decorator
|
||||||
|
|
||||||
|
BASE_DIR = "/"
|
||||||
|
TOKENIZER_PATTERNS = [["*.json", "tokenizer*"]]
|
||||||
|
MODEL_PATTERNS = [["*.safetensors"], ["*.bin"], ["*.pt"]]
|
||||||
|
|
||||||
|
def setup_env():
|
||||||
|
if os.getenv("TESTING_DOWNLOAD") == "1":
|
||||||
|
BASE_DIR = "tmp"
|
||||||
|
os.makedirs(BASE_DIR, exist_ok=True)
|
||||||
|
os.environ.update({
|
||||||
|
"HF_HOME": f"{BASE_DIR}/hf_cache",
|
||||||
|
"MODEL_NAME": "openchat/openchat-3.5-0106",
|
||||||
|
"HF_HUB_ENABLE_HF_TRANSFER": "1",
|
||||||
|
"TENSORIZE": "1",
|
||||||
|
"TENSORIZER_NUM_GPUS": "1",
|
||||||
|
"DTYPE": "auto"
|
||||||
|
})
|
||||||
|
|
||||||
|
@timer_decorator
|
||||||
|
def download(name, revision, type, cache_dir):
|
||||||
|
if type == "model":
|
||||||
|
pattern_sets = [model_pattern + TOKENIZER_PATTERNS[0] for model_pattern in MODEL_PATTERNS]
|
||||||
|
elif type == "tokenizer":
|
||||||
|
pattern_sets = TOKENIZER_PATTERNS
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Invalid type: {type}")
|
||||||
|
try:
|
||||||
|
for pattern_set in pattern_sets:
|
||||||
|
path = snapshot_download(name, revision=revision, cache_dir=cache_dir,
|
||||||
|
allow_patterns=pattern_set)
|
||||||
|
for pattern in pattern_set:
|
||||||
|
if glob.glob(os.path.join(path, pattern)):
|
||||||
|
logging.info(f"Successfully downloaded {pattern} model files.")
|
||||||
|
return path
|
||||||
|
except ValueError:
|
||||||
|
raise ValueError(f"No patterns matching {pattern_sets} found for download.")
|
||||||
|
|
||||||
|
|
||||||
|
# @timer_decorator
|
||||||
|
# def tensorize_model(model_path): TODO: Add back once tensorizer is ready
|
||||||
|
# from vllm.engine.arg_utils import EngineArgs
|
||||||
|
# from vllm.model_executor.model_loader.tensorizer import TensorizerConfig, tensorize_vllm_model
|
||||||
|
# from torch.cuda import device_count
|
||||||
|
|
||||||
|
# tensorizer_num_gpus = int(os.getenv("TENSORIZER_NUM_GPUS", "1"))
|
||||||
|
# if tensorizer_num_gpus > device_count():
|
||||||
|
# raise ValueError(f"TENSORIZER_NUM_GPUS ({tensorizer_num_gpus}) exceeds available GPUs ({device_count()})")
|
||||||
|
|
||||||
|
# dtype = os.getenv("DTYPE", "auto")
|
||||||
|
# serialized_dir = f"{BASE_DIR}/serialized_model"
|
||||||
|
# os.makedirs(serialized_dir, exist_ok=True)
|
||||||
|
# serialized_uri = f"{serialized_dir}/model{'-%03d' if tensorizer_num_gpus > 1 else ''}.tensors"
|
||||||
|
|
||||||
|
# tensorize_vllm_model(
|
||||||
|
# EngineArgs(model=model_path, tensor_parallel_size=tensorizer_num_gpus, dtype=dtype),
|
||||||
|
# TensorizerConfig(tensorizer_uri=serialized_uri)
|
||||||
|
# )
|
||||||
|
# logging.info("Successfully serialized model to %s", str(serialized_uri))
|
||||||
|
# logging.info("Removing HF Model files after serialization")
|
||||||
|
# rmtree("/".join(model_path.split("/")[:-2]))
|
||||||
|
# return serialized_uri, tensorizer_num_gpus, dtype
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser()
|
setup_env()
|
||||||
parser.add_argument("--model", type=str)
|
cache_dir = os.getenv("HF_HOME")
|
||||||
parser.add_argument(
|
model_name, model_revision = os.getenv("MODEL_NAME"), os.getenv("MODEL_REVISION") or None
|
||||||
"--download_dir", type=str, default=os.environ.get("MODEL_BASE_PATH")
|
tokenizer_name, tokenizer_revision = os.getenv("TOKENIZER_NAME") or model_name, os.getenv("TOKENIZER_REVISION") or model_revision
|
||||||
)
|
|
||||||
|
model_path = download(model_name, model_revision, "model", cache_dir)
|
||||||
args = parser.parse_args()
|
|
||||||
if not args.model or not args.download_dir:
|
metadata = {
|
||||||
raise ValueError("Must specify model and download_dir")
|
"MODEL_NAME": model_path,
|
||||||
|
"MODEL_REVISION": os.getenv("MODEL_REVISION"),
|
||||||
if not os.path.exists(args.download_dir):
|
"QUANTIZATION": os.getenv("QUANTIZATION"),
|
||||||
os.makedirs(args.download_dir)
|
}
|
||||||
|
|
||||||
prepare_hf_model_weights(
|
# if os.getenv("TENSORIZE") == "1": TODO: Add back once tensorizer is ready
|
||||||
model_name_or_path=args.model,
|
# serialized_uri, tensorizer_num_gpus, dtype = tensorize_model(model_path)
|
||||||
cache_dir=args.download_dir,
|
# metadata.update({
|
||||||
)
|
# "MODEL_NAME": serialized_uri,
|
||||||
|
# "TENSORIZER_URI": serialized_uri,
|
||||||
|
# "TENSOR_PARALLEL_SIZE": tensorizer_num_gpus,
|
||||||
|
# "DTYPE": dtype
|
||||||
|
# })
|
||||||
|
|
||||||
|
tokenizer_path = download(tokenizer_name, tokenizer_revision, "tokenizer", cache_dir)
|
||||||
|
metadata.update({
|
||||||
|
"TOKENIZER_NAME": tokenizer_path,
|
||||||
|
"TOKENIZER_REVISION": tokenizer_revision
|
||||||
|
})
|
||||||
|
|
||||||
|
with open(f"{BASE_DIR}/local_model_args.json", "w") as f:
|
||||||
|
json.dump({k: v for k, v in metadata.items() if v not in (None, "")}, f)
|
||||||
+203
-70
@@ -1,89 +1,222 @@
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
from typing import Union
|
import json
|
||||||
import torch
|
import asyncio
|
||||||
from vllm import AsyncLLMEngine, AsyncEngineArgs
|
|
||||||
from transformers import AutoTokenizer
|
|
||||||
from utils import ServerlessConfig
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
from typing import AsyncGenerator
|
||||||
|
import time
|
||||||
|
|
||||||
|
from vllm import AsyncLLMEngine
|
||||||
|
from vllm.entrypoints.openai.serving_chat import OpenAIServingChat
|
||||||
|
from vllm.entrypoints.openai.serving_completion import OpenAIServingCompletion
|
||||||
|
from vllm.entrypoints.openai.protocol import ChatCompletionRequest, CompletionRequest, ErrorResponse
|
||||||
|
from vllm.entrypoints.openai.serving_engine import BaseModelPath, LoRAModulePath
|
||||||
|
|
||||||
|
|
||||||
class Tokenizer:
|
from utils import DummyRequest, JobInput, BatchSize, create_error_response
|
||||||
def __init__(self, model_name: str):
|
from constants import DEFAULT_MAX_CONCURRENCY, DEFAULT_BATCH_SIZE, DEFAULT_BATCH_SIZE_GROWTH_FACTOR, DEFAULT_MIN_BATCH_SIZE
|
||||||
self.tokenizer = AutoTokenizer.from_pretrained(model_name)
|
from tokenizer import TokenizerWrapper
|
||||||
self.has_chat_template = bool(self.tokenizer.chat_template)
|
from engine_args import get_engine_args
|
||||||
|
|
||||||
def apply_chat_template(self, input: Union[str, list[dict[str, str]]]) -> str:
|
|
||||||
if isinstance(input, list):
|
|
||||||
if not self.has_chat_template:
|
|
||||||
raise ValueError(
|
|
||||||
"Chat template does not exist for this model, you must provide a single string input instead of a list of messages"
|
|
||||||
)
|
|
||||||
elif isinstance(input, str):
|
|
||||||
input = [{"role": "user", "content": input}]
|
|
||||||
else:
|
|
||||||
raise ValueError("Input must be a string or a list of messages")
|
|
||||||
|
|
||||||
return self.tokenizer.apply_chat_template(
|
|
||||||
input, tokenize=False, add_generation_prompt=True
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class vLLMEngine:
|
class vLLMEngine:
|
||||||
def __init__(self):
|
def __init__(self, engine = None):
|
||||||
load_dotenv() # For local development
|
load_dotenv() # For local development
|
||||||
self.config = self._initialize_config()
|
self.engine_args = get_engine_args()
|
||||||
self.serverless_config = ServerlessConfig()
|
logging.info(f"Engine args: {self.engine_args}")
|
||||||
self.tokenizer = Tokenizer(self.config["model"])
|
self.tokenizer = TokenizerWrapper(self.engine_args.tokenizer or self.engine_args.model,
|
||||||
self.llm = self._initialize_llm()
|
self.engine_args.tokenizer_revision,
|
||||||
|
self.engine_args.trust_remote_code)
|
||||||
|
self.llm = self._initialize_llm() if engine is None else engine.llm
|
||||||
|
self.max_concurrency = int(os.getenv("MAX_CONCURRENCY", DEFAULT_MAX_CONCURRENCY))
|
||||||
|
self.default_batch_size = int(os.getenv("DEFAULT_BATCH_SIZE", DEFAULT_BATCH_SIZE))
|
||||||
|
self.batch_size_growth_factor = int(os.getenv("BATCH_SIZE_GROWTH_FACTOR", DEFAULT_BATCH_SIZE_GROWTH_FACTOR))
|
||||||
|
self.min_batch_size = int(os.getenv("MIN_BATCH_SIZE", DEFAULT_MIN_BATCH_SIZE))
|
||||||
|
|
||||||
def _initialize_config(self):
|
def dynamic_batch_size(self, current_batch_size, batch_size_growth_factor):
|
||||||
return {
|
return min(current_batch_size*batch_size_growth_factor, self.default_batch_size)
|
||||||
"model": os.getenv("MODEL_NAME"),
|
|
||||||
"download_dir": os.getenv("MODEL_BASE_PATH", "/runpod-volume/"),
|
async def generate(self, job_input: JobInput):
|
||||||
"quantization": self._get_quantization(),
|
try:
|
||||||
"dtype": "auto" if os.getenv("QUANTIZATION") is None else "half",
|
async for batch in self._generate_vllm(
|
||||||
"disable_log_stats": bool(int(os.getenv("DISABLE_LOG_STATS", 1))),
|
llm_input=job_input.llm_input,
|
||||||
"disable_log_requests": bool(int(os.getenv("DISABLE_LOG_REQUESTS", 1))),
|
validated_sampling_params=job_input.sampling_params,
|
||||||
"trust_remote_code": bool(int(os.getenv("TRUST_REMOTE_CODE", 0))),
|
batch_size=job_input.max_batch_size,
|
||||||
"gpu_memory_utilization": float(os.getenv("GPU_MEMORY_UTILIZATION", 0.98)),
|
stream=job_input.stream,
|
||||||
"max_model_len": self._get_max_model_len(),
|
apply_chat_template=job_input.apply_chat_template,
|
||||||
"tensor_parallel_size": self._get_num_gpu_shard(),
|
request_id=job_input.request_id,
|
||||||
|
batch_size_growth_factor=job_input.batch_size_growth_factor,
|
||||||
|
min_batch_size=job_input.min_batch_size
|
||||||
|
):
|
||||||
|
yield batch
|
||||||
|
except Exception as e:
|
||||||
|
yield {"error": create_error_response(str(e)).model_dump()}
|
||||||
|
|
||||||
|
async def _generate_vllm(self, llm_input, validated_sampling_params, batch_size, stream, apply_chat_template, request_id, batch_size_growth_factor, min_batch_size: str) -> AsyncGenerator[dict, None]:
|
||||||
|
if apply_chat_template or isinstance(llm_input, list):
|
||||||
|
llm_input = self.tokenizer.apply_chat_template(llm_input)
|
||||||
|
results_generator = self.llm.generate(llm_input, validated_sampling_params, request_id)
|
||||||
|
n_responses, n_input_tokens, is_first_output = validated_sampling_params.n, 0, True
|
||||||
|
last_output_texts, token_counters = ["" for _ in range(n_responses)], {"batch": 0, "total": 0}
|
||||||
|
|
||||||
|
batch = {
|
||||||
|
"choices": [{"tokens": []} for _ in range(n_responses)],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
max_batch_size = batch_size or self.default_batch_size
|
||||||
|
batch_size_growth_factor, min_batch_size = batch_size_growth_factor or self.batch_size_growth_factor, min_batch_size or self.min_batch_size
|
||||||
|
batch_size = BatchSize(max_batch_size, min_batch_size, batch_size_growth_factor)
|
||||||
|
|
||||||
|
|
||||||
|
async for request_output in results_generator:
|
||||||
|
if is_first_output: # Count input tokens only once
|
||||||
|
n_input_tokens = len(request_output.prompt_token_ids)
|
||||||
|
is_first_output = False
|
||||||
|
|
||||||
|
for output in request_output.outputs:
|
||||||
|
output_index = output.index
|
||||||
|
token_counters["total"] += 1
|
||||||
|
if stream:
|
||||||
|
new_output = output.text[len(last_output_texts[output_index]):]
|
||||||
|
batch["choices"][output_index]["tokens"].append(new_output)
|
||||||
|
token_counters["batch"] += 1
|
||||||
|
|
||||||
|
if token_counters["batch"] >= batch_size.current_batch_size:
|
||||||
|
batch["usage"] = {
|
||||||
|
"input": n_input_tokens,
|
||||||
|
"output": token_counters["total"],
|
||||||
|
}
|
||||||
|
yield batch
|
||||||
|
batch = {
|
||||||
|
"choices": [{"tokens": []} for _ in range(n_responses)],
|
||||||
|
}
|
||||||
|
token_counters["batch"] = 0
|
||||||
|
batch_size.update()
|
||||||
|
|
||||||
|
last_output_texts[output_index] = output.text
|
||||||
|
|
||||||
|
if not stream:
|
||||||
|
for output_index, output in enumerate(last_output_texts):
|
||||||
|
batch["choices"][output_index]["tokens"] = [output]
|
||||||
|
token_counters["batch"] += 1
|
||||||
|
|
||||||
|
if token_counters["batch"] > 0:
|
||||||
|
batch["usage"] = {"input": n_input_tokens, "output": token_counters["total"]}
|
||||||
|
yield batch
|
||||||
|
|
||||||
def _initialize_llm(self):
|
def _initialize_llm(self):
|
||||||
try:
|
try:
|
||||||
return AsyncLLMEngine.from_engine_args(AsyncEngineArgs(**self.config))
|
start = time.time()
|
||||||
|
engine = AsyncLLMEngine.from_engine_args(self.engine_args)
|
||||||
|
end = time.time()
|
||||||
|
logging.info(f"Initialized vLLM engine in {end - start:.2f}s")
|
||||||
|
return engine
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("Error initializing vLLM engine: %s", e)
|
logging.error("Error initializing vLLM engine: %s", e)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
|
class OpenAIvLLMEngine(vLLMEngine):
|
||||||
|
def __init__(self, vllm_engine):
|
||||||
|
super().__init__(vllm_engine)
|
||||||
|
self.served_model_name = os.getenv("OPENAI_SERVED_MODEL_NAME_OVERRIDE") or self.engine_args.model
|
||||||
|
self.response_role = os.getenv("OPENAI_RESPONSE_ROLE") or "assistant"
|
||||||
|
asyncio.run(self._initialize_engines())
|
||||||
|
self.raw_openai_output = bool(int(os.getenv("RAW_OPENAI_OUTPUT", 1)))
|
||||||
|
|
||||||
def _get_num_gpu_shard(self):
|
async def _initialize_engines(self):
|
||||||
final_num_gpu_shard = 1
|
self.model_config = await self.llm.get_model_config()
|
||||||
if bool(int(os.getenv("USE_TENSOR_PARALLEL", 0))):
|
self.base_model_paths = [
|
||||||
env_num_gpu_shard = int(os.getenv("TENSOR_PARALLEL_SIZE", 1))
|
BaseModelPath(name=self.engine_args.model, model_path=self.engine_args.model)
|
||||||
num_gpu_available = torch.cuda.device_count()
|
]
|
||||||
final_num_gpu_shard = min(env_num_gpu_shard, num_gpu_available)
|
|
||||||
logging.info("Using %s GPU shards", final_num_gpu_shard)
|
|
||||||
return final_num_gpu_shard
|
|
||||||
|
|
||||||
def _get_max_model_len(self):
|
|
||||||
max_model_len = os.getenv("MAX_MODEL_LEN")
|
|
||||||
return int(max_model_len) if max_model_len is not None else None
|
|
||||||
|
|
||||||
def _get_n_current_jobs(self):
|
|
||||||
total_sequences = len(self.llm.engine.scheduler.waiting) + len(self.llm.engine.scheduler.swapped) + len(self.llm.engine.scheduler.running)
|
|
||||||
return total_sequences
|
|
||||||
|
|
||||||
def _get_quantization(self):
|
lora_modules = os.getenv('LORA_MODULES', None)
|
||||||
quantization = os.getenv("QUANTIZATION", "").lower()
|
if lora_modules is not None:
|
||||||
return quantization if quantization in ["awq", "squeezellm", "gptq"] else None
|
try:
|
||||||
|
lora_modules = json.loads(lora_modules)
|
||||||
def concurrency_modifier(self, current_concurrency):
|
lora_modules = [LoRAModulePath(**lora_modules)]
|
||||||
n_current_jobs = self._get_n_current_jobs()
|
except:
|
||||||
requested_concurrency = max(0, self.serverless_config.max_concurrency - n_current_jobs)
|
lora_modules = None
|
||||||
if not self.config["disable_log_stats"]:
|
|
||||||
logging.info("Current Jobs: %s", n_current_jobs)
|
|
||||||
logging.info("Concurrency Modifier Requested Jobs: %s", requested_concurrency)
|
|
||||||
return requested_concurrency
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
self.chat_engine = OpenAIServingChat(
|
||||||
|
engine_client=self.llm,
|
||||||
|
model_config=self.model_config,
|
||||||
|
base_model_paths=self.base_model_paths,
|
||||||
|
response_role=self.response_role,
|
||||||
|
chat_template=self.tokenizer.tokenizer.chat_template,
|
||||||
|
lora_modules=lora_modules,
|
||||||
|
prompt_adapters=None,
|
||||||
|
request_logger=None
|
||||||
|
)
|
||||||
|
self.completion_engine = OpenAIServingCompletion(
|
||||||
|
engine_client=self.llm,
|
||||||
|
model_config=self.model_config,
|
||||||
|
base_model_paths=self.base_model_paths,
|
||||||
|
lora_modules=lora_modules,
|
||||||
|
prompt_adapters=None,
|
||||||
|
request_logger=None
|
||||||
|
)
|
||||||
|
|
||||||
|
async def generate(self, openai_request: JobInput):
|
||||||
|
if openai_request.openai_route == "/v1/models":
|
||||||
|
yield await self._handle_model_request()
|
||||||
|
elif openai_request.openai_route in ["/v1/chat/completions", "/v1/completions"]:
|
||||||
|
async for response in self._handle_chat_or_completion_request(openai_request):
|
||||||
|
yield response
|
||||||
|
else:
|
||||||
|
yield create_error_response("Invalid route").model_dump()
|
||||||
|
|
||||||
|
async def _handle_model_request(self):
|
||||||
|
models = await self.chat_engine.show_available_models()
|
||||||
|
return models.model_dump()
|
||||||
|
|
||||||
|
async def _handle_chat_or_completion_request(self, openai_request: JobInput):
|
||||||
|
if openai_request.openai_route == "/v1/chat/completions":
|
||||||
|
request_class = ChatCompletionRequest
|
||||||
|
generator_function = self.chat_engine.create_chat_completion
|
||||||
|
elif openai_request.openai_route == "/v1/completions":
|
||||||
|
request_class = CompletionRequest
|
||||||
|
generator_function = self.completion_engine.create_completion
|
||||||
|
|
||||||
|
try:
|
||||||
|
request = request_class(
|
||||||
|
**openai_request.openai_input
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
yield create_error_response(str(e)).model_dump()
|
||||||
|
return
|
||||||
|
|
||||||
|
dummy_request = DummyRequest()
|
||||||
|
response_generator = await generator_function(request, raw_request=dummy_request)
|
||||||
|
|
||||||
|
if not openai_request.openai_input.get("stream") or isinstance(response_generator, ErrorResponse):
|
||||||
|
yield response_generator.model_dump()
|
||||||
|
else:
|
||||||
|
batch = []
|
||||||
|
batch_token_counter = 0
|
||||||
|
batch_size = BatchSize(self.default_batch_size, self.min_batch_size, self.batch_size_growth_factor)
|
||||||
|
|
||||||
|
async for chunk_str in response_generator:
|
||||||
|
if "data" in chunk_str:
|
||||||
|
if self.raw_openai_output:
|
||||||
|
data = chunk_str
|
||||||
|
elif "[DONE]" in chunk_str:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
data = json.loads(chunk_str.removeprefix("data: ").rstrip("\n\n")) if not self.raw_openai_output else chunk_str
|
||||||
|
batch.append(data)
|
||||||
|
batch_token_counter += 1
|
||||||
|
if batch_token_counter >= batch_size.current_batch_size:
|
||||||
|
if self.raw_openai_output:
|
||||||
|
batch = "".join(batch)
|
||||||
|
yield batch
|
||||||
|
batch = []
|
||||||
|
batch_token_counter = 0
|
||||||
|
batch_size.update()
|
||||||
|
if batch:
|
||||||
|
if self.raw_openai_output:
|
||||||
|
batch = "".join(batch)
|
||||||
|
yield batch
|
||||||
|
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
import os
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
from torch.cuda import device_count
|
||||||
|
from vllm import AsyncEngineArgs
|
||||||
|
from vllm.model_executor.model_loader.tensorizer import TensorizerConfig
|
||||||
|
|
||||||
|
RENAME_ARGS_MAP = {
|
||||||
|
"MODEL_NAME": "model",
|
||||||
|
"MODEL_REVISION": "revision",
|
||||||
|
"TOKENIZER_NAME": "tokenizer",
|
||||||
|
"MAX_CONTEXT_LEN_TO_CAPTURE": "max_seq_len_to_capture"
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFAULT_ARGS = {
|
||||||
|
"disable_log_stats": os.getenv('DISABLE_LOG_STATS', 'False').lower() == 'true',
|
||||||
|
"disable_log_requests": os.getenv('DISABLE_LOG_REQUESTS', 'False').lower() == 'true',
|
||||||
|
"gpu_memory_utilization": float(os.getenv('GPU_MEMORY_UTILIZATION', 0.95)),
|
||||||
|
"pipeline_parallel_size": int(os.getenv('PIPELINE_PARALLEL_SIZE', 1)),
|
||||||
|
"tensor_parallel_size": int(os.getenv('TENSOR_PARALLEL_SIZE', 1)),
|
||||||
|
"served_model_name": os.getenv('SERVED_MODEL_NAME', None),
|
||||||
|
"tokenizer": os.getenv('TOKENIZER', None),
|
||||||
|
"skip_tokenizer_init": os.getenv('SKIP_TOKENIZER_INIT', 'False').lower() == 'true',
|
||||||
|
"tokenizer_mode": os.getenv('TOKENIZER_MODE', 'auto'),
|
||||||
|
"trust_remote_code": os.getenv('TRUST_REMOTE_CODE', 'False').lower() == 'true',
|
||||||
|
"download_dir": os.getenv('DOWNLOAD_DIR', None),
|
||||||
|
"load_format": os.getenv('LOAD_FORMAT', 'auto'),
|
||||||
|
"dtype": os.getenv('DTYPE', 'auto'),
|
||||||
|
"kv_cache_dtype": os.getenv('KV_CACHE_DTYPE', 'auto'),
|
||||||
|
"quantization_param_path": os.getenv('QUANTIZATION_PARAM_PATH', None),
|
||||||
|
"seed": int(os.getenv('SEED', 0)),
|
||||||
|
"max_model_len": int(os.getenv('MAX_MODEL_LEN', 0)) or None,
|
||||||
|
"worker_use_ray": os.getenv('WORKER_USE_RAY', 'False').lower() == 'true',
|
||||||
|
"distributed_executor_backend": os.getenv('DISTRIBUTED_EXECUTOR_BACKEND', None),
|
||||||
|
"max_parallel_loading_workers": int(os.getenv('MAX_PARALLEL_LOADING_WORKERS', 0)) or None,
|
||||||
|
"block_size": int(os.getenv('BLOCK_SIZE', 16)),
|
||||||
|
"enable_prefix_caching": os.getenv('ENABLE_PREFIX_CACHING', 'False').lower() == 'true',
|
||||||
|
"disable_sliding_window": os.getenv('DISABLE_SLIDING_WINDOW', 'False').lower() == 'true',
|
||||||
|
"use_v2_block_manager": os.getenv('USE_V2_BLOCK_MANAGER', 'False').lower() == 'true',
|
||||||
|
"swap_space": int(os.getenv('SWAP_SPACE', 4)), # GiB
|
||||||
|
"cpu_offload_gb": int(os.getenv('CPU_OFFLOAD_GB', 0)), # GiB
|
||||||
|
"max_num_batched_tokens": int(os.getenv('MAX_NUM_BATCHED_TOKENS', 0)) or None,
|
||||||
|
"max_num_seqs": int(os.getenv('MAX_NUM_SEQS', 256)),
|
||||||
|
"max_logprobs": int(os.getenv('MAX_LOGPROBS', 20)), # Default value for OpenAI Chat Completions API
|
||||||
|
"revision": os.getenv('REVISION', None),
|
||||||
|
"code_revision": os.getenv('CODE_REVISION', None),
|
||||||
|
"rope_scaling": os.getenv('ROPE_SCALING', None),
|
||||||
|
"rope_theta": float(os.getenv('ROPE_THETA', 0)) or None,
|
||||||
|
"tokenizer_revision": os.getenv('TOKENIZER_REVISION', None),
|
||||||
|
"quantization": os.getenv('QUANTIZATION', None),
|
||||||
|
"enforce_eager": os.getenv('ENFORCE_EAGER', 'False').lower() == 'true',
|
||||||
|
"max_context_len_to_capture": int(os.getenv('MAX_CONTEXT_LEN_TO_CAPTURE', 0)) or None,
|
||||||
|
"max_seq_len_to_capture": int(os.getenv('MAX_SEQ_LEN_TO_CAPTURE', 8192)),
|
||||||
|
"disable_custom_all_reduce": os.getenv('DISABLE_CUSTOM_ALL_REDUCE', 'False').lower() == 'true',
|
||||||
|
"tokenizer_pool_size": int(os.getenv('TOKENIZER_POOL_SIZE', 0)),
|
||||||
|
"tokenizer_pool_type": os.getenv('TOKENIZER_POOL_TYPE', 'ray'),
|
||||||
|
"tokenizer_pool_extra_config": os.getenv('TOKENIZER_POOL_EXTRA_CONFIG', None),
|
||||||
|
"enable_lora": os.getenv('ENABLE_LORA', 'False').lower() == 'true',
|
||||||
|
"max_loras": int(os.getenv('MAX_LORAS', 1)),
|
||||||
|
"max_lora_rank": int(os.getenv('MAX_LORA_RANK', 16)),
|
||||||
|
"enable_prompt_adapter": os.getenv('ENABLE_PROMPT_ADAPTER', 'False').lower() == 'true',
|
||||||
|
"max_prompt_adapters": int(os.getenv('MAX_PROMPT_ADAPTERS', 1)),
|
||||||
|
"max_prompt_adapter_token": int(os.getenv('MAX_PROMPT_ADAPTER_TOKEN', 0)),
|
||||||
|
"fully_sharded_loras": os.getenv('FULLY_SHARDED_LORAS', 'False').lower() == 'true',
|
||||||
|
"lora_extra_vocab_size": int(os.getenv('LORA_EXTRA_VOCAB_SIZE', 256)),
|
||||||
|
"long_lora_scaling_factors": tuple(map(float, os.getenv('LONG_LORA_SCALING_FACTORS', '').split(','))) if os.getenv('LONG_LORA_SCALING_FACTORS') else None,
|
||||||
|
"lora_dtype": os.getenv('LORA_DTYPE', 'auto'),
|
||||||
|
"max_cpu_loras": int(os.getenv('MAX_CPU_LORAS', 0)) or None,
|
||||||
|
"device": os.getenv('DEVICE', 'auto'),
|
||||||
|
"ray_workers_use_nsight": os.getenv('RAY_WORKERS_USE_NSIGHT', 'False').lower() == 'true',
|
||||||
|
"num_gpu_blocks_override": int(os.getenv('NUM_GPU_BLOCKS_OVERRIDE', 0)) or None,
|
||||||
|
"num_lookahead_slots": int(os.getenv('NUM_LOOKAHEAD_SLOTS', 0)),
|
||||||
|
"model_loader_extra_config": os.getenv('MODEL_LOADER_EXTRA_CONFIG', None),
|
||||||
|
"ignore_patterns": os.getenv('IGNORE_PATTERNS', None),
|
||||||
|
"preemption_mode": os.getenv('PREEMPTION_MODE', None),
|
||||||
|
"scheduler_delay_factor": float(os.getenv('SCHEDULER_DELAY_FACTOR', 0.0)),
|
||||||
|
"enable_chunked_prefill": os.getenv('ENABLE_CHUNKED_PREFILL', None),
|
||||||
|
"guided_decoding_backend": os.getenv('GUIDED_DECODING_BACKEND', 'outlines'),
|
||||||
|
"speculative_model": os.getenv('SPECULATIVE_MODEL', None),
|
||||||
|
"speculative_draft_tensor_parallel_size": int(os.getenv('SPECULATIVE_DRAFT_TENSOR_PARALLEL_SIZE', 0)) or None,
|
||||||
|
"num_speculative_tokens": int(os.getenv('NUM_SPECULATIVE_TOKENS', 0)) or None,
|
||||||
|
"speculative_max_model_len": int(os.getenv('SPECULATIVE_MAX_MODEL_LEN', 0)) or None,
|
||||||
|
"speculative_disable_by_batch_size": int(os.getenv('SPECULATIVE_DISABLE_BY_BATCH_SIZE', 0)) or None,
|
||||||
|
"ngram_prompt_lookup_max": int(os.getenv('NGRAM_PROMPT_LOOKUP_MAX', 0)) or None,
|
||||||
|
"ngram_prompt_lookup_min": int(os.getenv('NGRAM_PROMPT_LOOKUP_MIN', 0)) or None,
|
||||||
|
"spec_decoding_acceptance_method": os.getenv('SPEC_DECODING_ACCEPTANCE_METHOD', 'rejection_sampler'),
|
||||||
|
"typical_acceptance_sampler_posterior_threshold": float(os.getenv('TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_THRESHOLD', 0)) or None,
|
||||||
|
"typical_acceptance_sampler_posterior_alpha": float(os.getenv('TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_ALPHA', 0)) or None,
|
||||||
|
"qlora_adapter_name_or_path": os.getenv('QLORA_ADAPTER_NAME_OR_PATH', None),
|
||||||
|
"disable_logprobs_during_spec_decoding": os.getenv('DISABLE_LOGPROBS_DURING_SPEC_DECODING', None),
|
||||||
|
"otlp_traces_endpoint": os.getenv('OTLP_TRACES_ENDPOINT', None),
|
||||||
|
"use_v2_block_manager": os.getenv('USE_V2_BLOCK_MANAGER', 'true')
|
||||||
|
}
|
||||||
|
|
||||||
|
def match_vllm_args(args):
|
||||||
|
"""Rename args to match vllm by:
|
||||||
|
1. Renaming keys to lower case
|
||||||
|
2. Renaming keys to match vllm
|
||||||
|
3. Filtering args to match vllm's AsyncEngineArgs
|
||||||
|
|
||||||
|
Args:
|
||||||
|
args (dict): Dictionary of args
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: Dictionary of args with renamed keys
|
||||||
|
"""
|
||||||
|
renamed_args = {RENAME_ARGS_MAP.get(k, k): v for k, v in args.items()}
|
||||||
|
matched_args = {k: v for k, v in renamed_args.items() if k in AsyncEngineArgs.__dataclass_fields__}
|
||||||
|
return {k: v for k, v in matched_args.items() if v not in [None, ""]}
|
||||||
|
def get_local_args():
|
||||||
|
"""
|
||||||
|
Retrieve local arguments from a JSON file.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: Local arguments.
|
||||||
|
"""
|
||||||
|
if not os.path.exists("/local_model_args.json"):
|
||||||
|
return {}
|
||||||
|
|
||||||
|
with open("/local_model_args.json", "r") as f:
|
||||||
|
local_args = json.load(f)
|
||||||
|
|
||||||
|
if local_args.get("MODEL_NAME") is None:
|
||||||
|
raise ValueError("Model name not found in /local_model_args.json. There was a problem when baking the model in.")
|
||||||
|
|
||||||
|
logging.info(f"Using baked in model with args: {local_args}")
|
||||||
|
os.environ["TRANSFORMERS_OFFLINE"] = "1"
|
||||||
|
os.environ["HF_HUB_OFFLINE"] = "1"
|
||||||
|
|
||||||
|
return local_args
|
||||||
|
def get_engine_args():
|
||||||
|
# Start with default args
|
||||||
|
args = DEFAULT_ARGS
|
||||||
|
|
||||||
|
# Get env args that match keys in AsyncEngineArgs
|
||||||
|
args.update(os.environ)
|
||||||
|
|
||||||
|
# Get local args if model is baked in and overwrite env args
|
||||||
|
args.update(get_local_args())
|
||||||
|
|
||||||
|
# if args.get("TENSORIZER_URI"): TODO: add back once tensorizer is ready
|
||||||
|
# args["load_format"] = "tensorizer"
|
||||||
|
# args["model_loader_extra_config"] = TensorizerConfig(tensorizer_uri=args["TENSORIZER_URI"], num_readers=None)
|
||||||
|
# logging.info(f"Using tensorized model from {args['TENSORIZER_URI']}")
|
||||||
|
|
||||||
|
|
||||||
|
# Rename and match to vllm args
|
||||||
|
args = match_vllm_args(args)
|
||||||
|
|
||||||
|
# Set tensor parallel size and max parallel loading workers if more than 1 GPU is available
|
||||||
|
num_gpus = device_count()
|
||||||
|
if num_gpus > 1:
|
||||||
|
args["tensor_parallel_size"] = num_gpus
|
||||||
|
args["max_parallel_loading_workers"] = None
|
||||||
|
if os.getenv("MAX_PARALLEL_LOADING_WORKERS"):
|
||||||
|
logging.warning("Overriding MAX_PARALLEL_LOADING_WORKERS with None because more than 1 GPU is available.")
|
||||||
|
|
||||||
|
# Deprecated env args backwards compatibility
|
||||||
|
if args.get("kv_cache_dtype") == "fp8_e5m2":
|
||||||
|
args["kv_cache_dtype"] = "fp8"
|
||||||
|
logging.warning("Using fp8_e5m2 is deprecated. Please use fp8 instead.")
|
||||||
|
if os.getenv("MAX_CONTEXT_LEN_TO_CAPTURE"):
|
||||||
|
args["max_seq_len_to_capture"] = int(os.getenv("MAX_CONTEXT_LEN_TO_CAPTURE"))
|
||||||
|
logging.warning("Using MAX_CONTEXT_LEN_TO_CAPTURE is deprecated. Please use MAX_SEQ_LEN_TO_CAPTURE instead.")
|
||||||
|
|
||||||
|
# if "gemma-2" in args.get("model", "").lower():
|
||||||
|
# os.environ["VLLM_ATTENTION_BACKEND"] = "FLASHINFER"
|
||||||
|
# logging.info("Using FLASHINFER for gemma-2 model.")
|
||||||
|
|
||||||
|
return AsyncEngineArgs(**args)
|
||||||
+12
-57
@@ -1,67 +1,22 @@
|
|||||||
#!/usr/bin/env python
|
import os
|
||||||
from typing import Generator
|
|
||||||
import runpod
|
import runpod
|
||||||
from utils import validate_sampling_params, random_uuid
|
from utils import JobInput
|
||||||
from engine import vLLMEngine
|
from engine import vLLMEngine, OpenAIvLLMEngine
|
||||||
|
|
||||||
vllm_engine = vLLMEngine()
|
vllm_engine = vLLMEngine()
|
||||||
async def handler(job: dict) -> Generator[dict, None, None]:
|
OpenAIvLLMEngine = OpenAIvLLMEngine(vllm_engine)
|
||||||
job_input = job["input"]
|
|
||||||
llm_input = job_input.get("messages", job_input.get("prompt"))
|
|
||||||
apply_chat_template = job_input.get("apply_chat_template", False)
|
|
||||||
|
|
||||||
if apply_chat_template or isinstance(llm_input, list):
|
async def handler(job):
|
||||||
llm_input = vllm_engine.tokenizer.apply_chat_template(llm_input)
|
job_input = JobInput(job["input"])
|
||||||
|
engine = OpenAIvLLMEngine if job_input.openai_route else vllm_engine
|
||||||
stream = job_input.get("stream", False)
|
results_generator = engine.generate(job_input)
|
||||||
batch_size = job_input.get("batch_size", vllm_engine.serverless_config.default_batch_size)
|
async for batch in results_generator:
|
||||||
sampling_params = job_input.get("sampling_params", {})
|
yield batch
|
||||||
|
|
||||||
validated_params = validate_sampling_params(sampling_params)
|
|
||||||
request_id = random_uuid()
|
|
||||||
results_generator = vllm_engine.llm.generate(
|
|
||||||
llm_input, validated_params, request_id
|
|
||||||
)
|
|
||||||
|
|
||||||
batch = {"tokens": []}
|
|
||||||
last_output_text = ""
|
|
||||||
n_input_tokens, is_first_output = 0, True
|
|
||||||
|
|
||||||
async for request_output in results_generator:
|
|
||||||
if is_first_output: # Count input tokens only once
|
|
||||||
n_input_tokens = len(request_output.prompt_token_ids)
|
|
||||||
is_first_output = False
|
|
||||||
|
|
||||||
for output in request_output.outputs:
|
|
||||||
if stream:
|
|
||||||
|
|
||||||
batch["tokens"].append(
|
|
||||||
output.text[len(last_output_text):]
|
|
||||||
)
|
|
||||||
finished = request_output.finished
|
|
||||||
if len(batch["tokens"]) >= batch_size or finished:
|
|
||||||
batch["usage"] = {
|
|
||||||
"input": n_input_tokens,
|
|
||||||
"output": len(output.token_ids),
|
|
||||||
}
|
|
||||||
batch["finished"] = finished
|
|
||||||
yield batch
|
|
||||||
batch = {"tokens": []}
|
|
||||||
|
|
||||||
last_output_text = output.text
|
|
||||||
|
|
||||||
if not stream:
|
|
||||||
yield {"tokens": [last_output_text],
|
|
||||||
"usage": {
|
|
||||||
"input": n_input_tokens,
|
|
||||||
"output": len(output.token_ids),
|
|
||||||
},
|
|
||||||
"finished": True}
|
|
||||||
|
|
||||||
runpod.serverless.start(
|
runpod.serverless.start(
|
||||||
{
|
{
|
||||||
"handler": handler,
|
"handler": handler,
|
||||||
"concurrency_modifier": lambda x: vllm_engine.serverless_config.max_concurrency,
|
"concurrency_modifier": lambda x: vllm_engine.max_concurrency,
|
||||||
"return_aggregate_stream": True,
|
"return_aggregate_stream": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
from transformers import AutoTokenizer
|
||||||
|
import os
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
class TokenizerWrapper:
|
||||||
|
def __init__(self, tokenizer_name_or_path, tokenizer_revision, trust_remote_code):
|
||||||
|
print(f"tokenizer_name_or_path: {tokenizer_name_or_path}, tokenizer_revision: {tokenizer_revision}, trust_remote_code: {trust_remote_code}")
|
||||||
|
self.tokenizer = AutoTokenizer.from_pretrained(tokenizer_name_or_path, revision=tokenizer_revision or "main", trust_remote_code=trust_remote_code)
|
||||||
|
self.custom_chat_template = os.getenv("CUSTOM_CHAT_TEMPLATE")
|
||||||
|
self.has_chat_template = bool(self.tokenizer.chat_template) or bool(self.custom_chat_template)
|
||||||
|
if self.custom_chat_template and isinstance(self.custom_chat_template, str):
|
||||||
|
self.tokenizer.chat_template = self.custom_chat_template
|
||||||
|
|
||||||
|
def apply_chat_template(self, input: Union[str, list[dict[str, str]]]) -> str:
|
||||||
|
if isinstance(input, list):
|
||||||
|
if not self.has_chat_template:
|
||||||
|
raise ValueError(
|
||||||
|
"Chat template does not exist for this model, you must provide a single string input instead of a list of messages"
|
||||||
|
)
|
||||||
|
elif isinstance(input, str):
|
||||||
|
input = [{"role": "user", "content": input}]
|
||||||
|
else:
|
||||||
|
raise ValueError("Input must be a string or a list of messages")
|
||||||
|
|
||||||
|
return self.tokenizer.apply_chat_template(
|
||||||
|
input, tokenize=False, add_generation_prompt=True
|
||||||
|
)
|
||||||
+83
-41
@@ -1,51 +1,93 @@
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict
|
from http import HTTPStatus
|
||||||
from vllm import SamplingParams
|
from functools import wraps
|
||||||
from vllm.utils import random_uuid
|
from time import time
|
||||||
from constants import sampling_param_types, DEFAULT_BATCH_SIZE, DEFAULT_MAX_CONCURRENCY
|
from vllm.entrypoints.openai.protocol import RequestResponseMetadata
|
||||||
|
|
||||||
|
try:
|
||||||
|
from vllm.utils import random_uuid
|
||||||
|
from vllm.entrypoints.openai.protocol import ErrorResponse
|
||||||
|
from vllm import SamplingParams
|
||||||
|
except ImportError:
|
||||||
|
logging.warning("Error importing vllm, skipping related imports. This is ONLY expected when baking model into docker image from a machine without GPUs")
|
||||||
|
pass
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
def count_physical_cores():
|
||||||
|
with open('/proc/cpuinfo') as f:
|
||||||
|
content = f.readlines()
|
||||||
|
|
||||||
class ServerlessConfig:
|
cores = set()
|
||||||
|
current_physical_id = None
|
||||||
|
current_core_id = None
|
||||||
|
|
||||||
|
for line in content:
|
||||||
|
if 'physical id' in line:
|
||||||
|
current_physical_id = line.strip().split(': ')[1]
|
||||||
|
elif 'core id' in line:
|
||||||
|
current_core_id = line.strip().split(': ')[1]
|
||||||
|
cores.add((current_physical_id, current_core_id))
|
||||||
|
|
||||||
|
return len(cores)
|
||||||
|
|
||||||
|
|
||||||
|
class JobInput:
|
||||||
|
def __init__(self, job):
|
||||||
|
self.llm_input = job.get("messages", job.get("prompt"))
|
||||||
|
self.stream = job.get("stream", False)
|
||||||
|
self.max_batch_size = job.get("max_batch_size")
|
||||||
|
self.apply_chat_template = job.get("apply_chat_template", False)
|
||||||
|
self.use_openai_format = job.get("use_openai_format", False)
|
||||||
|
self.sampling_params = SamplingParams(**job.get("sampling_params", {}))
|
||||||
|
self.request_id = random_uuid()
|
||||||
|
batch_size_growth_factor = job.get("batch_size_growth_factor")
|
||||||
|
self.batch_size_growth_factor = float(batch_size_growth_factor) if batch_size_growth_factor else None
|
||||||
|
min_batch_size = job.get("min_batch_size")
|
||||||
|
self.min_batch_size = int(min_batch_size) if min_batch_size else None
|
||||||
|
self.openai_route = job.get("openai_route")
|
||||||
|
self.openai_input = job.get("openai_input")
|
||||||
|
class DummyState:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._max_concurrency = int(
|
self.request_metadata = None
|
||||||
os.environ.get("MAX_CONCURRENCY", DEFAULT_MAX_CONCURRENCY)
|
|
||||||
)
|
class DummyRequest:
|
||||||
self._default_batch_size = int(
|
def __init__(self):
|
||||||
os.environ.get("DEFAULT_BATCH_SIZE", DEFAULT_BATCH_SIZE)
|
self.headers = {}
|
||||||
)
|
self.state = DummyState()
|
||||||
|
async def is_disconnected(self):
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
class BatchSize:
|
||||||
def max_concurrency(self):
|
def __init__(self, max_batch_size, min_batch_size, batch_size_growth_factor):
|
||||||
return self._max_concurrency
|
self.max_batch_size = max_batch_size
|
||||||
|
self.batch_size_growth_factor = batch_size_growth_factor
|
||||||
@property
|
self.min_batch_size = min_batch_size
|
||||||
def default_batch_size(self):
|
self.is_dynamic = batch_size_growth_factor > 1 and min_batch_size >= 1 and max_batch_size > min_batch_size
|
||||||
return self._default_batch_size
|
if self.is_dynamic:
|
||||||
|
self.current_batch_size = min_batch_size
|
||||||
|
|
||||||
def validate_sampling_params(params: Dict[str, Any]) -> SamplingParams:
|
|
||||||
validated_params = {}
|
|
||||||
|
|
||||||
for key, value in params.items():
|
|
||||||
expected_type = sampling_param_types.get(key)
|
|
||||||
if value is None:
|
|
||||||
validated_params[key] = None
|
|
||||||
continue
|
|
||||||
|
|
||||||
if expected_type is None:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if isinstance(expected_type, tuple):
|
|
||||||
casted_value = next(
|
|
||||||
(t(value) for t in expected_type if isinstance(value, t)), None
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
casted_value = value if isinstance(value, expected_type) else None
|
self.current_batch_size = max_batch_size
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
if self.is_dynamic:
|
||||||
|
self.current_batch_size = min(self.current_batch_size*self.batch_size_growth_factor, self.max_batch_size)
|
||||||
|
|
||||||
|
def create_error_response(message: str, err_type: str = "BadRequestError", status_code: HTTPStatus = HTTPStatus.BAD_REQUEST) -> ErrorResponse:
|
||||||
|
return ErrorResponse(message=message,
|
||||||
|
type=err_type,
|
||||||
|
code=status_code.value)
|
||||||
|
|
||||||
|
def get_int_bool_env(env_var: str, default: bool) -> bool:
|
||||||
|
return int(os.getenv(env_var, int(default))) == 1
|
||||||
|
|
||||||
if casted_value is not None:
|
def timer_decorator(func):
|
||||||
validated_params[key] = casted_value
|
@wraps(func)
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
return SamplingParams(**validated_params)
|
start = time()
|
||||||
|
result = func(*args, **kwargs)
|
||||||
|
end = time()
|
||||||
|
logging.info(f"{func.__name__} completed in {end - start:.2f} seconds")
|
||||||
|
return result
|
||||||
|
return wrapper
|
||||||
Submodule
+1
Submodule vllm-base-image/vllm added at 6a1a31c41e
@@ -0,0 +1,996 @@
|
|||||||
|
{
|
||||||
|
"versions": {
|
||||||
|
"0.6.4": {
|
||||||
|
"imageName": "runpod/worker-v1-vllm:v1.6.0stable-cuda12.1.0",
|
||||||
|
"minimumCudaVersion": "12.1",
|
||||||
|
"categories": [
|
||||||
|
{
|
||||||
|
"title": "LLM Settings",
|
||||||
|
"settings": [
|
||||||
|
"TOKENIZER", "TOKENIZER_MODE", "SKIP_TOKENIZER_INIT", "TRUST_REMOTE_CODE",
|
||||||
|
"DOWNLOAD_DIR", "LOAD_FORMAT", "DTYPE", "KV_CACHE_DTYPE", "QUANTIZATION_PARAM_PATH",
|
||||||
|
"MAX_MODEL_LEN", "GUIDED_DECODING_BACKEND", "DISTRIBUTED_EXECUTOR_BACKEND",
|
||||||
|
"WORKER_USE_RAY", "RAY_WORKERS_USE_NSIGHT", "PIPELINE_PARALLEL_SIZE",
|
||||||
|
"TENSOR_PARALLEL_SIZE", "MAX_PARALLEL_LOADING_WORKERS", "ENABLE_PREFIX_CACHING",
|
||||||
|
"DISABLE_SLIDING_WINDOW", "NUM_LOOKAHEAD_SLOTS",
|
||||||
|
"SEED", "NUM_GPU_BLOCKS_OVERRIDE", "MAX_NUM_BATCHED_TOKENS", "MAX_NUM_SEQS",
|
||||||
|
"MAX_LOGPROBS", "DISABLE_LOG_STATS", "QUANTIZATION", "ROPE_SCALING", "ROPE_THETA",
|
||||||
|
"TOKENIZER_POOL_SIZE", "TOKENIZER_POOL_TYPE", "TOKENIZER_POOL_EXTRA_CONFIG",
|
||||||
|
"ENABLE_LORA", "MAX_LORAS", "MAX_LORA_RANK", "LORA_EXTRA_VOCAB_SIZE",
|
||||||
|
"LORA_DTYPE", "LONG_LORA_SCALING_FACTORS", "MAX_CPU_LORAS", "FULLY_SHARDED_LORAS",
|
||||||
|
"DEVICE", "SCHEDULER_DELAY_FACTOR", "ENABLE_CHUNKED_PREFILL", "SPECULATIVE_MODEL",
|
||||||
|
"NUM_SPECULATIVE_TOKENS", "SPECULATIVE_DRAFT_TENSOR_PARALLEL_SIZE",
|
||||||
|
"SPECULATIVE_MAX_MODEL_LEN", "SPECULATIVE_DISABLE_BY_BATCH_SIZE",
|
||||||
|
"NGRAM_PROMPT_LOOKUP_MAX", "NGRAM_PROMPT_LOOKUP_MIN", "SPEC_DECODING_ACCEPTANCE_METHOD",
|
||||||
|
"TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_THRESHOLD", "TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_ALPHA",
|
||||||
|
"MODEL_LOADER_EXTRA_CONFIG", "PREEMPTION_MODE", "PREEMPTION_CHECK_PERIOD",
|
||||||
|
"PREEMPTION_CPU_CAPACITY", "MAX_LOG_LEN", "DISABLE_LOGGING_REQUEST"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Tokenizer Settings",
|
||||||
|
"settings": [
|
||||||
|
"TOKENIZER_NAME", "TOKENIZER_REVISION", "CUSTOM_CHAT_TEMPLATE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "System Settings",
|
||||||
|
"settings": [
|
||||||
|
"GPU_MEMORY_UTILIZATION", "MAX_PARALLEL_LOADING_WORKERS", "BLOCK_SIZE",
|
||||||
|
"SWAP_SPACE", "ENFORCE_EAGER", "MAX_SEQ_LEN_TO_CAPTURE", "DISABLE_CUSTOM_ALL_REDUCE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Streaming Settings",
|
||||||
|
"settings": [
|
||||||
|
"DEFAULT_BATCH_SIZE", "DEFAULT_MIN_BATCH_SIZE", "DEFAULT_BATCH_SIZE_GROWTH_FACTOR"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "OpenAI Settings",
|
||||||
|
"settings": [
|
||||||
|
"RAW_OPENAI_OUTPUT", "OPENAI_RESPONSE_ROLE", "OPENAI_SERVED_MODEL_NAME_OVERRIDE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Serverless Settings",
|
||||||
|
"settings": [
|
||||||
|
"MAX_CONCURRENCY", "DISABLE_LOG_STATS", "DISABLE_LOG_REQUESTS"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"0.6.3": {
|
||||||
|
"imageName": "runpod/worker-v1-vllm:v1.6.0stable-cuda12.1.0",
|
||||||
|
"minimumCudaVersion": "12.1",
|
||||||
|
"categories": [
|
||||||
|
{
|
||||||
|
"title": "LLM Settings",
|
||||||
|
"settings": [
|
||||||
|
"TOKENIZER", "TOKENIZER_MODE", "SKIP_TOKENIZER_INIT", "TRUST_REMOTE_CODE",
|
||||||
|
"DOWNLOAD_DIR", "LOAD_FORMAT", "DTYPE", "KV_CACHE_DTYPE", "QUANTIZATION_PARAM_PATH",
|
||||||
|
"MAX_MODEL_LEN", "GUIDED_DECODING_BACKEND", "DISTRIBUTED_EXECUTOR_BACKEND",
|
||||||
|
"WORKER_USE_RAY", "RAY_WORKERS_USE_NSIGHT", "PIPELINE_PARALLEL_SIZE",
|
||||||
|
"TENSOR_PARALLEL_SIZE", "MAX_PARALLEL_LOADING_WORKERS", "ENABLE_PREFIX_CACHING",
|
||||||
|
"DISABLE_SLIDING_WINDOW", "NUM_LOOKAHEAD_SLOTS",
|
||||||
|
"SEED", "NUM_GPU_BLOCKS_OVERRIDE", "MAX_NUM_BATCHED_TOKENS", "MAX_NUM_SEQS",
|
||||||
|
"MAX_LOGPROBS", "DISABLE_LOG_STATS", "QUANTIZATION", "ROPE_SCALING", "ROPE_THETA",
|
||||||
|
"TOKENIZER_POOL_SIZE", "TOKENIZER_POOL_TYPE", "TOKENIZER_POOL_EXTRA_CONFIG",
|
||||||
|
"ENABLE_LORA", "MAX_LORAS", "MAX_LORA_RANK", "LORA_EXTRA_VOCAB_SIZE",
|
||||||
|
"LORA_DTYPE", "LONG_LORA_SCALING_FACTORS", "MAX_CPU_LORAS", "FULLY_SHARDED_LORAS",
|
||||||
|
"DEVICE", "SCHEDULER_DELAY_FACTOR", "ENABLE_CHUNKED_PREFILL", "SPECULATIVE_MODEL",
|
||||||
|
"NUM_SPECULATIVE_TOKENS", "SPECULATIVE_DRAFT_TENSOR_PARALLEL_SIZE",
|
||||||
|
"SPECULATIVE_MAX_MODEL_LEN", "SPECULATIVE_DISABLE_BY_BATCH_SIZE",
|
||||||
|
"NGRAM_PROMPT_LOOKUP_MAX", "NGRAM_PROMPT_LOOKUP_MIN", "SPEC_DECODING_ACCEPTANCE_METHOD",
|
||||||
|
"TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_THRESHOLD", "TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_ALPHA",
|
||||||
|
"MODEL_LOADER_EXTRA_CONFIG", "PREEMPTION_MODE", "PREEMPTION_CHECK_PERIOD",
|
||||||
|
"PREEMPTION_CPU_CAPACITY", "MAX_LOG_LEN", "DISABLE_LOGGING_REQUEST"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Tokenizer Settings",
|
||||||
|
"settings": [
|
||||||
|
"TOKENIZER_NAME", "TOKENIZER_REVISION", "CUSTOM_CHAT_TEMPLATE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "System Settings",
|
||||||
|
"settings": [
|
||||||
|
"GPU_MEMORY_UTILIZATION", "MAX_PARALLEL_LOADING_WORKERS", "BLOCK_SIZE",
|
||||||
|
"SWAP_SPACE", "ENFORCE_EAGER", "MAX_SEQ_LEN_TO_CAPTURE", "DISABLE_CUSTOM_ALL_REDUCE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Streaming Settings",
|
||||||
|
"settings": [
|
||||||
|
"DEFAULT_BATCH_SIZE", "DEFAULT_MIN_BATCH_SIZE", "DEFAULT_BATCH_SIZE_GROWTH_FACTOR"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "OpenAI Settings",
|
||||||
|
"settings": [
|
||||||
|
"RAW_OPENAI_OUTPUT", "OPENAI_RESPONSE_ROLE", "OPENAI_SERVED_MODEL_NAME_OVERRIDE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Serverless Settings",
|
||||||
|
"settings": [
|
||||||
|
"MAX_CONCURRENCY", "DISABLE_LOG_STATS", "DISABLE_LOG_REQUESTS"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"0.6.2": {
|
||||||
|
"imageName": "runpod/worker-v1-vllm:v1.5.0stable-cuda12.1.0",
|
||||||
|
"minimumCudaVersion": "12.1",
|
||||||
|
"categories": [
|
||||||
|
{
|
||||||
|
"title": "LLM Settings",
|
||||||
|
"settings": [
|
||||||
|
"TOKENIZER", "TOKENIZER_MODE", "SKIP_TOKENIZER_INIT", "TRUST_REMOTE_CODE",
|
||||||
|
"DOWNLOAD_DIR", "LOAD_FORMAT", "DTYPE", "KV_CACHE_DTYPE", "QUANTIZATION_PARAM_PATH",
|
||||||
|
"MAX_MODEL_LEN", "GUIDED_DECODING_BACKEND", "DISTRIBUTED_EXECUTOR_BACKEND",
|
||||||
|
"WORKER_USE_RAY", "RAY_WORKERS_USE_NSIGHT", "PIPELINE_PARALLEL_SIZE",
|
||||||
|
"TENSOR_PARALLEL_SIZE", "MAX_PARALLEL_LOADING_WORKERS", "ENABLE_PREFIX_CACHING",
|
||||||
|
"DISABLE_SLIDING_WINDOW", "USE_V2_BLOCK_MANAGER", "NUM_LOOKAHEAD_SLOTS",
|
||||||
|
"SEED", "NUM_GPU_BLOCKS_OVERRIDE", "MAX_NUM_BATCHED_TOKENS", "MAX_NUM_SEQS",
|
||||||
|
"MAX_LOGPROBS", "DISABLE_LOG_STATS", "QUANTIZATION", "ROPE_SCALING", "ROPE_THETA",
|
||||||
|
"TOKENIZER_POOL_SIZE", "TOKENIZER_POOL_TYPE", "TOKENIZER_POOL_EXTRA_CONFIG",
|
||||||
|
"ENABLE_LORA", "MAX_LORAS", "MAX_LORA_RANK", "LORA_EXTRA_VOCAB_SIZE",
|
||||||
|
"LORA_DTYPE", "LONG_LORA_SCALING_FACTORS", "MAX_CPU_LORAS", "FULLY_SHARDED_LORAS",
|
||||||
|
"DEVICE", "SCHEDULER_DELAY_FACTOR", "ENABLE_CHUNKED_PREFILL", "SPECULATIVE_MODEL",
|
||||||
|
"NUM_SPECULATIVE_TOKENS", "SPECULATIVE_DRAFT_TENSOR_PARALLEL_SIZE",
|
||||||
|
"SPECULATIVE_MAX_MODEL_LEN", "SPECULATIVE_DISABLE_BY_BATCH_SIZE",
|
||||||
|
"NGRAM_PROMPT_LOOKUP_MAX", "NGRAM_PROMPT_LOOKUP_MIN", "SPEC_DECODING_ACCEPTANCE_METHOD",
|
||||||
|
"TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_THRESHOLD", "TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_ALPHA",
|
||||||
|
"MODEL_LOADER_EXTRA_CONFIG", "PREEMPTION_MODE", "PREEMPTION_CHECK_PERIOD",
|
||||||
|
"PREEMPTION_CPU_CAPACITY", "MAX_LOG_LEN", "DISABLE_LOGGING_REQUEST"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Tokenizer Settings",
|
||||||
|
"settings": [
|
||||||
|
"TOKENIZER_NAME", "TOKENIZER_REVISION", "CUSTOM_CHAT_TEMPLATE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "System Settings",
|
||||||
|
"settings": [
|
||||||
|
"GPU_MEMORY_UTILIZATION", "MAX_PARALLEL_LOADING_WORKERS", "BLOCK_SIZE",
|
||||||
|
"SWAP_SPACE", "ENFORCE_EAGER", "MAX_SEQ_LEN_TO_CAPTURE", "DISABLE_CUSTOM_ALL_REDUCE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Streaming Settings",
|
||||||
|
"settings": [
|
||||||
|
"DEFAULT_BATCH_SIZE", "DEFAULT_MIN_BATCH_SIZE", "DEFAULT_BATCH_SIZE_GROWTH_FACTOR"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "OpenAI Settings",
|
||||||
|
"settings": [
|
||||||
|
"RAW_OPENAI_OUTPUT", "OPENAI_RESPONSE_ROLE", "OPENAI_SERVED_MODEL_NAME_OVERRIDE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Serverless Settings",
|
||||||
|
"settings": [
|
||||||
|
"MAX_CONCURRENCY", "DISABLE_LOG_STATS", "DISABLE_LOG_REQUESTS"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"0.6.1": {
|
||||||
|
"imageName": "runpod/worker-v1-vllm:v1.4.0stable-cuda12.1.0",
|
||||||
|
"minimumCudaVersion": "12.1",
|
||||||
|
"categories": [
|
||||||
|
{
|
||||||
|
"title": "LLM Settings",
|
||||||
|
"settings": [
|
||||||
|
"TOKENIZER", "TOKENIZER_MODE", "SKIP_TOKENIZER_INIT", "TRUST_REMOTE_CODE",
|
||||||
|
"DOWNLOAD_DIR", "LOAD_FORMAT", "DTYPE", "KV_CACHE_DTYPE", "QUANTIZATION_PARAM_PATH",
|
||||||
|
"MAX_MODEL_LEN", "GUIDED_DECODING_BACKEND", "DISTRIBUTED_EXECUTOR_BACKEND",
|
||||||
|
"WORKER_USE_RAY", "RAY_WORKERS_USE_NSIGHT", "PIPELINE_PARALLEL_SIZE",
|
||||||
|
"TENSOR_PARALLEL_SIZE", "MAX_PARALLEL_LOADING_WORKERS", "ENABLE_PREFIX_CACHING",
|
||||||
|
"DISABLE_SLIDING_WINDOW", "USE_V2_BLOCK_MANAGER", "NUM_LOOKAHEAD_SLOTS",
|
||||||
|
"SEED", "NUM_GPU_BLOCKS_OVERRIDE", "MAX_NUM_BATCHED_TOKENS", "MAX_NUM_SEQS",
|
||||||
|
"MAX_LOGPROBS", "DISABLE_LOG_STATS", "QUANTIZATION", "ROPE_SCALING", "ROPE_THETA",
|
||||||
|
"TOKENIZER_POOL_SIZE", "TOKENIZER_POOL_TYPE", "TOKENIZER_POOL_EXTRA_CONFIG",
|
||||||
|
"ENABLE_LORA", "MAX_LORAS", "MAX_LORA_RANK", "LORA_EXTRA_VOCAB_SIZE",
|
||||||
|
"LORA_DTYPE", "LONG_LORA_SCALING_FACTORS", "MAX_CPU_LORAS", "FULLY_SHARDED_LORAS",
|
||||||
|
"DEVICE", "SCHEDULER_DELAY_FACTOR", "ENABLE_CHUNKED_PREFILL", "SPECULATIVE_MODEL",
|
||||||
|
"NUM_SPECULATIVE_TOKENS", "SPECULATIVE_DRAFT_TENSOR_PARALLEL_SIZE",
|
||||||
|
"SPECULATIVE_MAX_MODEL_LEN", "SPECULATIVE_DISABLE_BY_BATCH_SIZE",
|
||||||
|
"NGRAM_PROMPT_LOOKUP_MAX", "NGRAM_PROMPT_LOOKUP_MIN", "SPEC_DECODING_ACCEPTANCE_METHOD",
|
||||||
|
"TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_THRESHOLD", "TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_ALPHA",
|
||||||
|
"MODEL_LOADER_EXTRA_CONFIG", "PREEMPTION_MODE", "PREEMPTION_CHECK_PERIOD",
|
||||||
|
"PREEMPTION_CPU_CAPACITY", "MAX_LOG_LEN", "DISABLE_LOGGING_REQUEST"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Tokenizer Settings",
|
||||||
|
"settings": [
|
||||||
|
"TOKENIZER_NAME", "TOKENIZER_REVISION", "CUSTOM_CHAT_TEMPLATE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "System Settings",
|
||||||
|
"settings": [
|
||||||
|
"GPU_MEMORY_UTILIZATION", "MAX_PARALLEL_LOADING_WORKERS", "BLOCK_SIZE",
|
||||||
|
"SWAP_SPACE", "ENFORCE_EAGER", "MAX_SEQ_LEN_TO_CAPTURE", "DISABLE_CUSTOM_ALL_REDUCE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Streaming Settings",
|
||||||
|
"settings": [
|
||||||
|
"DEFAULT_BATCH_SIZE", "DEFAULT_MIN_BATCH_SIZE", "DEFAULT_BATCH_SIZE_GROWTH_FACTOR"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "OpenAI Settings",
|
||||||
|
"settings": [
|
||||||
|
"RAW_OPENAI_OUTPUT", "OPENAI_RESPONSE_ROLE", "OPENAI_SERVED_MODEL_NAME_OVERRIDE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Serverless Settings",
|
||||||
|
"settings": [
|
||||||
|
"MAX_CONCURRENCY", "DISABLE_LOG_STATS", "DISABLE_LOG_REQUESTS"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"0.5.5": {
|
||||||
|
"imageName": "runpod/worker-v1-vllm:v1.3.1stable-cuda12.1.0",
|
||||||
|
"minimumCudaVersion": "12.1",
|
||||||
|
"categories": [
|
||||||
|
{
|
||||||
|
"title": "LLM Settings",
|
||||||
|
"settings": [
|
||||||
|
"TOKENIZER", "TOKENIZER_MODE", "SKIP_TOKENIZER_INIT", "TRUST_REMOTE_CODE",
|
||||||
|
"DOWNLOAD_DIR", "LOAD_FORMAT", "DTYPE", "KV_CACHE_DTYPE", "QUANTIZATION_PARAM_PATH",
|
||||||
|
"MAX_MODEL_LEN", "GUIDED_DECODING_BACKEND", "DISTRIBUTED_EXECUTOR_BACKEND",
|
||||||
|
"WORKER_USE_RAY", "RAY_WORKERS_USE_NSIGHT", "PIPELINE_PARALLEL_SIZE",
|
||||||
|
"TENSOR_PARALLEL_SIZE", "MAX_PARALLEL_LOADING_WORKERS", "ENABLE_PREFIX_CACHING",
|
||||||
|
"DISABLE_SLIDING_WINDOW", "USE_V2_BLOCK_MANAGER", "NUM_LOOKAHEAD_SLOTS",
|
||||||
|
"SEED", "NUM_GPU_BLOCKS_OVERRIDE", "MAX_NUM_BATCHED_TOKENS", "MAX_NUM_SEQS",
|
||||||
|
"MAX_LOGPROBS", "DISABLE_LOG_STATS", "QUANTIZATION", "ROPE_SCALING", "ROPE_THETA",
|
||||||
|
"TOKENIZER_POOL_SIZE", "TOKENIZER_POOL_TYPE", "TOKENIZER_POOL_EXTRA_CONFIG",
|
||||||
|
"ENABLE_LORA", "MAX_LORAS", "MAX_LORA_RANK", "LORA_EXTRA_VOCAB_SIZE",
|
||||||
|
"LORA_DTYPE", "LONG_LORA_SCALING_FACTORS", "MAX_CPU_LORAS", "FULLY_SHARDED_LORAS",
|
||||||
|
"DEVICE", "SCHEDULER_DELAY_FACTOR", "ENABLE_CHUNKED_PREFILL", "SPECULATIVE_MODEL",
|
||||||
|
"NUM_SPECULATIVE_TOKENS", "SPECULATIVE_DRAFT_TENSOR_PARALLEL_SIZE",
|
||||||
|
"SPECULATIVE_MAX_MODEL_LEN", "SPECULATIVE_DISABLE_BY_BATCH_SIZE",
|
||||||
|
"NGRAM_PROMPT_LOOKUP_MAX", "NGRAM_PROMPT_LOOKUP_MIN", "SPEC_DECODING_ACCEPTANCE_METHOD",
|
||||||
|
"TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_THRESHOLD", "TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_ALPHA",
|
||||||
|
"MODEL_LOADER_EXTRA_CONFIG", "PREEMPTION_MODE", "PREEMPTION_CHECK_PERIOD",
|
||||||
|
"PREEMPTION_CPU_CAPACITY", "MAX_LOG_LEN", "DISABLE_LOGGING_REQUEST"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Tokenizer Settings",
|
||||||
|
"settings": [
|
||||||
|
"TOKENIZER_NAME", "TOKENIZER_REVISION", "CUSTOM_CHAT_TEMPLATE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "System Settings",
|
||||||
|
"settings": [
|
||||||
|
"GPU_MEMORY_UTILIZATION", "MAX_PARALLEL_LOADING_WORKERS", "BLOCK_SIZE",
|
||||||
|
"SWAP_SPACE", "ENFORCE_EAGER", "MAX_SEQ_LEN_TO_CAPTURE", "DISABLE_CUSTOM_ALL_REDUCE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Streaming Settings",
|
||||||
|
"settings": [
|
||||||
|
"DEFAULT_BATCH_SIZE", "DEFAULT_MIN_BATCH_SIZE", "DEFAULT_BATCH_SIZE_GROWTH_FACTOR"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "OpenAI Settings",
|
||||||
|
"settings": [
|
||||||
|
"RAW_OPENAI_OUTPUT", "OPENAI_RESPONSE_ROLE", "OPENAI_SERVED_MODEL_NAME_OVERRIDE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Serverless Settings",
|
||||||
|
"settings": [
|
||||||
|
"MAX_CONCURRENCY", "DISABLE_LOG_STATS", "DISABLE_LOG_REQUESTS"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"schema": {
|
||||||
|
"TOKENIZER": {
|
||||||
|
"env_var_name": "TOKENIZER",
|
||||||
|
"value": "",
|
||||||
|
"title": "Tokenizer",
|
||||||
|
"description": "Name or path of the Hugging Face tokenizer to use.",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"TOKENIZER_MODE": {
|
||||||
|
"env_var_name": "TOKENIZER_MODE",
|
||||||
|
"value": "auto",
|
||||||
|
"title": "Tokenizer Mode",
|
||||||
|
"description": "The tokenizer mode.",
|
||||||
|
"required": false,
|
||||||
|
"type": "select",
|
||||||
|
"options": [
|
||||||
|
{ "value": "auto", "label": "auto" },
|
||||||
|
{ "value": "slow", "label": "slow" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"SKIP_TOKENIZER_INIT": {
|
||||||
|
"env_var_name": "SKIP_TOKENIZER_INIT",
|
||||||
|
"value": false,
|
||||||
|
"title": "Skip Tokenizer Init",
|
||||||
|
"description": "Skip initialization of tokenizer and detokenizer.",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"TRUST_REMOTE_CODE": {
|
||||||
|
"env_var_name": "TRUST_REMOTE_CODE",
|
||||||
|
"value": false,
|
||||||
|
"title": "Trust Remote Code",
|
||||||
|
"description": "Trust remote code from Hugging Face.",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"DOWNLOAD_DIR": {
|
||||||
|
"env_var_name": "DOWNLOAD_DIR",
|
||||||
|
"value": "",
|
||||||
|
"title": "Download Directory",
|
||||||
|
"description": "Directory to download and load the weights.",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"LOAD_FORMAT": {
|
||||||
|
"env_var_name": "LOAD_FORMAT",
|
||||||
|
"value": "auto",
|
||||||
|
"title": "Load Format",
|
||||||
|
"description": "The format of the model weights to load.",
|
||||||
|
"required": false,
|
||||||
|
"type": "select",
|
||||||
|
"options": [
|
||||||
|
{ "value": "auto", "label": "auto" },
|
||||||
|
{ "value": "pt", "label": "pt" },
|
||||||
|
{ "value": "safetensors", "label": "safetensors" },
|
||||||
|
{ "value": "npcache", "label": "npcache" },
|
||||||
|
{ "value": "dummy", "label": "dummy" },
|
||||||
|
{ "value": "tensorizer", "label": "tensorizer" },
|
||||||
|
{ "value": "bitsandbytes", "label": "bitsandbytes" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"DTYPE": {
|
||||||
|
"env_var_name": "DTYPE",
|
||||||
|
"value": "auto",
|
||||||
|
"title": "Data Type",
|
||||||
|
"description": "Data type for model weights and activations.",
|
||||||
|
"required": false,
|
||||||
|
"type": "select",
|
||||||
|
"options": [
|
||||||
|
{ "value": "auto", "label": "auto" },
|
||||||
|
{ "value": "half", "label": "half" },
|
||||||
|
{ "value": "float16", "label": "float16" },
|
||||||
|
{ "value": "bfloat16", "label": "bfloat16" },
|
||||||
|
{ "value": "float", "label": "float" },
|
||||||
|
{ "value": "float32", "label": "float32" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"KV_CACHE_DTYPE": {
|
||||||
|
"env_var_name": "KV_CACHE_DTYPE",
|
||||||
|
"value": "auto",
|
||||||
|
"title": "KV Cache Data Type",
|
||||||
|
"description": "Data type for KV cache storage.",
|
||||||
|
"required": false,
|
||||||
|
"type": "select",
|
||||||
|
"options": [
|
||||||
|
{ "value": "auto", "label": "auto" },
|
||||||
|
{ "value": "fp8", "label": "fp8" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"QUANTIZATION_PARAM_PATH": {
|
||||||
|
"env_var_name": "QUANTIZATION_PARAM_PATH",
|
||||||
|
"value": "",
|
||||||
|
"title": "Quantization Param Path",
|
||||||
|
"description": "Path to the JSON file containing the KV cache scaling factors.",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"MAX_MODEL_LEN": {
|
||||||
|
"env_var_name": "MAX_MODEL_LEN",
|
||||||
|
"value": "",
|
||||||
|
"title": "Max Model Length",
|
||||||
|
"description": "Model context length.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"GUIDED_DECODING_BACKEND": {
|
||||||
|
"env_var_name": "GUIDED_DECODING_BACKEND",
|
||||||
|
"value": "outlines",
|
||||||
|
"title": "Guided Decoding Backend",
|
||||||
|
"description": "Which engine will be used for guided decoding by default.",
|
||||||
|
"required": false,
|
||||||
|
"type": "select",
|
||||||
|
"options": [
|
||||||
|
{ "value": "outlines", "label": "outlines" },
|
||||||
|
{ "value": "lm-format-enforcer", "label": "lm-format-enforcer" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"DISTRIBUTED_EXECUTOR_BACKEND": {
|
||||||
|
"env_var_name": "DISTRIBUTED_EXECUTOR_BACKEND",
|
||||||
|
"value": "",
|
||||||
|
"title": "Distributed Executor Backend",
|
||||||
|
"description": "Backend to use for distributed serving.",
|
||||||
|
"required": false,
|
||||||
|
"type": "select",
|
||||||
|
"options": [
|
||||||
|
{ "value": "ray", "label": "ray" },
|
||||||
|
{ "value": "mp", "label": "mp" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"WORKER_USE_RAY": {
|
||||||
|
"env_var_name": "WORKER_USE_RAY",
|
||||||
|
"value": false,
|
||||||
|
"title": "Worker Use Ray",
|
||||||
|
"description": "Deprecated, use --distributed-executor-backend=ray.",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"RAY_WORKERS_USE_NSIGHT": {
|
||||||
|
"env_var_name": "RAY_WORKERS_USE_NSIGHT",
|
||||||
|
"value": false,
|
||||||
|
"title": "Ray Workers Use Nsight",
|
||||||
|
"description": "If specified, use nsight to profile Ray workers.",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"PIPELINE_PARALLEL_SIZE": {
|
||||||
|
"env_var_name": "PIPELINE_PARALLEL_SIZE",
|
||||||
|
"value": 1,
|
||||||
|
"title": "Pipeline Parallel Size",
|
||||||
|
"description": "Number of pipeline stages.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"TENSOR_PARALLEL_SIZE": {
|
||||||
|
"env_var_name": "TENSOR_PARALLEL_SIZE",
|
||||||
|
"value": 1,
|
||||||
|
"title": "Tensor Parallel Size",
|
||||||
|
"description": "Number of tensor parallel replicas.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"MAX_PARALLEL_LOADING_WORKERS": {
|
||||||
|
"env_var_name": "MAX_PARALLEL_LOADING_WORKERS",
|
||||||
|
"value": "",
|
||||||
|
"title": "Max Parallel Loading Workers",
|
||||||
|
"description": "Load model sequentially in multiple batches.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"ENABLE_PREFIX_CACHING": {
|
||||||
|
"env_var_name": "ENABLE_PREFIX_CACHING",
|
||||||
|
"value": false,
|
||||||
|
"title": "Enable Prefix Caching",
|
||||||
|
"description": "Enables automatic prefix caching.",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"DISABLE_SLIDING_WINDOW": {
|
||||||
|
"env_var_name": "DISABLE_SLIDING_WINDOW",
|
||||||
|
"value": false,
|
||||||
|
"title": "Disable Sliding Window",
|
||||||
|
"description": "Disables sliding window, capping to sliding window size.",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"USE_V2_BLOCK_MANAGER": {
|
||||||
|
"env_var_name": "USE_V2_BLOCK_MANAGER",
|
||||||
|
"value": false,
|
||||||
|
"title": "Use V2 Block Manager",
|
||||||
|
"description": "Use BlockSpaceMangerV2.",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"NUM_LOOKAHEAD_SLOTS": {
|
||||||
|
"env_var_name": "NUM_LOOKAHEAD_SLOTS",
|
||||||
|
"value": 0,
|
||||||
|
"title": "Num Lookahead Slots",
|
||||||
|
"description": "Experimental scheduling config necessary for speculative decoding.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"SEED": {
|
||||||
|
"env_var_name": "SEED",
|
||||||
|
"value": 0,
|
||||||
|
"title": "Seed",
|
||||||
|
"description": "Random seed for operations.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"NUM_GPU_BLOCKS_OVERRIDE": {
|
||||||
|
"env_var_name": "NUM_GPU_BLOCKS_OVERRIDE",
|
||||||
|
"value": "",
|
||||||
|
"title": "Num GPU Blocks Override",
|
||||||
|
"description": "If specified, ignore GPU profiling result and use this number of GPU blocks.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"MAX_NUM_BATCHED_TOKENS": {
|
||||||
|
"env_var_name": "MAX_NUM_BATCHED_TOKENS",
|
||||||
|
"value": "",
|
||||||
|
"title": "Max Num Batched Tokens",
|
||||||
|
"description": "Maximum number of batched tokens per iteration.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"MAX_NUM_SEQS": {
|
||||||
|
"env_var_name": "MAX_NUM_SEQS",
|
||||||
|
"value": 256,
|
||||||
|
"title": "Max Num Seqs",
|
||||||
|
"description": "Maximum number of sequences per iteration.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"MAX_LOGPROBS": {
|
||||||
|
"env_var_name": "MAX_LOGPROBS",
|
||||||
|
"value": 20,
|
||||||
|
"title": "Max Logprobs",
|
||||||
|
"description": "Max number of log probs to return when logprobs is specified in SamplingParams.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"DISABLE_LOG_STATS": {
|
||||||
|
"env_var_name": "DISABLE_LOG_STATS",
|
||||||
|
"value": false,
|
||||||
|
"title": "Disable Log Stats",
|
||||||
|
"description": "Disable logging statistics.",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"QUANTIZATION": {
|
||||||
|
"env_var_name": "QUANTIZATION",
|
||||||
|
"value": "",
|
||||||
|
"title": "Quantization",
|
||||||
|
"description": "Method used to quantize the weights.",
|
||||||
|
"required": false,
|
||||||
|
"type": "select",
|
||||||
|
"options": [
|
||||||
|
{ "value": "None", "label": "None" },
|
||||||
|
{ "value": "awq", "label": "AWQ" },
|
||||||
|
{ "value": "squeezellm", "label": "SqueezeLLM" },
|
||||||
|
{ "value": "gptq", "label": "GPTQ" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ROPE_SCALING": {
|
||||||
|
"env_var_name": "ROPE_SCALING",
|
||||||
|
"value": "",
|
||||||
|
"title": "RoPE Scaling",
|
||||||
|
"description": "RoPE scaling configuration in JSON format.",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"ROPE_THETA": {
|
||||||
|
"env_var_name": "ROPE_THETA",
|
||||||
|
"value": "",
|
||||||
|
"title": "RoPE Theta",
|
||||||
|
"description": "RoPE theta. Use with rope_scaling.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"TOKENIZER_POOL_SIZE": {
|
||||||
|
"env_var_name": "TOKENIZER_POOL_SIZE",
|
||||||
|
"value": 0,
|
||||||
|
"title": "Tokenizer Pool Size",
|
||||||
|
"description": "Size of tokenizer pool to use for asynchronous tokenization.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"TOKENIZER_POOL_TYPE": {
|
||||||
|
"env_var_name": "TOKENIZER_POOL_TYPE",
|
||||||
|
"value": "ray",
|
||||||
|
"title": "Tokenizer Pool Type",
|
||||||
|
"description": "Type of tokenizer pool to use for asynchronous tokenization.",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"TOKENIZER_POOL_EXTRA_CONFIG": {
|
||||||
|
"env_var_name": "TOKENIZER_POOL_EXTRA_CONFIG",
|
||||||
|
"value": "",
|
||||||
|
"title": "Tokenizer Pool Extra Config",
|
||||||
|
"description": "Extra config for tokenizer pool.",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"ENABLE_LORA": {
|
||||||
|
"env_var_name": "ENABLE_LORA",
|
||||||
|
"value": false,
|
||||||
|
"title": "Enable LoRA",
|
||||||
|
"description": "If True, enable handling of LoRA adapters.",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"MAX_LORAS": {
|
||||||
|
"env_var_name": "MAX_LORAS",
|
||||||
|
"value": 1,
|
||||||
|
"title": "Max LoRAs",
|
||||||
|
"description": "Max number of LoRAs in a single batch.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"MAX_LORA_RANK": {
|
||||||
|
"env_var_name": "MAX_LORA_RANK",
|
||||||
|
"value": 16,
|
||||||
|
"title": "Max LoRA Rank",
|
||||||
|
"description": "Max LoRA rank.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"LORA_EXTRA_VOCAB_SIZE": {
|
||||||
|
"env_var_name": "LORA_EXTRA_VOCAB_SIZE",
|
||||||
|
"value": 256,
|
||||||
|
"title": "LoRA Extra Vocab Size",
|
||||||
|
"description": "Maximum size of extra vocabulary for LoRA adapters.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"LORA_DTYPE": {
|
||||||
|
"env_var_name": "LORA_DTYPE",
|
||||||
|
"value": "auto",
|
||||||
|
"title": "LoRA Data Type",
|
||||||
|
"description": "Data type for LoRA.",
|
||||||
|
"required": false,
|
||||||
|
"type": "select",
|
||||||
|
"options": [
|
||||||
|
{ "value": "auto", "label": "auto" },
|
||||||
|
{ "value": "float16", "label": "float16" },
|
||||||
|
{ "value": "bfloat16", "label": "bfloat16" },
|
||||||
|
{ "value": "float32", "label": "float32" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"LONG_LORA_SCALING_FACTORS": {
|
||||||
|
"env_var_name": "LONG_LORA_SCALING_FACTORS",
|
||||||
|
"value": "",
|
||||||
|
"title": "Long LoRA Scaling Factors",
|
||||||
|
"description": "Specify multiple scaling factors for LoRA adapters.",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"MAX_CPU_LORAS": {
|
||||||
|
"env_var_name": "MAX_CPU_LORAS",
|
||||||
|
"value": "",
|
||||||
|
"title": "Max CPU LoRAs",
|
||||||
|
"description": "Maximum number of LoRAs to store in CPU memory.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"FULLY_SHARDED_LORAS": {
|
||||||
|
"env_var_name": "FULLY_SHARDED_LORAS",
|
||||||
|
"value": false,
|
||||||
|
"title": "Fully Sharded LoRAs",
|
||||||
|
"description": "Enable fully sharded LoRA layers.",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"DEVICE": {
|
||||||
|
"env_var_name": "DEVICE",
|
||||||
|
"value": "auto",
|
||||||
|
"title": "Device",
|
||||||
|
"description": "Device type for vLLM execution.",
|
||||||
|
"required": false,
|
||||||
|
"type": "select",
|
||||||
|
"options": [
|
||||||
|
{ "value": "auto", "label": "auto" },
|
||||||
|
{ "value": "cuda", "label": "cuda" },
|
||||||
|
{ "value": "neuron", "label": "neuron" },
|
||||||
|
{ "value": "cpu", "label": "cpu" },
|
||||||
|
{ "value": "openvino", "label": "openvino" },
|
||||||
|
{ "value": "tpu", "label": "tpu" },
|
||||||
|
{ "value": "xpu", "label": "xpu" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"SCHEDULER_DELAY_FACTOR": {
|
||||||
|
"env_var_name": "SCHEDULER_DELAY_FACTOR",
|
||||||
|
"value": 0.0,
|
||||||
|
"title": "Scheduler Delay Factor",
|
||||||
|
"description": "Apply a delay before scheduling next prompt.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"ENABLE_CHUNKED_PREFILL": {
|
||||||
|
"env_var_name": "ENABLE_CHUNKED_PREFILL",
|
||||||
|
"value": false,
|
||||||
|
"title": "Enable Chunked Prefill",
|
||||||
|
"description": "Enable chunked prefill requests.",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"SPECULATIVE_MODEL": {
|
||||||
|
"env_var_name": "SPECULATIVE_MODEL",
|
||||||
|
"value": "",
|
||||||
|
"title": "Speculative Model",
|
||||||
|
"description": "The name of the draft model to be used in speculative decoding.",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"NUM_SPECULATIVE_TOKENS": {
|
||||||
|
"env_var_name": "NUM_SPECULATIVE_TOKENS",
|
||||||
|
"value": "",
|
||||||
|
"title": "Num Speculative Tokens",
|
||||||
|
"description": "The number of speculative tokens to sample from the draft model.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"SPECULATIVE_DRAFT_TENSOR_PARALLEL_SIZE": {
|
||||||
|
"env_var_name": "SPECULATIVE_DRAFT_TENSOR_PARALLEL_SIZE",
|
||||||
|
"value": "",
|
||||||
|
"title": "Speculative Draft Tensor Parallel Size",
|
||||||
|
"description": "Number of tensor parallel replicas for the draft model.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"SPECULATIVE_MAX_MODEL_LEN": {
|
||||||
|
"env_var_name": "SPECULATIVE_MAX_MODEL_LEN",
|
||||||
|
"value": "",
|
||||||
|
"title": "Speculative Max Model Length",
|
||||||
|
"description": "The maximum sequence length supported by the draft model.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"SPECULATIVE_DISABLE_BY_BATCH_SIZE": {
|
||||||
|
"env_var_name": "SPECULATIVE_DISABLE_BY_BATCH_SIZE",
|
||||||
|
"value": "",
|
||||||
|
"title": "Speculative Disable by Batch Size",
|
||||||
|
"description": "Disable speculative decoding if the number of enqueue requests is larger than this value.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"NGRAM_PROMPT_LOOKUP_MAX": {
|
||||||
|
"env_var_name": "NGRAM_PROMPT_LOOKUP_MAX",
|
||||||
|
"value": "",
|
||||||
|
"title": "Ngram Prompt Lookup Max",
|
||||||
|
"description": "Max size of window for ngram prompt lookup in speculative decoding.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"NGRAM_PROMPT_LOOKUP_MIN": {
|
||||||
|
"env_var_name": "NGRAM_PROMPT_LOOKUP_MIN",
|
||||||
|
"value": "",
|
||||||
|
"title": "Ngram Prompt Lookup Min",
|
||||||
|
"description": "Min size of window for ngram prompt lookup in speculative decoding.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"SPEC_DECODING_ACCEPTANCE_METHOD": {
|
||||||
|
"env_var_name": "SPEC_DECODING_ACCEPTANCE_METHOD",
|
||||||
|
"value": "rejection_sampler",
|
||||||
|
"title": "Speculative Decoding Acceptance Method",
|
||||||
|
"description": "Specify the acceptance method for draft token verification in speculative decoding.",
|
||||||
|
"required": false,
|
||||||
|
"type": "select",
|
||||||
|
"options": [
|
||||||
|
{ "value": "rejection_sampler", "label": "rejection_sampler" },
|
||||||
|
{ "value": "typical_acceptance_sampler", "label": "typical_acceptance_sampler" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_THRESHOLD": {
|
||||||
|
"env_var_name": "TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_THRESHOLD",
|
||||||
|
"value": "",
|
||||||
|
"title": "Typical Acceptance Sampler Posterior Threshold",
|
||||||
|
"description": "Set the lower bound threshold for the posterior probability of a token to be accepted.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_ALPHA": {
|
||||||
|
"env_var_name": "TYPICAL_ACCEPTANCE_SAMPLER_POSTERIOR_ALPHA",
|
||||||
|
"value": "",
|
||||||
|
"title": "Typical Acceptance Sampler Posterior Alpha",
|
||||||
|
"description": "A scaling factor for the entropy-based threshold for token acceptance.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"MODEL_LOADER_EXTRA_CONFIG": {
|
||||||
|
"env_var_name": "MODEL_LOADER_EXTRA_CONFIG",
|
||||||
|
"value": "",
|
||||||
|
"title": "Model Loader Extra Config",
|
||||||
|
"description": "Extra config for model loader.",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"PREEMPTION_MODE": {
|
||||||
|
"env_var_name": "PREEMPTION_MODE",
|
||||||
|
"value": "",
|
||||||
|
"title": "Preemption Mode",
|
||||||
|
"description": "If 'recompute', the engine performs preemption-aware recomputation. If 'save', the engine saves activations into the CPU memory as preemption happens.",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"PREEMPTION_CHECK_PERIOD": {
|
||||||
|
"env_var_name": "PREEMPTION_CHECK_PERIOD",
|
||||||
|
"value": 1.0,
|
||||||
|
"title": "Preemption Check Period",
|
||||||
|
"description": "How frequently the engine checks if a preemption happens.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"PREEMPTION_CPU_CAPACITY": {
|
||||||
|
"env_var_name": "PREEMPTION_CPU_CAPACITY",
|
||||||
|
"value": 2,
|
||||||
|
"title": "Preemption CPU Capacity",
|
||||||
|
"description": "The percentage of CPU memory used for the saved activations.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"MAX_LOG_LEN": {
|
||||||
|
"env_var_name": "MAX_LOG_LEN",
|
||||||
|
"value": "",
|
||||||
|
"title": "Max Log Length",
|
||||||
|
"description": "Max number of characters or ID numbers being printed in log.",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"DISABLE_LOGGING_REQUEST": {
|
||||||
|
"env_var_name": "DISABLE_LOGGING_REQUEST",
|
||||||
|
"value": false,
|
||||||
|
"title": "Disable Logging Request",
|
||||||
|
"description": "Disable logging requests.",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"TOKENIZER_NAME": {
|
||||||
|
"env_var_name": "TOKENIZER_NAME",
|
||||||
|
"value": "",
|
||||||
|
"title": "Tokenizer Name",
|
||||||
|
"description": "Tokenizer repo to use a different tokenizer than the model's default",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"TOKENIZER_REVISION": {
|
||||||
|
"env_var_name": "TOKENIZER_REVISION",
|
||||||
|
"value": "",
|
||||||
|
"title": "Tokenizer Revision",
|
||||||
|
"description": "Tokenizer revision to load",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"CUSTOM_CHAT_TEMPLATE": {
|
||||||
|
"env_var_name": "CUSTOM_CHAT_TEMPLATE",
|
||||||
|
"value": "",
|
||||||
|
"title": "Custom Chat Template",
|
||||||
|
"description": "Custom chat jinja template",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"GPU_MEMORY_UTILIZATION": {
|
||||||
|
"env_var_name": "GPU_MEMORY_UTILIZATION",
|
||||||
|
"value": "0.95",
|
||||||
|
"title": "GPU Memory Utilization",
|
||||||
|
"description": "Sets GPU VRAM utilization",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"BLOCK_SIZE": {
|
||||||
|
"env_var_name": "BLOCK_SIZE",
|
||||||
|
"value": "16",
|
||||||
|
"title": "Block Size",
|
||||||
|
"description": "Token block size for contiguous chunks of tokens",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"SWAP_SPACE": {
|
||||||
|
"env_var_name": "SWAP_SPACE",
|
||||||
|
"value": "4",
|
||||||
|
"title": "Swap Space",
|
||||||
|
"description": "CPU swap space size (GiB) per GPU",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"ENFORCE_EAGER": {
|
||||||
|
"env_var_name": "ENFORCE_EAGER",
|
||||||
|
"value": false,
|
||||||
|
"title": "Enforce Eager",
|
||||||
|
"description": "Always use eager-mode PyTorch. If False (0), will use eager mode and CUDA graph in hybrid for maximal performance and flexibility",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"MAX_SEQ_LEN_TO_CAPTURE": {
|
||||||
|
"env_var_name": "MAX_SEQ_LEN_TO_CAPTURE",
|
||||||
|
"value": "8192",
|
||||||
|
"title": "CUDA Graph Max Content Length",
|
||||||
|
"description": "Maximum context length covered by CUDA graphs. If a sequence has context length larger than this, we fall back to eager mode",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"DISABLE_CUSTOM_ALL_REDUCE": {
|
||||||
|
"env_var_name": "DISABLE_CUSTOM_ALL_REDUCE",
|
||||||
|
"value": false,
|
||||||
|
"title": "Disable Custom All Reduce",
|
||||||
|
"description": "Enables or disables custom all reduce",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"DEFAULT_BATCH_SIZE": {
|
||||||
|
"env_var_name": "DEFAULT_BATCH_SIZE",
|
||||||
|
"value": "50",
|
||||||
|
"title": "Default Final Batch Size",
|
||||||
|
"description": "Default and Maximum batch size for token streaming to reduce HTTP calls",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"DEFAULT_MIN_BATCH_SIZE": {
|
||||||
|
"env_var_name": "DEFAULT_MIN_BATCH_SIZE",
|
||||||
|
"value": "1",
|
||||||
|
"title": "Default Starting Batch Size",
|
||||||
|
"description": "Batch size for the first request, which will be multiplied by the growth factor every subsequent request",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"DEFAULT_BATCH_SIZE_GROWTH_FACTOR": {
|
||||||
|
"env_var_name": "DEFAULT_BATCH_SIZE_GROWTH_FACTOR",
|
||||||
|
"value": "3",
|
||||||
|
"title": "Default Batch Size Growth Factor",
|
||||||
|
"description": "Growth factor for dynamic batch size",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"RAW_OPENAI_OUTPUT": {
|
||||||
|
"env_var_name": "RAW_OPENAI_OUTPUT",
|
||||||
|
"value": true,
|
||||||
|
"title": "Raw OpenAI Output",
|
||||||
|
"description": "Raw OpenAI output instead of just the text",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
},
|
||||||
|
"OPENAI_RESPONSE_ROLE": {
|
||||||
|
"env_var_name": "OPENAI_RESPONSE_ROLE",
|
||||||
|
"value": "assistant",
|
||||||
|
"title": "OpenAI Response Role",
|
||||||
|
"description": "Role of the LLM's Response in OpenAI Chat Completions",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"OPENAI_SERVED_MODEL_NAME_OVERRIDE": {
|
||||||
|
"env_var_name": "OPENAI_SERVED_MODEL_NAME_OVERRIDE",
|
||||||
|
"value": "",
|
||||||
|
"title": "OpenAI Served Model Name Override",
|
||||||
|
"description": "Overrides the name of the served model from model repo/path to specified name, which you will then be able to use the value for the `model` parameter when making OpenAI requests",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"MAX_CONCURRENCY": {
|
||||||
|
"env_var_name": "MAX_CONCURRENCY",
|
||||||
|
"value": "300",
|
||||||
|
"title": "Max Concurrency",
|
||||||
|
"description": "Max concurrent requests per worker. vLLM has an internal queue, so you don't have to worry about limiting by VRAM, this is for improving scaling/load balancing efficiency",
|
||||||
|
"required": false,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"MODEL_REVISION": {
|
||||||
|
"env_var_name": "MODEL_REVISION",
|
||||||
|
"value": "",
|
||||||
|
"title": "Model Revision",
|
||||||
|
"description": "Model revision (branch) to load",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"BASE_PATH": {
|
||||||
|
"env_var_name": "BASE_PATH",
|
||||||
|
"value": "/runpod-volume",
|
||||||
|
"title": "Base Path",
|
||||||
|
"description": "Storage directory for Huggingface cache and model",
|
||||||
|
"required": false,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"DISABLE_LOG_REQUESTS": {
|
||||||
|
"env_var_name": "DISABLE_LOG_REQUESTS",
|
||||||
|
"value": true,
|
||||||
|
"title": "Disable Log Requests",
|
||||||
|
"description": "Enables or disables vLLM request logging",
|
||||||
|
"required": false,
|
||||||
|
"type": "toggle"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user