Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14b74a4989 | ||
|
|
50aba8fb57 | ||
|
|
9edc5715ce | ||
|
|
4c91f2c5b5 | ||
|
|
6265b99348 | ||
|
|
026f8d700b | ||
|
|
146bdb0252 | ||
|
|
da01193a3d | ||
|
|
c2e6cc9f61 | ||
|
|
69968a6b39 | ||
|
|
32b29d4c6c | ||
|
|
dcea4fc4f9 | ||
|
|
9c139e8ceb | ||
|
|
678bb4be8f | ||
|
|
87d7365126 | ||
|
|
0e83616f93 | ||
|
|
ab6d39dcf8 | ||
|
|
ed315a175e | ||
|
|
73f030ae5e | ||
|
|
8a099c1723 | ||
|
|
ff87840a58 | ||
|
|
7dc853b1fe | ||
|
|
a8b754b92a | ||
|
|
6357aeda51 | ||
|
|
0140b29c44 | ||
|
|
0cb8aeae77 | ||
|
|
cd8f9e9560 | ||
|
|
895fd25fac | ||
|
|
7bb8df73af | ||
|
|
747cdf5891 | ||
|
|
3d4af5df9b | ||
|
|
72547aa3bb | ||
|
|
577fd8c3c3 | ||
|
|
f49f35456e | ||
|
|
cff7b09ef2 | ||
|
|
04b342c675 | ||
|
|
5b29643799 | ||
|
|
4f8a16df5d | ||
|
|
22356ee2b3 | ||
|
|
fa42ecd79a | ||
|
|
178c72238e | ||
|
|
e6950bdebd | ||
|
|
a774cefe85 | ||
|
|
9de17d49b7 | ||
|
|
296556a6f7 | ||
|
|
a1544ea70d | ||
|
|
3403889528 | ||
|
|
f299204770 | ||
|
|
1ed25eea20 | ||
|
|
dc4ad7ddeb | ||
|
|
9035b0e07f | ||
|
|
c979f0020f | ||
|
|
6fbd480a26 | ||
|
|
3ef1fb8e7b | ||
|
|
30e8514d63 | ||
|
|
d9808815ee | ||
|
|
d8ed3b5353 | ||
|
|
4c4e039565 | ||
|
|
9d1686960d | ||
|
|
45d1eeee47 | ||
|
|
17efb0e7d0 | ||
|
|
2b5f07df63 | ||
|
|
13fa71878e | ||
|
|
8a9365bed4 | ||
|
|
cd485a1af1 | ||
|
|
b9043639e9 | ||
|
|
407dbd7773 | ||
|
|
f103c142c1 | ||
|
|
efb093e198 | ||
|
|
42443f735e | ||
|
|
b7c6d4f9a2 | ||
|
|
d69cc021e8 | ||
|
|
61faa8f137 | ||
|
|
1606cff557 | ||
|
|
e705c9494b | ||
|
|
b749aa5718 | ||
|
|
4705ba8a7c | ||
|
|
767c66c301 | ||
|
|
fefdbe21a9 | ||
|
|
ee961ad28d | ||
|
|
2e8c251447 | ||
|
|
c3cf43b228 | ||
|
|
7ec10b98cd | ||
|
|
c45ac42acd | ||
|
|
340bc0b3c6 | ||
|
|
e1e9ef74ad | ||
|
|
461f89cea6 | ||
|
|
8eb55b90c1 | ||
|
|
6d6cbe7095 | ||
|
|
90c16b472d | ||
|
|
6f2381a9a1 | ||
|
|
3851d53f93 | ||
|
|
c896438f21 | ||
|
|
912892f94e | ||
|
|
f8bf82469c | ||
|
|
ec1664902b | ||
|
|
d09122de4a | ||
|
|
e27dc68dea | ||
|
|
1ee18d06a9 | ||
|
|
5c4edd15cc | ||
|
|
b074d3a23b | ||
|
|
205847471c | ||
|
|
6337a6673a | ||
|
|
66e1b1605b | ||
|
|
60c8f257a8 | ||
|
|
fae16e7ee1 | ||
|
|
2becd35345 | ||
|
|
33d88df6c0 | ||
|
|
ecd562e112 | ||
|
|
5cffaab8e8 | ||
|
|
a0fe1dfdad | ||
|
|
0e0d6df859 | ||
|
|
d1718aec00 | ||
|
|
5f0fc69d75 | ||
|
|
aef1187a30 | ||
|
|
f7514dea4b | ||
|
|
121a3dd44b | ||
|
|
e2e111b942 | ||
|
|
7aa17463d3 | ||
|
|
72a643dd0c | ||
|
|
15f569f970 | ||
|
|
2f2bd4c749 | ||
|
|
fb0c030797 | ||
|
|
8b02a703b4 | ||
|
|
d8863139d6 | ||
|
|
f5a063956e | ||
|
|
18748fd73e | ||
|
|
0133c23be8 | ||
|
|
a129cff47d | ||
|
|
30f2c4630e | ||
|
|
b98636e432 | ||
|
|
185205c750 | ||
|
|
b948e530a1 | ||
|
|
4f22d6f107 | ||
|
|
8839689132 | ||
|
|
5ddc2326cd | ||
|
|
46a3300cbb | ||
|
|
1e9a731380 | ||
|
|
c47e649a24 | ||
|
|
7192bcaeef | ||
|
|
8665ffb78d | ||
|
|
57431b30ad | ||
|
|
437a84c77a | ||
|
|
a4062fc488 | ||
|
|
9631407c1d | ||
|
|
1a93932ab2 | ||
|
|
4c6c88c3b9 | ||
|
|
a58a76783d | ||
|
|
26919c8849 | ||
|
|
70cd1c8113 | ||
|
|
deeff579f8 | ||
|
|
11f96a09d7 | ||
|
|
23e8ecf85b | ||
|
|
6db2c44d3b | ||
|
|
9b7ca4d0b0 | ||
|
|
2a4eaf0356 | ||
|
|
ba19cc97bf | ||
|
|
6075f2c590 | ||
|
|
a9786a2481 | ||
|
|
0b6bc7a2be | ||
|
|
d0ab58ee17 | ||
|
|
4e474c41c8 | ||
|
|
e9d13c155e | ||
|
|
e807342e90 | ||
|
|
f33e8d2bcd | ||
|
|
6b64bb93bd | ||
|
|
a53cf777ff | ||
|
|
cfc258674b | ||
|
|
8beafed06b | ||
|
|
d77c53c3b7 | ||
|
|
3d067cd472 | ||
|
|
f1360ccae7 | ||
|
|
96f1b86126 | ||
|
|
3a095f3e10 | ||
|
|
7cf7f3e4e6 | ||
|
|
4395d0c67b | ||
|
|
5864fa6843 | ||
|
|
067f0bc173 | ||
|
|
0869068e7c | ||
|
|
19f25b17de | ||
|
|
70aa748c30 | ||
|
|
da3e5f524b | ||
|
|
acbdf63de8 | ||
|
|
084d000324 | ||
|
|
fa31d9663d | ||
|
|
b8fb313483 | ||
|
|
9635daf336 | ||
|
|
fb4e700090 | ||
|
|
d4872ed9c8 | ||
|
|
b2eef50c3b | ||
|
|
8005bcc1a8 | ||
|
|
aa7b00ddda | ||
|
|
dc6f3239bd | ||
|
|
f9d0fcb78c | ||
|
|
99b952e55e | ||
|
|
389fad7952 | ||
|
|
56dc4ad075 | ||
|
|
6dcf39e159 | ||
|
|
2b1d618287 | ||
|
|
d7e9c49fe4 | ||
|
|
c9791f1163 | ||
|
|
6fc770415d | ||
|
|
04288240f6 | ||
|
|
9e8d9196b0 | ||
|
|
30dd7c1eb5 | ||
|
|
aa7c37ffb0 | ||
|
|
dc8c88027a | ||
|
|
a948e90caa | ||
|
|
c703254f71 | ||
|
|
2747106403 | ||
|
|
91ed30e9a2 | ||
|
|
fcbfe84f63 | ||
|
|
610429df23 | ||
|
|
a578c6df23 | ||
|
|
9299f43b8b | ||
|
|
131c17569f | ||
|
|
8882f6d50b | ||
|
|
331bc30101 | ||
|
|
a27f72a33a | ||
|
|
7167985f23 | ||
|
|
0e3359a70e | ||
|
|
3f0a20d28e | ||
|
|
8e3c26be14 | ||
|
|
66ea8b1110 | ||
|
|
a3d432afdf | ||
|
|
06c2bb1715 | ||
|
|
d2e355eae9 | ||
|
|
b7787d8ca8 | ||
|
|
b1fca5d257 | ||
|
|
3e86d16892 | ||
|
|
d9f54ce76a | ||
|
|
149da95cd0 | ||
|
|
0a89394f1d | ||
|
|
8df7f41f1d | ||
|
|
4d7b8c03c0 | ||
|
|
6c6bf50379 | ||
|
|
27a2ee5754 | ||
|
|
2df915a145 | ||
|
|
aadc025849 | ||
|
|
8b4a49073d | ||
|
|
4e10641d69 | ||
|
|
6e8696c12a | ||
|
|
b49e81a75a | ||
|
|
65932f85e1 | ||
|
|
94840cfbbb | ||
|
|
ce47c41f4a | ||
|
|
c03ecc42fe | ||
|
|
ae56b9f43d | ||
|
|
891699be1e | ||
|
|
c28aa02576 | ||
|
|
eba20c0704 | ||
|
|
677a01e8f3 | ||
|
|
5cd12ba331 | ||
|
|
850c686538 | ||
|
|
de2876e659 |
@@ -0,0 +1,79 @@
|
||||
# Contributing to worker-vllm
|
||||
|
||||
## 🚀 Release Process
|
||||
|
||||
### Development Workflow
|
||||
|
||||
1. **Feature Development**
|
||||
|
||||
```bash
|
||||
git checkout -b feature/your-feature-name
|
||||
# Make your changes
|
||||
git push origin feature/your-feature-name
|
||||
```
|
||||
|
||||
- Creates pull request → triggers dev build: `runpod/worker-v1-vllm:dev-refs-pull-214-merge`
|
||||
|
||||
2. **Main Branch**
|
||||
```bash
|
||||
git checkout main
|
||||
git merge feature/your-feature-name
|
||||
git push origin main
|
||||
```
|
||||
- No automatic builds on main (staging area)
|
||||
|
||||
### Creating Releases
|
||||
|
||||
**Method 1: GitHub UI (Recommended)**
|
||||
|
||||
1. Go to [Releases](https://github.com/runpod-workers/worker-vllm/releases)
|
||||
2. Click **"Create a new release"**
|
||||
3. **Tag version**: `v2.8.0` (with "v" prefix, semantic versioning)
|
||||
4. **Target**: `main` branch
|
||||
5. **Title**: `Release 2.8.0`
|
||||
6. **Description**: Brief changelog
|
||||
7. Click **"Publish release"**
|
||||
|
||||
**Method 2: Git CLI**
|
||||
|
||||
```bash
|
||||
git checkout main
|
||||
git tag v2.8.0
|
||||
git push origin v2.8.0
|
||||
```
|
||||
|
||||
### What Happens Automatically
|
||||
|
||||
✅ **GitHub Release** created (if using Method 1)
|
||||
✅ **Docker Image** built and pushed: `runpod/worker-v1-vllm:v2.8.0`
|
||||
✅ **Documentation** updated with new version references
|
||||
|
||||
## 📋 Version Format
|
||||
|
||||
- **Format**: `vMAJOR.MINOR.PATCH` (e.g., `v2.8.0`)
|
||||
- **With "v" prefix**: Use `v2.8.0` for git tags
|
||||
- **Semantic Versioning**: Follow [SemVer](https://semver.org/)
|
||||
|
||||
## 🐛 Development
|
||||
|
||||
### Running Tests
|
||||
|
||||
```bash
|
||||
# Update test configuration in .runpod/tests.json
|
||||
# Tests run automatically via RunPod platform
|
||||
```
|
||||
|
||||
### Model Updates
|
||||
|
||||
- Update `MODEL_NAME` in `.runpod/tests.json` and `worker-config.json`
|
||||
- Ensure model has vLLM support and chat template (for OpenAI compatibility)
|
||||
|
||||
### Environment Variables
|
||||
|
||||
See [README.md](../README.md) for full list of supported environment variables.
|
||||
|
||||
## 🔧 CI/CD Workflows
|
||||
|
||||
- **Dev builds**: All pull requests → `dev-refs-pull-<PR#>-merge` images
|
||||
- **Release builds**: Git tags → versioned images + GitHub releases
|
||||
- **Manual triggers**: Available in GitHub Actions for emergency releases
|
||||
@@ -9,42 +9,60 @@ on:
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
check_dep:
|
||||
runs-on: ubuntu-latest
|
||||
name: Check python requirements file and update
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check for new package version and update
|
||||
run: |
|
||||
# Get current version
|
||||
current_version=$(grep -oP 'runpod==\K[^"]+' ./builder/requirements.txt)
|
||||
echo "Fetching current runpod version from requirements.txt..."
|
||||
|
||||
# Get new version
|
||||
new_version=$(curl -s https://pypi.org/pypi/runpod/json | jq -r .info.version)
|
||||
# Match runpod with any version specifier or no specifier at all
|
||||
current_version=$(grep -oP '^runpod([~>=!<]{1,2}\K[\d.]+)?' ./builder/requirements.txt | grep -oP '[\d.]+' || echo "")
|
||||
echo "Current version: ${current_version:-unset}"
|
||||
|
||||
echo "Fetching latest runpod version from PyPI..."
|
||||
new_version=$(curl -sf https://pypi.org/pypi/runpod/json | jq -r .info.version)
|
||||
echo "NEW_VERSION_ENV=$new_version" >> $GITHUB_ENV
|
||||
echo "New version: $new_version"
|
||||
|
||||
if [ -z "$new_version" ]; then
|
||||
echo "Failed to fetch the new version."
|
||||
echo "ERROR: Failed to fetch new version from PyPI."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the version is already up-to-date
|
||||
if [ "$current_version" = "$new_version" ]; then
|
||||
echo "The package version is already up-to-date."
|
||||
if [ -z "$current_version" ]; then
|
||||
echo "No version pin found — pinning to $new_version."
|
||||
else
|
||||
current_major_minor=$(echo "$current_version" | cut -d. -f1,2)
|
||||
new_major_minor=$(echo "$new_version" | cut -d. -f1,2)
|
||||
echo "Current major.minor: $current_major_minor New major.minor: $new_major_minor"
|
||||
|
||||
if [ "$current_major_minor" = "$new_major_minor" ]; then
|
||||
echo "No update needed. New version ($new_version) is within ~= $current_major_minor range."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Update requirements.txt
|
||||
sed -i "s/runpod==.*/runpod==$new_version/" ./builder/requirements.txt
|
||||
echo "New major/minor detected ($new_major_minor). Updating requirements.txt..."
|
||||
fi
|
||||
|
||||
# Replace any `runpod`, `runpod==x`, `runpod~=x`, etc. with pinned version
|
||||
sed -i "s|^runpod.*|runpod~=$new_version|" ./builder/requirements.txt
|
||||
echo "requirements.txt updated."
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: Update package version
|
||||
title: Update runpod package version
|
||||
body: The package version has been updated to ${{ env.NEW_VERSION_ENV }}
|
||||
commit-message: "chore: update runpod to ${{ env.NEW_VERSION_ENV }}"
|
||||
title: "chore: update runpod to ${{ env.NEW_VERSION_ENV }}"
|
||||
body: The `runpod` package has been updated to `${{ env.NEW_VERSION_ENV }}`.
|
||||
branch: runpod-package-update
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
name: Development
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- "**"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
dev:
|
||||
runs-on: [blacksmith-8vcpu-ubuntu-2204, linux]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Clear space to remove unused folders
|
||||
run: |
|
||||
rm -rf /usr/share/dotnet
|
||||
rm -rf /opt/ghc
|
||||
rm -rf "/usr/local/share/boost"
|
||||
rm -rf "$AGENT_TOOLSDIRECTORY"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: blacksmith docker layer cache
|
||||
uses: useblacksmith/build-push-action@v1
|
||||
with:
|
||||
setup-only: true
|
||||
|
||||
- name: Set environment variables
|
||||
run: |
|
||||
echo "DOCKERHUB_REPO=${{ vars.DOCKERHUB_REPO || 'runpod' }}" >> $GITHUB_ENV
|
||||
echo "DOCKERHUB_IMG=${{ vars.DOCKERHUB_IMG || 'worker-v1-vllm' }}" >> $GITHUB_ENV
|
||||
echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV
|
||||
# Convert branch name to safe docker tag (replace / with -)
|
||||
BRANCH_NAME="${GITHUB_REF##refs/heads/}"
|
||||
SAFE_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9._-]/-/g' | sed 's/--*/-/g')
|
||||
echo "RELEASE_VERSION=dev-${SAFE_BRANCH_NAME}" >> $GITHUB_ENV
|
||||
|
||||
- name: Build and push the images to Docker Hub
|
||||
uses: docker/bake-action@v2
|
||||
with:
|
||||
push: true
|
||||
set: |
|
||||
*.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }}
|
||||
*.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }}
|
||||
*.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }}
|
||||
*.args.HUGGINGFACE_ACCESS_TOKEN=${{ env.HUGGINGFACE_ACCESS_TOKEN }}
|
||||
@@ -0,0 +1,117 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v[0-9]+.[0-9]+.[0-9]+*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "Version to release (e.g., v2.8.0)"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write # Required for creating GitHub releases
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: [blacksmith-8vcpu-ubuntu-2204, linux]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Clear space to remove unused folders
|
||||
run: |
|
||||
rm -rf /usr/share/dotnet
|
||||
rm -rf /opt/ghc
|
||||
rm -rf "/usr/local/share/boost"
|
||||
rm -rf "$AGENT_TOOLSDIRECTORY"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: blacksmith docker layer cache
|
||||
uses: useblacksmith/build-push-action@v1
|
||||
with:
|
||||
setup-only: true
|
||||
|
||||
- name: Set environment variables
|
||||
run: |
|
||||
echo "DOCKERHUB_REPO=${{ vars.DOCKERHUB_REPO || 'runpod' }}" >> $GITHUB_ENV
|
||||
echo "DOCKERHUB_IMG=${{ vars.DOCKERHUB_IMG || 'worker-v1-vllm' }}" >> $GITHUB_ENV
|
||||
echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV
|
||||
|
||||
# Determine version based on trigger type
|
||||
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
||||
VERSION="${{ github.event.inputs.version }}"
|
||||
elif [[ "${{ github.event_name }}" == "release" ]]; then
|
||||
VERSION="${{ github.event.release.tag_name }}"
|
||||
else
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
fi
|
||||
echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_ENV
|
||||
|
||||
- name: Build and push the images to Docker Hub
|
||||
uses: docker/bake-action@v2
|
||||
with:
|
||||
push: true
|
||||
set: |
|
||||
*.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }}
|
||||
*.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }}
|
||||
*.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }}
|
||||
*.args.HUGGINGFACE_ACCESS_TOKEN=${{ env.HUGGINGFACE_ACCESS_TOKEN }}
|
||||
|
||||
- name: Release Summary
|
||||
run: |
|
||||
echo "Release completed!"
|
||||
echo "Version: ${{ env.RELEASE_VERSION }}"
|
||||
echo "Docker Image: ${{ env.DOCKERHUB_REPO }}/${{ env.DOCKERHUB_IMG }}:${{ env.RELEASE_VERSION }}"
|
||||
|
||||
- name: Fetch Release Notes
|
||||
run: |
|
||||
RESPONSE=$(curl -sf \
|
||||
-H "Authorization: token ${{ github.token }}" \
|
||||
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.RELEASE_VERSION }}" 2>/dev/null) || true
|
||||
if [[ -n "$RESPONSE" ]]; then
|
||||
NOTES=$(echo "$RESPONSE" | jq -r '.body // empty')
|
||||
fi
|
||||
printf '%s' "${NOTES:-No release notes available.}" > /tmp/release_notes.txt
|
||||
|
||||
- name: Notify Slack
|
||||
run: |
|
||||
jq -n \
|
||||
--arg version "${{ env.RELEASE_VERSION }}" \
|
||||
--arg docker "${{ env.DOCKERHUB_REPO }}/${{ env.DOCKERHUB_IMG }}:${{ env.RELEASE_VERSION }}" \
|
||||
--rawfile notes /tmp/release_notes.txt \
|
||||
--arg url "https://github.com/${{ github.repository }}/releases/tag/${{ env.RELEASE_VERSION }}" \
|
||||
'{
|
||||
text: (":rocket: New :runpod-new-whiteonpurple: Runpod worker-vllm release: *" + $version + "*"),
|
||||
blocks: [
|
||||
{
|
||||
type: "section",
|
||||
text: {
|
||||
type: "mrkdwn",
|
||||
text: (":banana-dance: *New Release — worker-vllm " + $version + "*\n*Docker:* `" + $docker + "`\n<" + $url + "|View release on GitHub>")
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "section",
|
||||
text: {
|
||||
type: "mrkdwn",
|
||||
text: ("*Release Notes:*\n" + $notes)
|
||||
}
|
||||
}
|
||||
]
|
||||
}' | curl -sf -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @-
|
||||
@@ -0,0 +1,41 @@
|
||||
name: Slack PR Notifications
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened]
|
||||
issues:
|
||||
types: [opened]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Notify Slack - New PR
|
||||
if: github.event_name == 'pull_request'
|
||||
run: |
|
||||
curl -sf -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"text": ":rocket: New PR in worker-vllm: *${{ github.event.pull_request.title }}*",
|
||||
"blocks": [
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": ":rocket: *New Pull Request — worker-vllm*\n*<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>*\nOpened by *${{ github.event.pull_request.user.login }}*"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "context",
|
||||
"elements": [
|
||||
{
|
||||
"type": "mrkdwn",
|
||||
"text": "${{ github.event.pull_request.base.ref }} ← ${{ github.event.pull_request.head.ref }}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}'
|
||||
@@ -0,0 +1,73 @@
|
||||
name: Monitor vLLM Releases
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *' # Every day at midnight
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check-vllm-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Restore last known vLLM tag
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: .vllm-last-tag
|
||||
key: vllm-tag-${{ github.run_id }}
|
||||
restore-keys: vllm-tag-
|
||||
|
||||
- name: Get latest vLLM release
|
||||
id: vllm
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
response=$(curl -sf https://api.github.com/repos/vllm-project/vllm/releases/latest \
|
||||
-H "Authorization: Bearer $GH_TOKEN")
|
||||
echo "tag=$(echo "$response" | jq -r '.tag_name')" >> $GITHUB_OUTPUT
|
||||
echo "url=$(echo "$response" | jq -r '.html_url')" >> $GITHUB_OUTPUT
|
||||
echo "name=$(echo "$response" | jq -r '.name')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Check if new release
|
||||
id: check
|
||||
run: |
|
||||
last=$(cat .vllm-last-tag 2>/dev/null || echo "")
|
||||
current="${{ steps.vllm.outputs.tag }}"
|
||||
echo "Last: $last Current: $current"
|
||||
if [ -n "$current" ] && [ "$last" != "$current" ]; then
|
||||
echo "is_new=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "is_new=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Notify Slack
|
||||
if: steps.check.outputs.is_new == 'true'
|
||||
run: |
|
||||
curl -sf -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"text": ":rocket: New vLLM release: *${{ steps.vllm.outputs.tag }}*",
|
||||
"blocks": [
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": ":rocket: *New vLLM Release: ${{ steps.vllm.outputs.tag }}*\n<${{ steps.vllm.outputs.url }}|View on GitHub>"
|
||||
}
|
||||
}
|
||||
]
|
||||
}'
|
||||
|
||||
- name: Save new tag
|
||||
if: steps.check.outputs.is_new == 'true'
|
||||
run: echo "${{ steps.vllm.outputs.tag }}" > .vllm-last-tag
|
||||
|
||||
- name: Update cache
|
||||
if: steps.check.outputs.is_new == 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: .vllm-last-tag
|
||||
key: vllm-tag-${{ steps.vllm.outputs.tag }}
|
||||
@@ -4,3 +4,4 @@ runpod.toml
|
||||
.env
|
||||
test/*
|
||||
vllm-base/vllm-*
|
||||
.DS_Store
|
||||
@@ -1,3 +0,0 @@
|
||||
[submodule "vllm-base-image/vllm"]
|
||||
path = vllm-base-image/vllm
|
||||
url = https://github.com/runpod/vllm-fork-for-sls-worker.git
|
||||
@@ -0,0 +1,298 @@
|
||||

|
||||
|
||||
Run LLMs using [vLLM](https://docs.vllm.ai) with an OpenAI-compatible API
|
||||
|
||||
---
|
||||
|
||||
[](https://www.runpod.io/console/hub/runpod-workers/worker-vllm)
|
||||
|
||||
Current vLLM version: [0.20.2](https://github.com/vllm-project/vllm/releases/tag/v0.20.2)
|
||||
|
||||
---
|
||||
|
||||
## Endpoint Configuration
|
||||
|
||||
All behaviour is controlled through environment variables:
|
||||
|
||||
| Environment Variable | Description | Default | Options |
|
||||
| ----------------------------------- | ------------------------------------------------- | ------------------- | ------------------------------------------------------------------ |
|
||||
| `MODEL_NAME` | Path of the model weights | "facebook/opt-125m" | Local folder or Hugging Face repo ID |
|
||||
| `HF_TOKEN` | HuggingFace access token for gated/private models | | Your HuggingFace access token |
|
||||
| `MAX_MODEL_LEN` | Model's maximum context length | | Integer (e.g., 4096) |
|
||||
| `QUANTIZATION` | Quantization method | | "awq", "gptq", "squeezellm", "bitsandbytes" |
|
||||
| `TENSOR_PARALLEL_SIZE` | Number of GPUs | 1 | Integer |
|
||||
| `GPU_MEMORY_UTILIZATION` | Fraction of GPU memory to use | 0.95 | Float between 0.0 and 1.0 |
|
||||
| `MAX_NUM_SEQS` | Maximum number of sequences per iteration | 256 | Integer |
|
||||
| `CUSTOM_CHAT_TEMPLATE` | Custom chat template override | | Jinja2 template string |
|
||||
| `ENABLE_AUTO_TOOL_CHOICE` | Enable automatic tool selection | false | boolean (true or false) |
|
||||
| `TOOL_CALL_PARSER` | Parser for tool calls | | "mistral", "hermes", "llama3_json", "granite", "deepseek_v3", etc. |
|
||||
| `REASONING_PARSER` | Parser for reasoning-capable models | | "deepseek_r1", "qwen3", "granite", "hunyuan_a13b" |
|
||||
| `OPENAI_SERVED_MODEL_NAME_OVERRIDE` | Override served model name in API | | String |
|
||||
| `MAX_CONCURRENCY` | Maximum concurrent requests | 300 | Integer |
|
||||
| `ENFORCE_EAGER` | If True, we will disable CUDA graph and always execute the model in eager mode. If False, we will use CUDA graph and eager execution in hybrid for maximal performance and flexibility. | true | boolean (true or false) |
|
||||
|
||||
**Pass any vLLM engine arg** not listed above by setting an env var with the **UPPERCASED** field name (e.g. `MAX_MODEL_LEN=4096`, `ENABLE_CHUNKED_PREFILL=true`). The worker auto-discovers all `AsyncEngineArgs` fields from env. See the [vLLM engine args docs](https://docs.vllm.ai/en/latest/configuration/engine_args) for all available options.
|
||||
|
||||
For complete configuration options, see the [full configuration documentation](https://github.com/runpod-workers/worker-vllm/blob/main/docs/configuration.md).
|
||||
|
||||
### Specify Transformers Version
|
||||
To change the version of the [Transformers library](https://github.com/huggingface/transformers) use the `TRANSFORMERS_VERSION` environment variable to specify the version you want to use. Note this might break the handler, so use for development purposes.
|
||||
|
||||
## API Usage
|
||||
|
||||
This worker supports two API formats: **RunPod native** and **OpenAI-compatible**.
|
||||
|
||||
### RunPod Native API
|
||||
|
||||
For testing directly in the RunPod UI, use these examples in your endpoint's request tab.
|
||||
|
||||
#### Chat Completions
|
||||
|
||||
```json
|
||||
{
|
||||
"input": {
|
||||
"messages": [
|
||||
{ "role": "system", "content": "You are a helpful assistant." },
|
||||
{ "role": "user", "content": "What is the capital of France?" }
|
||||
],
|
||||
"sampling_params": {
|
||||
"max_tokens": 100,
|
||||
"temperature": 0.7
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Chat Completions (Streaming)
|
||||
|
||||
```json
|
||||
{
|
||||
"input": {
|
||||
"messages": [
|
||||
{ "role": "user", "content": "Write a short story about a robot." }
|
||||
],
|
||||
"sampling_params": {
|
||||
"max_tokens": 500,
|
||||
"temperature": 0.8
|
||||
},
|
||||
"stream": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Text Generation
|
||||
|
||||
For direct text generation without chat format:
|
||||
|
||||
```json
|
||||
{
|
||||
"input": {
|
||||
"prompt": "The capital of France is",
|
||||
"sampling_params": {
|
||||
"max_tokens": 64,
|
||||
"temperature": 0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### List Models
|
||||
|
||||
```json
|
||||
{
|
||||
"input": {
|
||||
"openai_route": "/v1/models"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### OpenAI-Compatible API
|
||||
|
||||
For external clients and SDKs, use the `/openai/v1` path prefix with your RunPod API key.
|
||||
|
||||
#### Chat Completions
|
||||
|
||||
**Path:** `/openai/v1/chat/completions`
|
||||
|
||||
```json
|
||||
{
|
||||
"model": "meta-llama/Llama-2-7b-chat-hf",
|
||||
"messages": [
|
||||
{ "role": "system", "content": "You are a helpful assistant." },
|
||||
{ "role": "user", "content": "What is the capital of France?" }
|
||||
],
|
||||
"max_tokens": 100,
|
||||
"temperature": 0.7
|
||||
}
|
||||
```
|
||||
|
||||
#### Chat Completions (Streaming)
|
||||
|
||||
```json
|
||||
{
|
||||
"model": "meta-llama/Llama-2-7b-chat-hf",
|
||||
"messages": [
|
||||
{ "role": "user", "content": "Write a short story about a robot." }
|
||||
],
|
||||
"max_tokens": 500,
|
||||
"temperature": 0.8,
|
||||
"stream": true
|
||||
}
|
||||
```
|
||||
|
||||
#### Text Completions
|
||||
|
||||
**Path:** `/openai/v1/completions`
|
||||
|
||||
```json
|
||||
{
|
||||
"model": "meta-llama/Llama-2-7b-chat-hf",
|
||||
"prompt": "The capital of France is",
|
||||
"max_tokens": 100,
|
||||
"temperature": 0.7
|
||||
}
|
||||
```
|
||||
|
||||
#### List Models
|
||||
|
||||
**Path:** `/openai/v1/models`
|
||||
|
||||
```json
|
||||
{}
|
||||
```
|
||||
|
||||
#### OpenAI Responses API
|
||||
|
||||
**Path:** `/openai/v1/responses`
|
||||
|
||||
Supports the [OpenAI Responses API](https://platform.openai.com/docs/api-reference/responses) format. Note: this route bypasses the RunPod queue and is served directly — use `/openai/` prefixed paths rather than the RunPod job queue for these endpoints.
|
||||
|
||||
```json
|
||||
{
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"input": "Tell me a joke."
|
||||
}
|
||||
```
|
||||
|
||||
#### Anthropic Messages API
|
||||
|
||||
**Path:** `/openai/v1/messages`
|
||||
|
||||
Supports the [Anthropic Messages API](https://docs.anthropic.com/en/api/messages) format. Served directly, bypassing the RunPod queue.
|
||||
|
||||
```json
|
||||
{
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"max_tokens": 256,
|
||||
"messages": [
|
||||
{"role": "user", "content": "Hello!"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Response Format
|
||||
|
||||
Both APIs return the same response format:
|
||||
|
||||
```json
|
||||
{
|
||||
"choices": [
|
||||
{
|
||||
"index": 0,
|
||||
"message": { "role": "assistant", "content": "Paris." },
|
||||
"finish_reason": "stop"
|
||||
}
|
||||
],
|
||||
"usage": { "prompt_tokens": 9, "completion_tokens": 1, "total_tokens": 10 }
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
Below are minimal `python` snippets so you can copy-paste to get started quickly.
|
||||
|
||||
> Replace `<ENDPOINT_ID>` with your endpoint ID and `<API_KEY>` with a [RunPod API key](https://docs.runpod.io/get-started/api-keys).
|
||||
|
||||
### OpenAI compatible API
|
||||
|
||||
Minimal Python example using the official `openai` SDK:
|
||||
|
||||
```python
|
||||
from openai import OpenAI
|
||||
import os
|
||||
|
||||
# Initialize the OpenAI Client with your Runpod API Key and Endpoint URL
|
||||
client = OpenAI(
|
||||
api_key=os.getenv("RUNPOD_API_KEY"),
|
||||
base_url=f"https://api.runpod.ai/v2/<ENDPOINT_ID>/openai/v1",
|
||||
)
|
||||
```
|
||||
|
||||
`Chat Completions (Non-Streaming)`
|
||||
|
||||
```python
|
||||
response = client.chat.completions.create(
|
||||
model="meta-llama/Llama-2-7b-chat-hf",
|
||||
messages=[{"role": "user", "content": "Explain quantum computing in simple terms"}],
|
||||
temperature=0,
|
||||
max_tokens=100,
|
||||
)
|
||||
print(f"Response: {response.choices[0].message.content}")
|
||||
```
|
||||
|
||||
`Chat Completions (Streaming)`
|
||||
|
||||
```python
|
||||
response_stream = client.chat.completions.create(
|
||||
model="meta-llama/Llama-2-7b-chat-hf",
|
||||
messages=[{"role": "user", "content": "Explain quantum computing in simple terms"}],
|
||||
temperature=0,
|
||||
max_tokens=100,
|
||||
stream=True
|
||||
)
|
||||
for response in response_stream:
|
||||
print(response.choices[0].delta.content or "", end="", flush=True)
|
||||
```
|
||||
|
||||
### RunPod Native API
|
||||
|
||||
```python
|
||||
import requests
|
||||
|
||||
response = requests.post(
|
||||
"https://api.runpod.ai/v2/<ENDPOINT_ID>/run",
|
||||
headers={"Authorization": "Bearer <API_KEY>"},
|
||||
json={
|
||||
"input": {
|
||||
"messages": [
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
{"role": "user", "content": "Explain quantum computing in simple terms"}
|
||||
],
|
||||
"sampling_params": {
|
||||
"temperature": 0.7,
|
||||
"max_tokens": 150
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
result = response.json()
|
||||
print(result["output"])
|
||||
```
|
||||
|
||||
## Compatibility
|
||||
|
||||
For supported models, see the [vLLM supported models documentation](https://docs.vllm.ai/en/latest/models/supported_models.html).
|
||||
|
||||
Anything not recognized by worker-vllm is forwarded to vLLM's engine, so advanced options in the vLLM docs (guided generation, LoRA, speculative decoding, etc.) also work.
|
||||
|
||||
## Documentation
|
||||
|
||||
- **[🚀 Deployment Guide](https://docs.runpod.io/serverless/vllm/get-started)** - Step-by-step setup
|
||||
- **[📖 Configuration Reference](https://github.com/runpod-workers/worker-vllm/blob/main/docs/configuration.md)** - All environment variables
|
||||
- **[🏗️ Advanced Deployment](https://github.com/runpod-workers/worker-vllm/blob/main/docs/deployment.md)** - Custom builds and strategies
|
||||
- **[🔧 Development Guide](https://github.com/runpod-workers/worker-vllm/blob/main/docs/conventions.md)** - Architecture and patterns
|
||||
@@ -0,0 +1,821 @@
|
||||
{
|
||||
"title": "vLLM",
|
||||
"description": "Deploy OpenAI-Compatible Blazing-Fast LLM Endpoints powered by vLLM",
|
||||
"type": "serverless",
|
||||
"category": "language",
|
||||
"iconUrl": "https://registry.npmmirror.com/@lobehub/icons-static-png/latest/files/dark/vllm-color.png",
|
||||
"config": {
|
||||
"runsOn": "GPU",
|
||||
"containerDiskInGb": 150,
|
||||
"gpuIds": "ADA_80_PRO,AMPERE_80",
|
||||
"gpuCount": 1,
|
||||
"allowedCudaVersions": ["13.0"],
|
||||
"presets": [
|
||||
{
|
||||
"name": "deepseek-ai/deepseek-r1-distill-llama-8b",
|
||||
"defaults": {
|
||||
"MODEL_NAME": "deepseek-ai/deepseek-r1-distill-llama-8b"
|
||||
}
|
||||
}
|
||||
],
|
||||
"env": [
|
||||
{
|
||||
"key": "MODEL_NAME",
|
||||
"input": {
|
||||
"name": "Model",
|
||||
"type": "huggingface",
|
||||
"description": "Hugging Face model name",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "TOKENIZER",
|
||||
"input": {
|
||||
"name": "Tokenizer",
|
||||
"type": "string",
|
||||
"description": "Name or path of the Hugging Face tokenizer to use.",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "TOKENIZER_MODE",
|
||||
"input": {
|
||||
"name": "Tokenizer Mode",
|
||||
"type": "string",
|
||||
"description": "The tokenizer mode.",
|
||||
"options": [
|
||||
{
|
||||
"label": "auto",
|
||||
"value": "auto"
|
||||
},
|
||||
{
|
||||
"label": "slow",
|
||||
"value": "slow"
|
||||
}
|
||||
],
|
||||
"default": "auto",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "SKIP_TOKENIZER_INIT",
|
||||
"input": {
|
||||
"name": "Skip Tokenizer Init",
|
||||
"type": "boolean",
|
||||
"description": "Skip initialization of tokenizer and detokenizer.",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "TRUST_REMOTE_CODE",
|
||||
"input": {
|
||||
"name": "Trust Remote Code",
|
||||
"type": "boolean",
|
||||
"description": "Trust remote code from Hugging Face.",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "DOWNLOAD_DIR",
|
||||
"input": {
|
||||
"name": "Download Directory",
|
||||
"type": "string",
|
||||
"description": "Directory to download and load the weights.",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "LOAD_FORMAT",
|
||||
"input": {
|
||||
"name": "Load Format",
|
||||
"type": "string",
|
||||
"description": "The format of the model weights to load.",
|
||||
"options": [
|
||||
{
|
||||
"label": "auto",
|
||||
"value": "auto"
|
||||
},
|
||||
{
|
||||
"label": "pt",
|
||||
"value": "pt"
|
||||
},
|
||||
{
|
||||
"label": "safetensors",
|
||||
"value": "safetensors"
|
||||
},
|
||||
{
|
||||
"label": "npcache",
|
||||
"value": "npcache"
|
||||
},
|
||||
{
|
||||
"label": "dummy",
|
||||
"value": "dummy"
|
||||
},
|
||||
{
|
||||
"label": "tensorizer",
|
||||
"value": "tensorizer"
|
||||
},
|
||||
{
|
||||
"label": "bitsandbytes",
|
||||
"value": "bitsandbytes"
|
||||
}
|
||||
],
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "DTYPE",
|
||||
"input": {
|
||||
"name": "Data Type",
|
||||
"type": "string",
|
||||
"description": "Data type for model weights and activations.",
|
||||
"options": [
|
||||
{
|
||||
"label": "auto",
|
||||
"value": "auto"
|
||||
},
|
||||
{
|
||||
"label": "half",
|
||||
"value": "half"
|
||||
},
|
||||
{
|
||||
"label": "float16",
|
||||
"value": "float16"
|
||||
},
|
||||
{
|
||||
"label": "bfloat16",
|
||||
"value": "bfloat16"
|
||||
},
|
||||
{
|
||||
"label": "float",
|
||||
"value": "float"
|
||||
},
|
||||
{
|
||||
"label": "float32",
|
||||
"value": "float32"
|
||||
}
|
||||
],
|
||||
"default": "auto",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "KV_CACHE_DTYPE",
|
||||
"input": {
|
||||
"name": "KV Cache Data Type",
|
||||
"type": "string",
|
||||
"description": "Data type for KV cache storage.",
|
||||
"options": [
|
||||
{
|
||||
"label": "auto",
|
||||
"value": "auto"
|
||||
},
|
||||
{
|
||||
"label": "fp8",
|
||||
"value": "fp8"
|
||||
}
|
||||
],
|
||||
"default": "auto",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "MAX_MODEL_LEN",
|
||||
"input": {
|
||||
"name": "Max Model Length",
|
||||
"type": "number",
|
||||
"description": "Model context length.",
|
||||
"default": null,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "DISTRIBUTED_EXECUTOR_BACKEND",
|
||||
"input": {
|
||||
"name": "Distributed Executor Backend",
|
||||
"type": "string",
|
||||
"description": "Backend to use for distributed serving.",
|
||||
"options": [
|
||||
{
|
||||
"label": "ray",
|
||||
"value": "ray"
|
||||
},
|
||||
{
|
||||
"label": "mp",
|
||||
"value": "mp"
|
||||
}
|
||||
],
|
||||
"advanced": true,
|
||||
"default": "mp"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "RAY_WORKERS_USE_NSIGHT",
|
||||
"input": {
|
||||
"name": "Ray Workers Use Nsight",
|
||||
"type": "boolean",
|
||||
"description": "If specified, use nsight to profile Ray workers.",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "PIPELINE_PARALLEL_SIZE",
|
||||
"input": {
|
||||
"name": "Pipeline Parallel Size",
|
||||
"type": "number",
|
||||
"description": "Number of pipeline stages.",
|
||||
"default": 1,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "TENSOR_PARALLEL_SIZE",
|
||||
"input": {
|
||||
"name": "Tensor Parallel Size",
|
||||
"type": "number",
|
||||
"description": "Number of tensor parallel replicas.",
|
||||
"default": 1,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "MAX_PARALLEL_LOADING_WORKERS",
|
||||
"input": {
|
||||
"name": "Max Parallel Loading Workers",
|
||||
"type": "number",
|
||||
"description": "Load model sequentially in multiple batches.",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "ENABLE_PREFIX_CACHING",
|
||||
"input": {
|
||||
"name": "Enable Prefix Caching",
|
||||
"type": "boolean",
|
||||
"description": "Enables automatic prefix caching.",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "DISABLE_SLIDING_WINDOW",
|
||||
"input": {
|
||||
"name": "Disable Sliding Window",
|
||||
"type": "boolean",
|
||||
"description": "Disables sliding window, capping to sliding window size.",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "SEED",
|
||||
"input": {
|
||||
"name": "Seed",
|
||||
"type": "number",
|
||||
"description": "Random seed for operations.",
|
||||
"default": 0,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "MAX_NUM_BATCHED_TOKENS",
|
||||
"input": {
|
||||
"name": "Max Num Batched Tokens",
|
||||
"type": "number",
|
||||
"description": "Maximum number of batched tokens per iteration.",
|
||||
"default": null,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "MAX_NUM_SEQS",
|
||||
"input": {
|
||||
"name": "Max Num Seqs",
|
||||
"type": "number",
|
||||
"description": "Maximum number of sequences per iteration.",
|
||||
"default": 256,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "MAX_LOGPROBS",
|
||||
"input": {
|
||||
"name": "Max Logprobs",
|
||||
"type": "number",
|
||||
"description": "Max number of log probs to return when logprobs is specified in SamplingParams.",
|
||||
"default": 20,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "DISABLE_LOG_STATS",
|
||||
"input": {
|
||||
"name": "Disable Log Stats",
|
||||
"type": "boolean",
|
||||
"description": "Disable logging statistics.",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "QUANTIZATION",
|
||||
"input": {
|
||||
"name": "Quantization",
|
||||
"type": "string",
|
||||
"description": "Method used to quantize the weights.",
|
||||
"options": [
|
||||
{
|
||||
"label": "None",
|
||||
"value": "None"
|
||||
},
|
||||
{
|
||||
"label": "AWQ",
|
||||
"value": "awq"
|
||||
},
|
||||
{
|
||||
"label": "SqueezeLLM",
|
||||
"value": "squeezellm"
|
||||
},
|
||||
{
|
||||
"label": "GPTQ",
|
||||
"value": "gptq"
|
||||
}
|
||||
],
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "ENABLE_LORA",
|
||||
"input": {
|
||||
"name": "Enable LoRA",
|
||||
"type": "boolean",
|
||||
"description": "If True, enable handling of LoRA adapters.",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "MAX_LORAS",
|
||||
"input": {
|
||||
"name": "Max LoRAs",
|
||||
"type": "number",
|
||||
"description": "Max number of LoRAs in a single batch.",
|
||||
"default": 1,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "MAX_LORA_RANK",
|
||||
"input": {
|
||||
"name": "Max LoRA Rank",
|
||||
"type": "number",
|
||||
"description": "Max LoRA rank.",
|
||||
"default": 16,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "LORA_DTYPE",
|
||||
"input": {
|
||||
"name": "LoRA Data Type",
|
||||
"type": "string",
|
||||
"description": "Data type for LoRA.",
|
||||
"options": [
|
||||
{
|
||||
"label": "auto",
|
||||
"value": "auto"
|
||||
},
|
||||
{
|
||||
"label": "float16",
|
||||
"value": "float16"
|
||||
},
|
||||
{
|
||||
"label": "bfloat16",
|
||||
"value": "bfloat16"
|
||||
},
|
||||
{
|
||||
"label": "float32",
|
||||
"value": "float32"
|
||||
}
|
||||
],
|
||||
"default": "auto",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "MAX_CPU_LORAS",
|
||||
"input": {
|
||||
"name": "Max CPU LoRAs",
|
||||
"type": "number",
|
||||
"description": "Maximum number of LoRAs to store in CPU memory.",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "FULLY_SHARDED_LORAS",
|
||||
"input": {
|
||||
"name": "Fully Sharded LoRAs",
|
||||
"type": "boolean",
|
||||
"description": "Enable fully sharded LoRA layers.",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "DEVICE",
|
||||
"input": {
|
||||
"name": "Device",
|
||||
"type": "string",
|
||||
"description": "Device type for vLLM execution.",
|
||||
"options": [
|
||||
{
|
||||
"label": "auto",
|
||||
"value": "auto"
|
||||
},
|
||||
{
|
||||
"label": "cuda",
|
||||
"value": "cuda"
|
||||
},
|
||||
{
|
||||
"label": "neuron",
|
||||
"value": "neuron"
|
||||
},
|
||||
{
|
||||
"label": "cpu",
|
||||
"value": "cpu"
|
||||
},
|
||||
{
|
||||
"label": "openvino",
|
||||
"value": "openvino"
|
||||
},
|
||||
{
|
||||
"label": "tpu",
|
||||
"value": "tpu"
|
||||
},
|
||||
{
|
||||
"label": "xpu",
|
||||
"value": "xpu"
|
||||
}
|
||||
],
|
||||
"default": "auto",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "SCHEDULER_DELAY_FACTOR",
|
||||
"input": {
|
||||
"name": "Scheduler Delay Factor",
|
||||
"type": "number",
|
||||
"description": "Apply a delay before scheduling next prompt.",
|
||||
"default": 0,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "ENABLE_CHUNKED_PREFILL",
|
||||
"input": {
|
||||
"name": "Enable Chunked Prefill",
|
||||
"type": "boolean",
|
||||
"description": "Enable chunked prefill requests.",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "SPECULATIVE_CONFIG",
|
||||
"input": {
|
||||
"name": "Speculative Config (JSON)",
|
||||
"type": "string",
|
||||
"description": "Full speculative decoding configuration as a JSON string. Overrides individual speculative env vars.",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "SPECULATIVE_METHOD",
|
||||
"input": {
|
||||
"name": "Speculative Method",
|
||||
"type": "string",
|
||||
"description": "Speculative decoding method to use.",
|
||||
"options": [
|
||||
{ "label": "None", "value": "" },
|
||||
{ "label": "Draft Model", "value": "draft_model" },
|
||||
{ "label": "N-gram", "value": "ngram" },
|
||||
{ "label": "EAGLE", "value": "eagle" },
|
||||
{ "label": "EAGLE3", "value": "eagle3" },
|
||||
{ "label": "Medusa", "value": "medusa" },
|
||||
{ "label": "MLP Speculator", "value": "mlp_speculator" }
|
||||
],
|
||||
"default": "",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "SPECULATIVE_MODEL",
|
||||
"input": {
|
||||
"name": "Speculative Model",
|
||||
"type": "string",
|
||||
"description": "The name of the draft model to be used in speculative decoding.",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "NUM_SPECULATIVE_TOKENS",
|
||||
"input": {
|
||||
"name": "Num Speculative Tokens",
|
||||
"type": "number",
|
||||
"description": "The number of speculative tokens to sample from the draft model.",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "NGRAM_PROMPT_LOOKUP_MAX",
|
||||
"input": {
|
||||
"name": "Ngram Prompt Lookup Max",
|
||||
"type": "number",
|
||||
"description": "Max size of window for ngram prompt lookup in speculative decoding.",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "MODEL_LOADER_EXTRA_CONFIG",
|
||||
"input": {
|
||||
"name": "Model Loader Extra Config",
|
||||
"type": "string",
|
||||
"description": "Extra config for model loader.",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "ENABLE_LOG_REQUESTS",
|
||||
"input": {
|
||||
"name": "Enable Log Requests",
|
||||
"type": "boolean",
|
||||
"description": "Enable vLLM request logging.",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "TOKENIZER_NAME",
|
||||
"input": {
|
||||
"name": "Tokenizer Name",
|
||||
"type": "string",
|
||||
"description": "Tokenizer repo to use a different tokenizer than the model's default",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "TOKENIZER_REVISION",
|
||||
"input": {
|
||||
"name": "Tokenizer Revision",
|
||||
"type": "string",
|
||||
"description": "Tokenizer revision to load",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "CUSTOM_CHAT_TEMPLATE",
|
||||
"input": {
|
||||
"name": "Custom Chat Template",
|
||||
"type": "string",
|
||||
"description": "Custom chat jinja template",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "GPU_MEMORY_UTILIZATION",
|
||||
"input": {
|
||||
"name": "GPU Memory Utilization",
|
||||
"type": "number",
|
||||
"description": "Sets GPU VRAM utilization",
|
||||
"default": 0.95,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "BLOCK_SIZE",
|
||||
"input": {
|
||||
"name": "Block Size",
|
||||
"type": "number",
|
||||
"description": "Token block size for contiguous chunks of tokens",
|
||||
"default": 16,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "SWAP_SPACE",
|
||||
"input": {
|
||||
"name": "Swap Space",
|
||||
"type": "number",
|
||||
"description": "CPU swap space size (GiB) per GPU",
|
||||
"default": 4,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "ENFORCE_EAGER",
|
||||
"input": {
|
||||
"name": "Enforce Eager",
|
||||
"type": "boolean",
|
||||
"description": "Always use eager-mode PyTorch. If False (0), will use eager mode and CUDA graph in hybrid for maximal performance and flexibility",
|
||||
"default": true,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "DISABLE_CUSTOM_ALL_REDUCE",
|
||||
"input": {
|
||||
"name": "Disable Custom All Reduce",
|
||||
"type": "boolean",
|
||||
"description": "Enables or disables custom all reduce",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "DEFAULT_BATCH_SIZE",
|
||||
"input": {
|
||||
"name": "Default Final Batch Size",
|
||||
"type": "number",
|
||||
"description": "Default and Maximum batch size for token streaming to reduce HTTP calls",
|
||||
"default": 50,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "DEFAULT_MIN_BATCH_SIZE",
|
||||
"input": {
|
||||
"name": "Default Starting Batch Size",
|
||||
"type": "number",
|
||||
"description": "Batch size for the first request, which will be multiplied by the growth factor every subsequent request",
|
||||
"default": 1,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "DEFAULT_BATCH_SIZE_GROWTH_FACTOR",
|
||||
"input": {
|
||||
"name": "Default Batch Size Growth Factor",
|
||||
"type": "number",
|
||||
"description": "Growth factor for dynamic batch size",
|
||||
"default": 3,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "RAW_OPENAI_OUTPUT",
|
||||
"input": {
|
||||
"name": "Raw OpenAI Output",
|
||||
"type": "boolean",
|
||||
"description": "Raw OpenAI output instead of just the text",
|
||||
"default": true,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "OPENAI_RESPONSE_ROLE",
|
||||
"input": {
|
||||
"name": "OpenAI Response Role",
|
||||
"type": "string",
|
||||
"description": "Role of the LLM's Response in OpenAI Chat Completions",
|
||||
"default": "assistant",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "OPENAI_SERVED_MODEL_NAME_OVERRIDE",
|
||||
"input": {
|
||||
"name": "OpenAI Served Model Name Override",
|
||||
"type": "string",
|
||||
"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",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "MAX_CONCURRENCY",
|
||||
"input": {
|
||||
"name": "Max Concurrency",
|
||||
"type": "number",
|
||||
"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",
|
||||
"default": 30,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "ENABLE_EXPERT_PARALLEL",
|
||||
"input": {
|
||||
"name": "Enable Expert Parallel",
|
||||
"type": "boolean",
|
||||
"description": "Enable Expert Parallel for MoE models",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "MODEL_REVISION",
|
||||
"input": {
|
||||
"name": "Model Revision",
|
||||
"type": "string",
|
||||
"description": "Model revision (branch) to load",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "BASE_PATH",
|
||||
"input": {
|
||||
"name": "Base Path",
|
||||
"type": "string",
|
||||
"description": "Storage directory for Huggingface cache and model",
|
||||
"default": "/runpod-volume",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "ENABLE_AUTO_TOOL_CHOICE",
|
||||
"input": {
|
||||
"name": "Enable Auto Tool Choice",
|
||||
"type": "boolean",
|
||||
"description": "Enables or disables auto tool choice",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "TOOL_CALL_PARSER",
|
||||
"input": {
|
||||
"name": "Tool Call Parser",
|
||||
"type": "string",
|
||||
"description": "Tool call parser",
|
||||
"options": [
|
||||
{
|
||||
"label": "None",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "Hermes",
|
||||
"value": "hermes"
|
||||
},
|
||||
{
|
||||
"label": "Mistral",
|
||||
"value": "mistral"
|
||||
},
|
||||
{
|
||||
"label": "Llama3 JSON",
|
||||
"value": "llama3_json"
|
||||
},
|
||||
{
|
||||
"label": "Pythonic",
|
||||
"value": "pythonic"
|
||||
},
|
||||
{
|
||||
"label": "InternLM",
|
||||
"value": "internlm"
|
||||
}
|
||||
],
|
||||
"default": "",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "REASONING_PARSER",
|
||||
"input": {
|
||||
"name": "Reasoning Parser",
|
||||
"type": "string",
|
||||
"description": "Parser for reasoning-capable models (enables reasoning mode)",
|
||||
"options": [
|
||||
{ "label": "None", "value": "" },
|
||||
{ "label": "DeepSeek R1", "value": "deepseek_r1" },
|
||||
{ "label": "Qwen3", "value": "qwen3" },
|
||||
{ "label": "Granite", "value": "granite" },
|
||||
{ "label": "Hunyuan A13B", "value": "hunyuan_a13b" }
|
||||
],
|
||||
"default": "",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "PYTORCH_ALLOC_CONF",
|
||||
"input": {
|
||||
"name": "PyTorch Alloc Config",
|
||||
"type": "string",
|
||||
"description": "PyTorch allocation configuration, remove this if you want to use the default configuration",
|
||||
"default": "expandable_segments:True",
|
||||
"advanced": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "VLLM_USE_DEEP_GEMM",
|
||||
"input": {
|
||||
"name": "Use DeepGEMM",
|
||||
"type": "string",
|
||||
"description": "Enable DeepGEMM FP8 kernels (MoE and MQA logits). Set to 1 to enable, 0 to disable. Required for DeepSeek V4 models. Disabled by default — enable on H100/H200 for potential throughput gains. Some GPUs (e.g. H20) may perform better with this off.",
|
||||
"default": "0",
|
||||
"advanced": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"tests": [
|
||||
{
|
||||
"name": "basic_inference_test",
|
||||
"input": {
|
||||
"prompt": "Write a short poem about artificial intelligence."
|
||||
},
|
||||
"timeout": 30000
|
||||
},
|
||||
{
|
||||
"name": "openai_messages_test",
|
||||
"input": {
|
||||
"openai_route": "/v1/chat/completions",
|
||||
"openai_input": {
|
||||
"messages": [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a helpful assistant that writes concise responses."
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Explain what a neural network is in one sentence."
|
||||
}
|
||||
],
|
||||
"max_tokens": 200,
|
||||
"temperature": 0.1
|
||||
}
|
||||
},
|
||||
"timeout": 30000
|
||||
}
|
||||
],
|
||||
"config": {
|
||||
"gpuTypeId": "NVIDIA GeForce RTX 4090",
|
||||
"gpuCount": 1,
|
||||
"env": [
|
||||
{
|
||||
"key": "MODEL_NAME",
|
||||
"value": "HuggingFaceTB/SmolLM2-135M-Instruct"
|
||||
}
|
||||
],
|
||||
"allowedCudaVersions": ["12.9", "12.8", "12.7", "12.6", "12.5"]
|
||||
}
|
||||
}
|
||||
+32
-13
@@ -1,19 +1,22 @@
|
||||
FROM nvidia/cuda:12.1.0-base-ubuntu22.04
|
||||
FROM nvidia/cuda:13.0.2-devel-ubuntu22.04
|
||||
|
||||
RUN apt-get update -y \
|
||||
&& apt-get install -y python3-pip
|
||||
&& apt-get install -y python3-pip curl git \
|
||||
&& curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
|
||||
RUN ldconfig /usr/local/cuda-12.1/compat/
|
||||
ENV PATH="/root/.local/bin:$PATH"
|
||||
|
||||
# Install Python dependencies
|
||||
RUN ldconfig /usr/local/cuda-13.0/compat/
|
||||
|
||||
# Install vLLM with FlashInfer - use CUDA 130 PyTorch wheels
|
||||
RUN uv pip install --system "packaging>=24.2" && \
|
||||
uv pip install --system "vllm[flashinfer]==0.20.2" && \
|
||||
uv pip install --system git+https://github.com/deepseek-ai/DeepGEMM.git@714dd1a4a980f7937a74343d19a8eba4fe321480 --no-build-isolation
|
||||
|
||||
# Install additional Python dependencies (after vLLM to avoid PyTorch version conflicts)
|
||||
COPY builder/requirements.txt /requirements.txt
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
python3 -m pip install --upgrade pip && \
|
||||
python3 -m pip install --upgrade -r /requirements.txt
|
||||
|
||||
# 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 python3 -m pip install vllm==0.6.2 && \
|
||||
python3 -m pip install flashinfer -i https://flashinfer.ai/whl/cu121/torch2.3
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
uv pip install --system -r /requirements.txt
|
||||
|
||||
# Setup for Option 2: Building the Image with the Model included
|
||||
ARG MODEL_NAME=""
|
||||
@@ -22,6 +25,7 @@ ARG BASE_PATH="/runpod-volume"
|
||||
ARG QUANTIZATION=""
|
||||
ARG MODEL_REVISION=""
|
||||
ARG TOKENIZER_REVISION=""
|
||||
ARG VLLM_NIGHTLY="false"
|
||||
|
||||
ENV MODEL_NAME=$MODEL_NAME \
|
||||
MODEL_REVISION=$MODEL_REVISION \
|
||||
@@ -32,12 +36,27 @@ ENV MODEL_NAME=$MODEL_NAME \
|
||||
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
|
||||
HF_HUB_ENABLE_HF_TRANSFER=0 \
|
||||
# Suppress Ray metrics agent warnings (not needed in containerized environments)
|
||||
RAY_METRICS_EXPORT_ENABLED=0 \
|
||||
RAY_DISABLE_USAGE_STATS=1 \
|
||||
# Prevent rayon thread pool panic in containers where ulimit -u < nproc
|
||||
# (tokenizers uses Rust's rayon which tries to spawn threads = CPU cores)
|
||||
TOKENIZERS_PARALLELISM=false \
|
||||
RAYON_NUM_THREADS=4 \
|
||||
# Disable DeepGEMM MoE kernels by default; override with VLLM_USE_DEEP_GEMM=1 to enable
|
||||
VLLM_USE_DEEP_GEMM=0
|
||||
|
||||
ENV PYTHONPATH="/:/vllm-workspace"
|
||||
|
||||
RUN if [ "${VLLM_NIGHTLY}" = "true" ]; then \
|
||||
uv pip install --system -U vllm --pre --index-url https://pypi.org/simple --extra-index-url https://wheels.vllm.ai/nightly && \
|
||||
apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* && \
|
||||
uv pip install --system git+https://github.com/huggingface/transformers.git; \
|
||||
fi
|
||||
|
||||
COPY src /src
|
||||
RUN chmod +x /src/start.sh
|
||||
RUN --mount=type=secret,id=HF_TOKEN,required=false \
|
||||
if [ -f /run/secrets/HF_TOKEN ]; then \
|
||||
export HF_TOKEN=$(cat /run/secrets/HF_TOKEN); \
|
||||
@@ -47,4 +66,4 @@ RUN --mount=type=secret,id=HF_TOKEN,required=false \
|
||||
fi
|
||||
|
||||
# Start the handler
|
||||
CMD ["python3", "/src/handler.py"]
|
||||
CMD ["/bin/bash", "/src/start.sh"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 runpod-workers
|
||||
Copyright (c) 2025 Runpod
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,50 +1,25 @@
|
||||
<div align="center">
|
||||
|
||||
# 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.
|
||||
<!--
|
||||

|
||||

|
||||
\
|
||||
 -->
|
||||
<!--
|
||||
 -->
|
||||
|
||||
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.
|
||||
|
||||
</div>
|
||||
|
||||
# News:
|
||||

|
||||
|
||||
### 1. UI for Deploying vLLM Worker on RunPod console:
|
||||

|
||||
|
||||
### 2. Worker vLLM `v1.5.0` with vLLM `0.6.2` now available under `stable` tags
|
||||
|
||||
Update v1.5.0 is now available, use the image tag `runpod/worker-v1-vllm:v1.5.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!
|
||||
Current vLLM version: [0.20.2](https://github.com/vllm-project/vllm/releases/tag/v0.20.2)
|
||||
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
> Check out our Load Balancer implementation here: [vLLM Load Balancer](https://github.com/runpod-workers/vllm-loadbalancer-ep)
|
||||
|
||||
## 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 1: Deploy Any Model Using Pre-Built Docker Image [Recommended]](#option-1-deploy-any-model-using-pre-built-docker-image-recommended)
|
||||
- [Configuration](#configuration)
|
||||
- [Option 2: Build Docker Image with Model Inside](#option-2-build-docker-image-with-model-inside)
|
||||
- [Prerequisites](#prerequisites-1)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [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)
|
||||
@@ -52,149 +27,73 @@ Worker vLLM is now cached on all RunPod machines, resulting in near-instant depl
|
||||
- [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 [RECOMMENDED]](#chat-completions-recommended)
|
||||
- [Examples: Using your Runpod endpoint with OpenAI](#examples-using-your-runpod-endpoint-with-openai)
|
||||
- [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)
|
||||
- [Getting a list of names for available models](#getting-a-list-of-names-for-available-models)
|
||||
- [OpenAI Responses API](#openai-responses-api)
|
||||
- [Anthropic Messages API](#anthropic-messages-api)
|
||||
- [Usage: Standard (Non-OpenAI)](#usage-standard-non-openai)
|
||||
- [Request Input Parameters](#request-input-parameters)
|
||||
- [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)
|
||||
- [Text Input Formats](#text-input-formats)
|
||||
|
||||
# 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]
|
||||
|
||||
> [!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!
|
||||
**🚀 Deploy Guide**: Follow our [step-by-step deployment guide](https://docs.runpod.io/serverless/vllm/get-started) to deploy using the Runpod Console.
|
||||
|
||||
**📦 Docker Image**: `runpod/worker-v1-vllm:<version>`
|
||||
|
||||
- **Available Versions**: See [GitHub Releases](https://github.com/runpod-workers/worker-vllm/releases)
|
||||
- **CUDA Compatibility**: Requires CUDA >= 13.0
|
||||
|
||||
### Configuration
|
||||
|
||||
Configure worker-vllm using environment variables:
|
||||
|
||||
| Environment Variable | Description | Default | Options |
|
||||
| ----------------------------------- | ------------------------------------------------- | ------------------- | ------------------------------------------------------------------ |
|
||||
| `MODEL_NAME` | Path of the model weights | "facebook/opt-125m" | Local folder or Hugging Face repo ID |
|
||||
| `HF_TOKEN` | HuggingFace access token for gated/private models | | Your HuggingFace access token |
|
||||
| `MAX_MODEL_LEN` | Model's maximum context length | | Integer (e.g., 4096) |
|
||||
| `QUANTIZATION` | Quantization method | | "awq", "gptq", "squeezellm", "bitsandbytes" |
|
||||
| `TENSOR_PARALLEL_SIZE` | Number of GPUs | 1 | Integer |
|
||||
| `GPU_MEMORY_UTILIZATION` | Fraction of GPU memory to use | 0.95 | Float between 0.0 and 1.0 |
|
||||
| `MAX_NUM_SEQS` | Maximum number of sequences per iteration | 256 | Integer |
|
||||
| `CUSTOM_CHAT_TEMPLATE` | Custom chat template override | | Jinja2 template string |
|
||||
| `ENABLE_AUTO_TOOL_CHOICE` | Enable automatic tool selection | false | boolean (true or false) |
|
||||
| `TOOL_CALL_PARSER` | Parser for tool calls | | "mistral", "hermes", "llama3_json", "granite", "deepseek_v3", etc. |
|
||||
| `OPENAI_SERVED_MODEL_NAME_OVERRIDE` | Override served model name in API | | String |
|
||||
| `MAX_CONCURRENCY` | Maximum concurrent requests | 30 | Integer |
|
||||
|
||||
**Pass any vLLM engine arg** not listed above by setting an environment variable with the **UPPERCASED** field name (same names vLLM uses). The worker auto-discovers all `AsyncEngineArgs` fields from env. For example:
|
||||
|
||||
| Environment Variable | vLLM Engine Arg | Example Value |
|
||||
| ------------------------- | ------------------------ | ------------- |
|
||||
| `MAX_MODEL_LEN` | `max_model_len` | `4096` |
|
||||
| `ENFORCE_EAGER` | `enforce_eager` | `true` |
|
||||
| `ENABLE_CHUNKED_PREFILL` | `enable_chunked_prefill` | `true` |
|
||||
|
||||
Any env var whose name matches a valid `AsyncEngineArgs` field (uppercased) is applied automatically. Backward-compat aliases: `MODEL_NAME`, `TOKENIZER_NAME`, `MAX_CONTEXT_LEN_TO_CAPTURE`. This lets you configure any vLLM option without waiting for explicit worker support.
|
||||
|
||||
For the complete list of all available environment variables, examples, and detailed descriptions: **[Configuration](docs/configuration.md)**
|
||||
|
||||
### Specify Transformers Version
|
||||
To change the version of the [Transformers library](https://github.com/huggingface/transformers) use the `TRANSFORMERS_VERSION` environment variable to specify the version you want to use. Note this might break the handler, so use for development purposes.
|
||||
|
||||
|
||||
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:
|
||||
## Option 2: Build Docker Image with Model Inside
|
||||
|
||||
---
|
||||
|
||||
## RunPod Worker Images
|
||||
|
||||
Below is a summary of the available RunPod Worker images, categorized by image stability and CUDA version compatibility.
|
||||
|
||||
| CUDA Version | Stable Image Tag | Development Image Tag | Note |
|
||||
|--------------|-----------------------------------|-----------------------------------|----------------------------------------------------------------------|
|
||||
| 12.1.0 | `runpod/worker-v1-vllm:v15.0stable-cuda12.1.0` | `runpod/worker-v1-vllm:v1.5.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`.
|
||||
|
||||
|
||||
### Option 2: Build Docker Image with Model Inside
|
||||
To build an image with the model baked in, you must specify the following docker arguments when building the image.
|
||||
|
||||
#### Prerequisites
|
||||
- RunPod Account
|
||||
### Prerequisites
|
||||
|
||||
- Docker
|
||||
|
||||
#### Arguments:
|
||||
### Arguments
|
||||
|
||||
- **Required**
|
||||
- `MODEL_NAME`
|
||||
- **Optional**
|
||||
@@ -204,80 +103,76 @@ To build an image with the model baked in, you must specify the following docker
|
||||
- `WORKER_CUDA_VERSION`: `12.1.0` (`12.1.0` 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`).
|
||||
- `VLLM_NIGHTLY`: Set to `true` to replace the pinned vLLM release with the latest nightly build and the latest `transformers` from source. Useful for testing unreleased vLLM features. (default: `false`)
|
||||
|
||||
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
|
||||
|
||||
```bash
|
||||
sudo docker build -t username/image:tag --build-arg MODEL_NAME="openchat/openchat_3.5" --build-arg BASE_PATH="/models" .
|
||||
docker build -t username/image:tag --build-arg MODEL_NAME="openchat/openchat_3.5" --build-arg BASE_PATH="/models" .
|
||||
```
|
||||
|
||||
##### (Optional) Including Huggingface Token
|
||||
### Example: Building with vLLM Nightly
|
||||
|
||||
To use the latest unreleased vLLM build (installs from the nightly wheel index and `transformers` from source):
|
||||
|
||||
```bash
|
||||
docker build -t username/image:tag --build-arg VLLM_NIGHTLY=true .
|
||||
```
|
||||
|
||||
You can combine it with other arguments:
|
||||
|
||||
```bash
|
||||
docker build -t username/image:tag --build-arg VLLM_NIGHTLY=true --build-arg MODEL_NAME="meta-llama/Llama-3.1-8B-Instruct" --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 Model Architectures
|
||||
|
||||
- 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.)
|
||||
- BLOOM (`bigscience/bloom`, `bigscience/bloomz`, 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.)
|
||||
- Gemma (`google/gemma-2b`, `google/gemma-7b`, etc.)
|
||||
- GPT-2 (`gpt2`, `gpt2-xl`, etc.)
|
||||
- GPT BigCode (`bigcode/starcoder`, `bigcode/gpt_bigcode-santacoder`, 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.)
|
||||
- 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.)
|
||||
- OLMo (`allenai/OLMo-1B-hf`, `allenai/OLMo-7B-hf`, 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-3 (`microsoft/Phi-3-mini-4k-instruct`, `microsoft/Phi-3-mini-128k-instruct`, 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.)
|
||||
You can deploy **any model on Hugging Face** that is supported by vLLM. For the complete and up-to-date list of supported model architectures, see the [vLLM Supported Models documentation](https://docs.vllm.ai/en/latest/models/supported_models.html#list-of-text-only-language-models).
|
||||
|
||||
# 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.
|
||||
|
||||
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>, <ins>Models</ins>, <ins>Responses</ins>, and <ins>Messages</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`.
|
||||
|
||||
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
|
||||
|
||||
@@ -286,12 +181,13 @@ The vLLM Worker is fully compatible with OpenAI's API, and you can use it with a
|
||||
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?"}],
|
||||
messages=[{"role": "user", "content": "Why is Runpod the best platform?"}],
|
||||
temperature=0,
|
||||
max_tokens=100,
|
||||
)
|
||||
@@ -300,14 +196,15 @@ The vLLM Worker is fully compatible with OpenAI's API, and you can use it with a
|
||||
```python
|
||||
response = client.chat.completions.create(
|
||||
model="<YOUR DEPLOYED MODEL REPO/NAME>",
|
||||
messages=[{"role": "user", "content": "Why is RunPod the best platform?"}],
|
||||
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`
|
||||
|
||||
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 \
|
||||
@@ -318,7 +215,7 @@ The vLLM Worker is fully compatible with OpenAI's API, and you can use it with a
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Why is RunPod the best platform?"
|
||||
"content": "Why is Runpod the best platform?"
|
||||
}
|
||||
],
|
||||
"temperature": 0,
|
||||
@@ -335,7 +232,7 @@ The vLLM Worker is fully compatible with OpenAI's API, and you can use it with a
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Why is RunPod the best platform?"
|
||||
"content": "Why is Runpod the best platform?"
|
||||
}
|
||||
],
|
||||
"temperature": 0,
|
||||
@@ -348,49 +245,52 @@ The vLLM Worker is fully compatible with OpenAI's API, and you can use it with a
|
||||
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.|
|
||||
| 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>
|
||||
|
||||
### Examples: Using your Runpod endpoint with OpenAI
|
||||
|
||||
## Examples: Using your RunPod endpoint with OpenAI
|
||||
First, initialize the OpenAI Client with your Runpod API Key and Endpoint URL:
|
||||
|
||||
First, initialize the OpenAI Client with your RunPod API Key and Endpoint URL:
|
||||
```python
|
||||
from openai import OpenAI
|
||||
import os
|
||||
|
||||
# Initialize the OpenAI Client with your RunPod API Key and Endpoint URL
|
||||
# Initialize the OpenAI Client with your Runpod API Key and Endpoint URL
|
||||
client = OpenAI(
|
||||
api_key=os.environ.get("RUNPOD_API_KEY"),
|
||||
base_url="https://api.runpod.ai/v2/<YOUR ENDPOINT ID>/openai/v1",
|
||||
@@ -398,13 +298,15 @@ client = OpenAI(
|
||||
```
|
||||
|
||||
### Chat Completions:
|
||||
|
||||
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**:
|
||||
```python
|
||||
# Create a chat completion stream
|
||||
response_stream = client.chat.completions.create(
|
||||
model="<YOUR DEPLOYED MODEL REPO/NAME>",
|
||||
messages=[{"role": "user", "content": "Why is RunPod the best platform?"}],
|
||||
messages=[{"role": "user", "content": "Why is Runpod the best platform?"}],
|
||||
temperature=0,
|
||||
max_tokens=100,
|
||||
stream=True,
|
||||
@@ -418,7 +320,7 @@ This is the format used for GPT-4 and focused on instruction-following and chat.
|
||||
# Create a chat completion
|
||||
response = client.chat.completions.create(
|
||||
model="<YOUR DEPLOYED MODEL REPO/NAME>",
|
||||
messages=[{"role": "user", "content": "Why is RunPod the best platform?"}],
|
||||
messages=[{"role": "user", "content": "Why is Runpod the best platform?"}],
|
||||
temperature=0,
|
||||
max_tokens=100,
|
||||
)
|
||||
@@ -427,14 +329,73 @@ This is the format used for GPT-4 and focused on instruction-following and chat.
|
||||
```
|
||||
|
||||
### 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)
|
||||
```
|
||||
|
||||
### OpenAI Responses API
|
||||
|
||||
**Path:** `/openai/v1/responses` (full URL: `https://api.runpod.ai/v2/<YOUR ENDPOINT ID>/openai/v1/responses`)
|
||||
|
||||
Supports the [OpenAI Responses API](https://platform.openai.com/docs/api-reference/responses) request shape. Like other `/openai/` routes, this is served directly—use the `/openai/` prefix rather than the RunPod native job queue for these calls.
|
||||
|
||||
```json
|
||||
{
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"input": "Tell me a joke."
|
||||
}
|
||||
```
|
||||
|
||||
**Using HTTP requests:**
|
||||
|
||||
```bash
|
||||
curl https://api.runpod.ai/v2/<YOUR ENDPOINT ID>/openai/v1/responses \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer <YOUR RUNPOD API KEY>" \
|
||||
-d '{
|
||||
"model": "<YOUR DEPLOYED MODEL REPO/NAME>",
|
||||
"input": "Tell me a joke."
|
||||
}'
|
||||
```
|
||||
|
||||
### Anthropic Messages API
|
||||
|
||||
**Path:** `/openai/v1/messages` (full URL: `https://api.runpod.ai/v2/<YOUR ENDPOINT ID>/openai/v1/messages`)
|
||||
|
||||
Supports the [Anthropic Messages API](https://docs.anthropic.com/en/api/messages) format. Served directly, bypassing the RunPod queue.
|
||||
|
||||
```json
|
||||
{
|
||||
"model": "meta-llama/Llama-3.1-8B-Instruct",
|
||||
"max_tokens": 256,
|
||||
"messages": [
|
||||
{"role": "user", "content": "Hello!"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Using HTTP requests:**
|
||||
|
||||
```bash
|
||||
curl https://api.runpod.ai/v2/<YOUR ENDPOINT ID>/openai/v1/messages \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer <YOUR RUNPOD API KEY>" \
|
||||
-d '{
|
||||
"model": "<YOUR DEPLOYED MODEL REPO/NAME>",
|
||||
"max_tokens": 256,
|
||||
"messages": [
|
||||
{"role": "user", "content": "Hello!"}
|
||||
]
|
||||
}'
|
||||
```
|
||||
|
||||
# Usage: Standard (Non-OpenAI)
|
||||
|
||||
## Request Input Parameters
|
||||
|
||||
<details>
|
||||
@@ -456,148 +417,83 @@ print(list_of_models)
|
||||
### 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. |
|
||||
|
||||
| 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.
|
||||
|
||||
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": "..."
|
||||
{
|
||||
"input": {
|
||||
"prompt": "why sky is blue?",
|
||||
"sampling_params": {
|
||||
"temperature": 0.7,
|
||||
"max_tokens": 100
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
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`
|
||||
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
|
||||
{
|
||||
"input": {
|
||||
"messages": [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "..."
|
||||
"content": "You are a helpful AI assistant that provides clear and concise responses."
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "..."
|
||||
"content": "Can you explain the difference between supervised and unsupervised learning?"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "..."
|
||||
"content": "Sure! Supervised learning uses labeled data, meaning each input has a corresponding correct output. The model learns by mapping inputs to known outputs. In contrast, unsupervised learning works with unlabeled data, where the model identifies patterns, structures, or clusters without predefined answers."
|
||||
}
|
||||
],
|
||||
"sampling_params": {
|
||||
"temperature": 0.7,
|
||||
"max_tokens": 100
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</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,11 +1,15 @@
|
||||
ray
|
||||
pandas
|
||||
pyarrow
|
||||
runpod==1.7.1
|
||||
runpod==1.9.0
|
||||
huggingface-hub
|
||||
packaging
|
||||
typing-extensions==4.7.1
|
||||
lmcache==0.4.5
|
||||
packaging>=24.2
|
||||
typing-extensions>=4.8.0
|
||||
pydantic
|
||||
pydantic-settings
|
||||
hf-transfer
|
||||
transformers
|
||||
transformers>=5
|
||||
bitsandbytes>=0.45.0
|
||||
kernels
|
||||
torch-c-dlpack-ext
|
||||
|
||||
+13
-19
@@ -1,32 +1,26 @@
|
||||
variable "PUSH" {
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "REPOSITORY" {
|
||||
variable "DOCKERHUB_REPO" {
|
||||
default = "runpod"
|
||||
}
|
||||
|
||||
variable "BASE_IMAGE_VERSION" {
|
||||
default = "stable"
|
||||
variable "DOCKERHUB_IMG" {
|
||||
default = "worker-v1-vllm"
|
||||
}
|
||||
|
||||
group "all" {
|
||||
targets = ["main"]
|
||||
variable "RELEASE_VERSION" {
|
||||
default = "latest"
|
||||
}
|
||||
|
||||
|
||||
group "main" {
|
||||
targets = ["worker-1210"]
|
||||
variable "HUGGINGFACE_ACCESS_TOKEN" {
|
||||
default = ""
|
||||
}
|
||||
|
||||
group "default" {
|
||||
targets = ["worker-vllm"]
|
||||
}
|
||||
|
||||
target "worker-1210" {
|
||||
tags = ["${REPOSITORY}/worker-v1-vllm:${BASE_IMAGE_VERSION}-cuda12.1.0"]
|
||||
target "worker-vllm" {
|
||||
tags = ["${DOCKERHUB_REPO}/${DOCKERHUB_IMG}:${RELEASE_VERSION}"]
|
||||
context = "."
|
||||
dockerfile = "Dockerfile"
|
||||
args = {
|
||||
BASE_IMAGE_VERSION = "${BASE_IMAGE_VERSION}"
|
||||
WORKER_CUDA_VERSION = "12.1.0"
|
||||
}
|
||||
output = ["type=docker,push=${PUSH}"]
|
||||
platforms = ["linux/amd64"]
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
# Configuration Reference
|
||||
|
||||
Complete guide to all environment variables and configuration options for worker-vllm.
|
||||
|
||||
## LLM Settings
|
||||
|
||||
| Variable | Default | Type/Choices | Description |
|
||||
| ------------------------------ | ------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------- |
|
||||
| `MODEL_NAME` | 'facebook/opt-125m' | `str` | Name or path of the Hugging Face model to use. |
|
||||
| `MODEL_REVISION` | 'main' | `str` | Model revision to load (default: main). |
|
||||
| `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. |
|
||||
| `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', 'bitsandbytes'] | 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. |
|
||||
|
||||
## LoRA (Low-Rank Adaptation) Settings
|
||||
|
||||
| Variable | Default | Type | Description |
|
||||
| --------------------------- | ------- | ------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
|
||||
| `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. |
|
||||
| `LORA_MODULES` | `[]` | `list[dict]` | Add lora adapters from Hugging Face `[{"name": "xx", "path": "xxx/xxxx", "base_model_name": "xxx/xxxx"}]` |
|
||||
|
||||
> **Note (Serverless)**: When LoRA adapters are configured via `LORA_MODULES`, initialization is deferred to the first request to ensure compatibility with RunPod Serverless. This means the first request will include LoRA loading time. Subsequent requests are unaffected. Check logs for "LoRA mode: X adapter(s) will load on first request" at startup.
|
||||
|
||||
## Speculative Decoding Settings
|
||||
|
||||
Speculative decoding can be configured in two ways:
|
||||
|
||||
### Option 1: JSON Configuration
|
||||
|
||||
Set `SPECULATIVE_CONFIG` to a JSON string with your full speculative decoding configuration:
|
||||
|
||||
```bash
|
||||
SPECULATIVE_CONFIG='{"method": "ngram", "num_speculative_tokens": 5, "prompt_lookup_max": 4}'
|
||||
```
|
||||
|
||||
### Option 2: Individual Environment Variables
|
||||
|
||||
| Variable | Default | Type/Choices | Description |
|
||||
| ---------------------------------------- | ------- | ------------------------------------------------------------------ | ----------------------------------------------------------------------------------------- |
|
||||
| `SPECULATIVE_METHOD` | None | ['draft_model', 'ngram', 'eagle', 'eagle3', 'medusa', 'mlp_speculator'] | Speculative decoding method to use. |
|
||||
| `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. |
|
||||
|
||||
If `SPECULATIVE_CONFIG` is set, it takes priority over individual env vars. When using individual env vars without `SPECULATIVE_METHOD`, the method is auto-detected from the model name or configuration.
|
||||
|
||||
## Scheduling & Performance Settings
|
||||
|
||||
| Variable | Default | Type/Choices | Description |
|
||||
| ------------------------------ | ------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `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. |
|
||||
| `ENABLE_EXPERT_PARALLEL` | `False` | `bool` | Enable Expert Parallel for MoE models. |
|
||||
| `VLLM_USE_DEEP_GEMM` | `0` | `str` (`0`/`1`) | Enable DeepGEMM FP8 kernels for MoE and MQA logits computation. Disabled by default. Must be `"0"` or `"1"` — not `true`/`false`. See note below. |
|
||||
| `ATTENTION_BACKEND` | `None` | `str` | Attention backend to use (e.g., `FLASH_ATTN`, `FLASHINFER`, `TRITON_FLASH_ATTN`). Replaces deprecated `VLLM_ATTENTION_BACKEND`. |
|
||||
| `ASYNC_SCHEDULING` | `None` | `bool` | Enable async scheduling (overlaps engine scheduling with GPU execution). Default: enabled in vLLM 0.14.0+. Set to `false` to disable. |
|
||||
| `STREAM_INTERVAL` | `1` | `int` | Controls how often to yield streaming results. Lower = more frequent updates. |
|
||||
|
||||
> **Note (`VLLM_USE_DEEP_GEMM`):** DeepGEMM is used in two places: MoE weight computation and MQA logits computation. It is necessary for MQA logits computation on supported hardware — required for DeepSeek V4 models. Set `VLLM_USE_DEEP_GEMM=1` to enable. Set `VLLM_USE_DEEP_GEMM=0` to disable the MoE part and fall back to flashinfer/cutlass FP8 kernels. **Value must be `"0"` or `"1"` — not `"true"`/`"false"`.** Some users report better performance with `VLLM_USE_DEEP_GEMM=0`, particularly on H20 GPUs. Disabling it also skips the DeepGEMM warmup phase, reducing cold-start time. Requires CUDA 13.0+ and SM90+ (H100/H200) to use; the library is installed but inactive by default.
|
||||
|
||||
## Tokenizer Settings
|
||||
|
||||
| Variable | Default | Type/Choices | Description |
|
||||
| ---------------------- | ------- | ----------------------------------- | ------------------------------------------------------------------------------------------------- |
|
||||
| `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) |
|
||||
|
||||
## Streaming & Batch Settings
|
||||
|
||||
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.
|
||||
|
||||
| Variable | Default | Type/Choices | Description |
|
||||
| ---------------------------------- | ------- | ------------ | --------------------------------------------------------------------------------------------------------- |
|
||||
| `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. |
|
||||
|
||||
## OpenAI Compatibility Settings
|
||||
|
||||
| Variable | Default | Type/Choices | Description |
|
||||
| ----------------------------------- | ----------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `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. |
|
||||
| `ENABLE_AUTO_TOOL_CHOICE` | `false` | `bool` | Enables automatic tool selection for supported models. Set to `true` to activate. |
|
||||
| `TOOL_CALL_PARSER` | `None` | `str` | Specifies the parser for tool calls. Options: `mistral`, `hermes`, `llama3_json`, `llama4_json`, `llama4_pythonic`, `granite`, `granite-20b-fc`, `deepseek_v3`, `internlm`, `jamba`, `phi4_mini_json`, `pythonic` |
|
||||
| `REASONING_PARSER` | `None` | `str` | Parser for reasoning-capable models (enables reasoning mode). Examples: `deepseek_r1`, `qwen3`, `granite`, `hunyuan_a13b`. Leave unset to disable. |
|
||||
| `TRUST_REQUEST_CHAT_TEMPLATE` | `false` | `bool` | Allow clients to send custom chat templates in API requests. **Security consideration:** Only enable if you trust your API clients. |
|
||||
| `RETURN_TOKENS_AS_TOKEN_IDS` | `false` | `bool` | Return token IDs instead of decoded text strings in responses. |
|
||||
| `EXCLUDE_TOOLS_WHEN_TOOL_CHOICE_NONE` | `false` | `bool` | Exclude tool definitions from the prompt when `tool_choice` is set to `none`. |
|
||||
| `ENABLE_PROMPT_TOKENS_DETAILS` | `false` | `bool` | Include detailed prompt token information in API responses. |
|
||||
| `ENABLE_FORCE_INCLUDE_USAGE` | `false` | `bool` | Always include usage statistics in API responses, even when not requested. |
|
||||
| `ENABLE_LOG_OUTPUTS` | `false` | `bool` | Log model outputs for debugging purposes. |
|
||||
| `LOG_ERROR_STACK` | `false` | `bool` | Include full stack traces in error responses for debugging. |
|
||||
|
||||
## Serverless & Concurrency Settings
|
||||
|
||||
| Variable | Default | Type/Choices | Description |
|
||||
| ---------------------- | ------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `MAX_CONCURRENCY` | `30` | `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. |
|
||||
| `ENABLE_LOG_REQUESTS` | False | `bool` | Enables vLLM request logging. (Replaces deprecated `DISABLE_LOG_REQUESTS` in vLLM 0.15.0) |
|
||||
|
||||
## Advanced Settings
|
||||
|
||||
| Variable | Default | Type | Description |
|
||||
| --------------------------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `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. |
|
||||
|
||||
## UPPERCASED env vars: Pass any engine arg
|
||||
|
||||
Any vLLM `AsyncEngineArgs` field can be set via an environment variable using the **UPPERCASED** field name (the same names vLLM uses). The worker auto-discovers all fields from env — no prefix.
|
||||
|
||||
**Format:** `<FIELD_NAME_UPPERCASED>=<value>` (e.g. `MAX_MODEL_LEN=4096`)
|
||||
|
||||
**Examples:**
|
||||
|
||||
| Environment Variable | vLLM Engine Arg | Value Example |
|
||||
| ------------------------ | ------------------------ | ------------- |
|
||||
| `MAX_MODEL_LEN` | `max_model_len` | `4096` |
|
||||
| `ENFORCE_EAGER` | `enforce_eager` | `true` |
|
||||
| `ENABLE_CHUNKED_PREFILL` | `enable_chunked_prefill` | `true` |
|
||||
| `NUM_SCHEDULER_STEPS` | `num_scheduler_steps` | `8` |
|
||||
| `TOKENIZER_POOL_SIZE` | `tokenizer_pool_size` | `4` |
|
||||
|
||||
**Backward-compat aliases:** `MODEL_NAME` → `model`, `TOKENIZER_NAME` → `tokenizer`, `MAX_CONTEXT_LEN_TO_CAPTURE` → `max_seq_len_to_capture`, `MODEL_REVISION` → `revision`.
|
||||
|
||||
**Notes:**
|
||||
- Only valid `AsyncEngineArgs` fields are applied. Unknown keys are silently ignored.
|
||||
- Values are automatically cast to the correct type (`int`, `float`, `bool`, `str`, or JSON for `dict`/`list`/`tuple`).
|
||||
- For a full list of available engine args, see the [vLLM AsyncEngineArgs documentation](https://docs.vllm.ai/en/latest/configuration/engine_args/).
|
||||
|
||||
## Docker Build Arguments
|
||||
|
||||
These variables are used when building custom Docker images with models baked in:
|
||||
|
||||
| Variable | Default | Type | Description |
|
||||
| --------------------- | ---------------- | ----- | ------------------------------------------------- |
|
||||
| `BASE_PATH` | `/runpod-volume` | `str` | Storage directory for huggingface cache and model |
|
||||
| `WORKER_CUDA_VERSION` | `12.1.0` | `str` | CUDA version for the worker image |
|
||||
|
||||
## Deprecated Variables
|
||||
|
||||
⚠️ **The following variables are deprecated and will be removed in future versions:**
|
||||
|
||||
| Old Variable | New Variable | Note |
|
||||
| ---------------------------- | ------------------------ | -------------------------------------------------------------------- |
|
||||
| `MAX_CONTEXT_LEN_TO_CAPTURE` | `MAX_SEQ_LEN_TO_CAPTURE` | Use new variable name |
|
||||
| `kv_cache_dtype=fp8_e5m2` | `kv_cache_dtype=fp8` | Simplified fp8 format |
|
||||
| `USE_V2_BLOCK_MANAGER` | *(removed)* | V2 block manager is now the default in vLLM 0.13.0, setting ignored |
|
||||
| `VLLM_ATTENTION_BACKEND` | `ATTENTION_BACKEND` | Use new env var name (old still works with deprecation warning) |
|
||||
| `DISABLE_LOG_REQUESTS` | `ENABLE_LOG_REQUESTS` | Inverted logic in vLLM 0.15.0 (old still works with deprecation warning) |
|
||||
|
||||
@@ -0,0 +1,343 @@
|
||||
# Worker vLLM - Development Conventions & Architecture Guide
|
||||
|
||||
## Project Overview
|
||||
|
||||
**worker-vllm** is a RunPod serverless worker that provides OpenAI-compatible endpoints for Large Language Model (LLM) inference, powered by the vLLM engine. It enables blazing-fast LLM deployment on RunPod's serverless infrastructure with minimal configuration.
|
||||
|
||||
### Core Purpose
|
||||
|
||||
- **Primary Function**: Deploy any Hugging Face LLM as an OpenAI-compatible API endpoint
|
||||
- **Platform**: RunPod Serverless infrastructure
|
||||
- **Engine**: vLLM (high-performance LLM inference engine)
|
||||
- **Compatibility**: Drop-in replacement for OpenAI API (Chat Completions, Models)
|
||||
|
||||
## High-Level Architecture
|
||||
|
||||
### 1. **Entry Point & Request Flow**
|
||||
|
||||
```
|
||||
RunPod Request → handler.py → JobInput → Engine Selection → vLLM Generation → Streaming Response
|
||||
```
|
||||
|
||||
**Key Components:**
|
||||
|
||||
- `src/handler.py`: Main entry point using RunPod serverless framework
|
||||
- `src/utils.py`: Request parsing and utility classes (`JobInput`, `BatchSize`)
|
||||
- Two engine modes: OpenAI-compatible vs. standard vLLM
|
||||
|
||||
### 2. **Engine Architecture**
|
||||
|
||||
#### Core Classes:
|
||||
|
||||
- **`vLLMEngine`**: Base engine handling vLLM initialization and generation
|
||||
- **`OpenAIvLLMEngine`**: Wrapper providing OpenAI API compatibility
|
||||
- **Engine Selection**: Automatic routing based on `job_input.openai_route`
|
||||
|
||||
#### Key Design Patterns:
|
||||
|
||||
- **Dual API Support**: Same codebase serves both OpenAI-compatible and native vLLM APIs
|
||||
- **Streaming by Default**: Token-level streaming with configurable batching
|
||||
- **Dynamic Batching**: Adaptive batch sizes that grow from min → max for efficiency
|
||||
|
||||
### 3. **Configuration System**
|
||||
|
||||
#### Environment-Based Configuration:
|
||||
|
||||
- **Single Source of Truth**: All configuration via environment variables
|
||||
- **Hierarchical Loading**: `DEFAULT_ARGS` → `os.environ` → `local_model_args.json` (for baked models)
|
||||
- **vLLM Argument Mapping**: Automatic translation of env vars to vLLM `AsyncEngineArgs`
|
||||
|
||||
#### Key Configuration Files:
|
||||
|
||||
- `src/engine_args.py`: Centralized configuration management
|
||||
- `src/constants.py`: Default values for core settings
|
||||
- `.runpod/hub.json`: Hub UI configuration (CRITICAL: always update when changing defaults)
|
||||
- `worker-config.json`: UI form generation for RunPod console (if exists)
|
||||
|
||||
## Core Development Concepts
|
||||
|
||||
### 1. **Deployment Models**
|
||||
|
||||
#### Option 1: Pre-built Images (Recommended)
|
||||
|
||||
- **Image**: `runpod/worker-v1-vllm:<version>` (see [GitHub Releases](https://github.com/runpod-workers/worker-vllm/releases))
|
||||
- **Configuration**: Entirely via environment variables
|
||||
- **Model Loading**: Downloads model at runtime from Hugging Face
|
||||
- **Use Case**: Quick deployment, model experimentation
|
||||
|
||||
#### Option 2: Baked Model Images
|
||||
|
||||
- **Build Process**: Model downloaded during Docker build
|
||||
- **Storage**: Model embedded in container image
|
||||
- **Configuration**: Stored in `/local_model_args.json`
|
||||
- **Use Case**: Production deployments, faster cold starts
|
||||
|
||||
### 2. **Request Processing Patterns**
|
||||
|
||||
#### Input Handling:
|
||||
|
||||
```python
|
||||
class JobInput:
|
||||
- llm_input: str | List[Dict] (prompt or messages)
|
||||
- sampling_params: SamplingParams (generation settings)
|
||||
- stream: bool (streaming vs batch response)
|
||||
- openai_route: bool (API compatibility mode)
|
||||
- batch_size configs: Dynamic batching parameters
|
||||
```
|
||||
|
||||
#### Response Streaming:
|
||||
|
||||
- **Batched Streaming**: Tokens grouped into configurable batch sizes
|
||||
- **Dynamic Growth**: `min_batch_size * growth_factor^n` up to `max_batch_size`
|
||||
- **Usage Tracking**: Input/output token counting for billing
|
||||
|
||||
### 3. **Model & Tokenizer Management**
|
||||
|
||||
#### Tokenizer Handling:
|
||||
|
||||
- **Wrapper Pattern**: `TokenizerWrapper` for consistent chat template application
|
||||
- **Special Cases**: Mistral models use vLLM's native tokenizer
|
||||
- **Chat Templates**: Automatic application for message-based inputs
|
||||
|
||||
#### Model Loading:
|
||||
|
||||
- **Multi-GPU Support**: Automatic tensor parallelism detection
|
||||
- **Quantization**: Support for AWQ, GPTQ, BitsAndBytes
|
||||
- **Caching**: Hugging Face cache management
|
||||
|
||||
## Development Patterns & Best Practices
|
||||
|
||||
### 1. **Code Organization**
|
||||
|
||||
#### File Structure:
|
||||
|
||||
```
|
||||
src/
|
||||
├── handler.py # RunPod entry point
|
||||
├── engine.py # Core vLLM engines
|
||||
├── engine_args.py # Configuration management
|
||||
├── utils.py # Request parsing & utilities
|
||||
├── tokenizer.py # Tokenizer wrapper
|
||||
├── constants.py # Default constants
|
||||
└── download_model.py # Model downloading logic
|
||||
```
|
||||
|
||||
#### Separation of Concerns:
|
||||
|
||||
- **Engine Logic**: Isolated in `engine.py` classes
|
||||
- **Configuration**: Centralized in `engine_args.py`
|
||||
- **Request Handling**: Abstracted via `JobInput` class
|
||||
- **Platform Integration**: Contained in `handler.py`
|
||||
|
||||
### 2. **Error Handling & Logging**
|
||||
|
||||
#### Logging Strategy:
|
||||
|
||||
- **Structured Logging**: Consistent format across components
|
||||
- **Performance Tracking**: Timer decorators for critical operations
|
||||
- **Error Context**: Detailed error messages with configuration context
|
||||
|
||||
#### Error Responses:
|
||||
|
||||
- **OpenAI Compatibility**: Standard OpenAI error format
|
||||
- **Graceful Degradation**: Fallback behaviors for edge cases
|
||||
|
||||
### 3. **Environment Variable Conventions**
|
||||
|
||||
#### Naming Patterns:
|
||||
|
||||
- **vLLM Settings**: Match vLLM parameter names (uppercase)
|
||||
- **RunPod Settings**: `MAX_CONCURRENCY`, `DEFAULT_BATCH_SIZE`
|
||||
- **OpenAI Settings**: `OPENAI_` prefix for compatibility settings
|
||||
- **Feature Flags**: `ENABLE_*`, `DISABLE_*` pattern
|
||||
|
||||
#### Type Conventions:
|
||||
|
||||
- **Booleans**: String 'true'/'false' or int 0/1
|
||||
- **Lists**: Comma-separated strings
|
||||
- **Objects**: JSON strings for complex configurations
|
||||
|
||||
### 4. **Docker & Deployment**
|
||||
|
||||
#### Multi-Stage Builds:
|
||||
|
||||
- **Base**: CUDA runtime environment
|
||||
- **Dependencies**: Python packages and vLLM
|
||||
- **Model Download**: Optional model baking stage
|
||||
- **Runtime**: Final application layer
|
||||
|
||||
#### Build Arguments:
|
||||
|
||||
- **MODEL_NAME**: Primary model identifier
|
||||
- **BASE_PATH**: Storage location strategy
|
||||
- **QUANTIZATION**: Optimization settings
|
||||
- **WORKER_CUDA_VERSION**: CUDA compatibility
|
||||
|
||||
#### CI/CD Strategy:
|
||||
|
||||
- **Development Builds**: All non-main branches → `runpod/worker-v1-vllm:dev-<branch-name>`
|
||||
- **Release Builds**: Git tags (numeric) only → `runpod/worker-v1-vllm:<version>`
|
||||
- **Dependency Updates**: Automated runpod package version monitoring
|
||||
|
||||
#### Docker Bake Configuration:
|
||||
|
||||
- **File**: `docker-bake.hcl` (flexible variable-based configuration)
|
||||
- **Variables**: `DOCKERHUB_REPO`, `DOCKERHUB_IMG`, `RELEASE_VERSION`, `HUGGINGFACE_ACCESS_TOKEN`
|
||||
- **Platform**: `linux/amd64` (GPU-optimized)
|
||||
|
||||
## Release & Versioning Strategy
|
||||
|
||||
### 1. **Version Tagging**
|
||||
|
||||
- **Development**: `dev-<branch-name>` (e.g., `dev-feature-new-api`)
|
||||
- **Specific Versions**: `2.7.0`, `2.8.0` (semantic versioning without "v" prefix)
|
||||
- **Version Discovery**: Check [GitHub Releases](https://github.com/runpod-workers/worker-vllm/releases) for available versions
|
||||
|
||||
### 2. **Release Workflow**
|
||||
|
||||
1. **Feature Development**: Work on feature branches → triggers dev builds
|
||||
2. **Main Branch Staging**: Merge features to main → stable codebase (no builds)
|
||||
3. **Version Release**: Create git tag from main branch (e.g., `2.8.0`) → triggers versioned release + GitHub release
|
||||
4. **Docker Hub**: Versioned image pushed with tag
|
||||
|
||||
### 3. **Branch Strategy**
|
||||
|
||||
- **Feature Branches**: `feature/*`, `fix/*`, `feat/*` etc. → Dev builds
|
||||
- **Main Branch**: Stable codebase ready for release (no automatic builds)
|
||||
- **Git Tags**: Must be created from main branch for formal version releases
|
||||
|
||||
### 4. **Deployment Recommendations**
|
||||
|
||||
- **Production**: Use specific version tags (e.g., `2.7.0`) for stability
|
||||
- **Development**: Use `dev-<branch>` for testing specific features
|
||||
- **Version Selection**: Check [GitHub Releases](https://github.com/runpod-workers/worker-vllm/releases) for available versions
|
||||
- **Release Process**: Always tag from main branch: `git checkout main && git tag 2.8.0 && git push origin 2.8.0`
|
||||
|
||||
## Performance & Scaling Considerations
|
||||
|
||||
### 1. **Memory Management**
|
||||
|
||||
- **GPU Utilization**: Default 95% GPU memory utilization
|
||||
- **KV Cache**: Configurable cache types (auto, fp8)
|
||||
- **Swap Space**: CPU offloading for large contexts
|
||||
|
||||
### 2. **Concurrency Patterns**
|
||||
|
||||
- **Max Concurrency**: 30 concurrent requests by default
|
||||
- **vLLM Queuing**: Internal request batching and scheduling
|
||||
- **RunPod Integration**: Concurrency modifier for auto-scaling
|
||||
|
||||
### 3. **Optimization Features**
|
||||
|
||||
- **Prefix Caching**: Automatic caching of common prefixes
|
||||
- **Speculative Decoding**: Draft model acceleration
|
||||
- **Chunked Prefill**: Memory-efficient long context handling
|
||||
|
||||
## Testing & Development
|
||||
|
||||
### 1. **Local Development**
|
||||
|
||||
- **Environment**: Virtual environment with GPU support
|
||||
- **Configuration**: `.env` files for local testing
|
||||
- **Model Testing**: Small models for development (facebook/opt-125m)
|
||||
|
||||
### 2. **Docker Development**
|
||||
|
||||
- **Build Strategy**: `docker-bake.hcl` for consistent builds
|
||||
- **Testing Images**: Separate dev/stable image tags
|
||||
- **Layer Caching**: Optimized for rapid iteration
|
||||
|
||||
### 3. **Configuration Validation**
|
||||
|
||||
- **Argument Matching**: Automatic validation against vLLM parameters
|
||||
- **Environment Validation**: Type checking and default value handling
|
||||
- **Runtime Validation**: Model compatibility checks
|
||||
|
||||
## API Conventions
|
||||
|
||||
### 1. **OpenAI Compatibility**
|
||||
|
||||
- **Endpoint Mapping**: `/openai/v1/chat/completions`, `/openai/v1/models`
|
||||
- **Request Format**: Exact OpenAI request/response schemas
|
||||
- **Authentication**: RunPod API key in Authorization header
|
||||
- **Model Names**: Hugging Face repo names or custom overrides
|
||||
|
||||
### 2. **Native vLLM API**
|
||||
|
||||
- **Input Format**: `prompt` or `messages` with `sampling_params`
|
||||
- **Streaming**: Token-level streaming with configurable batching
|
||||
- **Extensibility**: Support for vLLM-specific features
|
||||
|
||||
## Common Patterns & Utilities
|
||||
|
||||
### 1. **Configuration Loading**
|
||||
|
||||
```python
|
||||
# Standard pattern for new configuration options
|
||||
def get_engine_args():
|
||||
args = DEFAULT_ARGS
|
||||
args.update(os.environ) # Environment override
|
||||
args.update(get_local_args()) # Baked model override
|
||||
return match_vllm_args(args) # Validate against vLLM
|
||||
```
|
||||
|
||||
### 2. **Error Handling**
|
||||
|
||||
```python
|
||||
# Standard error response pattern
|
||||
def create_error_response(message: str, err_type: str = "BadRequestError"):
|
||||
return ErrorResponse(message=message, type=err_type)
|
||||
```
|
||||
|
||||
### 3. **Async Generation**
|
||||
|
||||
```python
|
||||
# Standard streaming pattern
|
||||
async def generate(self, job_input: JobInput):
|
||||
async for batch in self._generate_vllm(...):
|
||||
yield batch # Batch-level yielding for efficiency
|
||||
```
|
||||
|
||||
## Extension Points
|
||||
|
||||
### 1. **New Model Architectures**
|
||||
|
||||
- **Engine Args**: Add new parameters in `engine_args.py`
|
||||
- **Compatibility**: Update vLLM argument mapping
|
||||
- **Validation**: Add architecture-specific validation
|
||||
|
||||
### 2. **New API Features**
|
||||
|
||||
- **Engine Extension**: Extend `vLLMEngine` or `OpenAIvLLMEngine`
|
||||
- **Input Parsing**: Extend `JobInput` class
|
||||
- **Response Format**: Add new response generators
|
||||
|
||||
### 3. **Performance Optimizations**
|
||||
|
||||
- **Batching Strategy**: Modify `BatchSize` class
|
||||
- **Memory Management**: Add new caching strategies
|
||||
- **Hardware Optimization**: GPU-specific optimizations
|
||||
|
||||
## Security & Best Practices
|
||||
|
||||
### 1. **Secret Management**
|
||||
|
||||
- **Build Secrets**: Docker secrets for HF tokens
|
||||
- **Runtime Secrets**: Environment variable injection
|
||||
- **Token Handling**: Secure authentication patterns
|
||||
|
||||
### 2. **Resource Limits**
|
||||
|
||||
- **Memory Bounds**: Configurable GPU memory limits
|
||||
- **Request Limits**: Concurrency and timeout controls
|
||||
- **Model Safety**: Trust remote code flags
|
||||
|
||||
### 3. **Logging Security**
|
||||
|
||||
- **Sanitization**: No secrets in logs
|
||||
- **Request Logging**: Configurable request/response logging
|
||||
- **Performance Monitoring**: Safe metrics collection
|
||||
|
||||
---
|
||||
|
||||
This guide should be consulted whenever working on the worker-vllm codebase to ensure consistency with established patterns and architectural decisions.
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 27 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
+1
-1
@@ -1,4 +1,4 @@
|
||||
DEFAULT_BATCH_SIZE = 50
|
||||
DEFAULT_MAX_CONCURRENCY = 300
|
||||
DEFAULT_MAX_CONCURRENCY = 30
|
||||
DEFAULT_BATCH_SIZE_GROWTH_FACTOR = 3
|
||||
DEFAULT_MIN_BATCH_SIZE = 1
|
||||
+396
-37
@@ -1,37 +1,113 @@
|
||||
import os
|
||||
import logging
|
||||
import json
|
||||
import asyncio
|
||||
import inspect
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
from typing import AsyncGenerator, Optional
|
||||
|
||||
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
|
||||
from vllm.inputs import TextPrompt
|
||||
from vllm.entrypoints.logger import RequestLogger
|
||||
from vllm.entrypoints.anthropic.protocol import AnthropicMessagesRequest, AnthropicMessagesResponse, AnthropicError, AnthropicErrorResponse
|
||||
from vllm.entrypoints.anthropic.serving import AnthropicServingMessages
|
||||
from vllm.entrypoints.openai.chat_completion.protocol import ChatCompletionRequest
|
||||
from vllm.entrypoints.openai.chat_completion.serving import OpenAIServingChat
|
||||
from vllm.entrypoints.openai.completion.protocol import CompletionRequest
|
||||
from vllm.entrypoints.openai.completion.serving import OpenAIServingCompletion
|
||||
from vllm.entrypoints.openai.engine.protocol import ErrorResponse
|
||||
from vllm.entrypoints.openai.models.protocol import BaseModelPath, LoRAModulePath
|
||||
from vllm.entrypoints.openai.models.serving import OpenAIServingModels
|
||||
from vllm.entrypoints.openai.responses.protocol import ResponsesRequest, ResponsesResponse
|
||||
from vllm.entrypoints.openai.responses.serving import OpenAIServingResponses
|
||||
from vllm.entrypoints.serve.render.serving import OpenAIServingRender
|
||||
|
||||
from utils import DummyRequest, JobInput, BatchSize, create_error_response
|
||||
from constants import DEFAULT_MAX_CONCURRENCY, DEFAULT_BATCH_SIZE, DEFAULT_BATCH_SIZE_GROWTH_FACTOR, DEFAULT_MIN_BATCH_SIZE
|
||||
from tokenizer import TokenizerWrapper
|
||||
from constants import DEFAULT_BATCH_SIZE, DEFAULT_BATCH_SIZE_GROWTH_FACTOR, DEFAULT_MAX_CONCURRENCY, DEFAULT_MIN_BATCH_SIZE
|
||||
from engine_args import get_engine_args
|
||||
from tokenizer import TokenizerWrapper
|
||||
from utils import BatchSize, DummyRequest, JobInput, create_error_response
|
||||
|
||||
class vLLMEngine:
|
||||
def __init__(self, engine = None):
|
||||
load_dotenv() # For local development
|
||||
self.engine_args = get_engine_args()
|
||||
logging.info(f"Engine args: {self.engine_args}")
|
||||
|
||||
if engine is None:
|
||||
ea = self.engine_args
|
||||
summary = {
|
||||
"model": ea.model,
|
||||
"dtype": ea.dtype,
|
||||
"quantization": ea.quantization,
|
||||
"max_model_len": ea.max_model_len,
|
||||
"tensor_parallel_size": ea.tensor_parallel_size,
|
||||
"gpu_memory_utilization": ea.gpu_memory_utilization,
|
||||
}
|
||||
if ea.tokenizer and ea.tokenizer != ea.model:
|
||||
summary["tokenizer"] = ea.tokenizer
|
||||
logging.info("Engine config: %s", summary)
|
||||
logging.debug("Full engine args: %s", ea)
|
||||
|
||||
self.llm = self._initialize_llm()
|
||||
|
||||
if self.engine_args.tokenizer_mode != 'mistral':
|
||||
self.tokenizer = TokenizerWrapper(self.engine_args.tokenizer or self.engine_args.model,
|
||||
self.engine_args.tokenizer_revision,
|
||||
self.engine_args.trust_remote_code)
|
||||
self.llm = self._initialize_llm() if engine is None else engine.llm
|
||||
else:
|
||||
self.tokenizer = None
|
||||
else:
|
||||
self.llm = engine.llm
|
||||
self.tokenizer = engine.tokenizer
|
||||
|
||||
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 _get_tokenizer_for_chat_template(self):
|
||||
"""Get tokenizer for chat template application"""
|
||||
if self.tokenizer is not None:
|
||||
return self.tokenizer
|
||||
else:
|
||||
# For mistral models, get tokenizer from vLLM engine
|
||||
# This is a fallback - ideally chat templates should be handled by vLLM directly
|
||||
try:
|
||||
from transformers import AutoTokenizer
|
||||
tokenizer = AutoTokenizer.from_pretrained(
|
||||
self.engine_args.tokenizer or self.engine_args.model,
|
||||
revision=self.engine_args.tokenizer_revision or "main",
|
||||
trust_remote_code=self.engine_args.trust_remote_code
|
||||
)
|
||||
# Create a minimal wrapper
|
||||
class MinimalTokenizerWrapper:
|
||||
def __init__(self, tokenizer):
|
||||
self.tokenizer = tokenizer
|
||||
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):
|
||||
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
|
||||
)
|
||||
|
||||
return MinimalTokenizerWrapper(tokenizer)
|
||||
except Exception as e:
|
||||
logging.error(f"Failed to create fallback tokenizer: {e}")
|
||||
raise e
|
||||
|
||||
def dynamic_batch_size(self, current_batch_size, batch_size_growth_factor):
|
||||
return min(current_batch_size*batch_size_growth_factor, self.default_batch_size)
|
||||
|
||||
@@ -53,8 +129,9 @@ class vLLMEngine:
|
||||
|
||||
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)
|
||||
tokenizer_wrapper = self._get_tokenizer_for_chat_template()
|
||||
llm_input = tokenizer_wrapper.apply_chat_template(llm_input)
|
||||
results_generator = self.llm.generate(TextPrompt(prompt=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}
|
||||
|
||||
@@ -118,49 +195,208 @@ class vLLMEngine:
|
||||
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.served_model_name = os.getenv("OPENAI_SERVED_MODEL_NAME_OVERRIDE") or self.engine_args.served_model_name 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)))
|
||||
self.lora_adapters = self._load_lora_adapters()
|
||||
|
||||
# Always defer OpenAI engine initialization to the first request.
|
||||
# asyncio.run() creates a temporary event loop that gets closed, but async
|
||||
# components (tokenizer pool, serving engines) bind futures to that loop.
|
||||
# When Runpod's serverless handler runs in its own event loop, those futures
|
||||
# are "attached to a different loop" causing RuntimeError.
|
||||
# This affects all configurations, not just LoRA.
|
||||
self._engines_initialized = False
|
||||
if self.lora_adapters:
|
||||
logging.info(f"LoRA mode: {len(self.lora_adapters)} adapter(s) will load on first request")
|
||||
for adapter in self.lora_adapters:
|
||||
logging.info(f" - {adapter.name}: {adapter.path}")
|
||||
else:
|
||||
logging.info("OpenAI engines will initialize on first request")
|
||||
|
||||
# Handle both integer and boolean string values for RAW_OPENAI_OUTPUT
|
||||
raw_output_env = os.getenv("RAW_OPENAI_OUTPUT", "1")
|
||||
if raw_output_env.lower() in ('true', 'false'):
|
||||
self.raw_openai_output = raw_output_env.lower() == 'true'
|
||||
else:
|
||||
self.raw_openai_output = bool(int(raw_output_env))
|
||||
|
||||
def _load_lora_adapters(self):
|
||||
lora_modules_env = os.getenv("LORA_MODULES", "")
|
||||
if not lora_modules_env:
|
||||
return []
|
||||
|
||||
try:
|
||||
parsed = json.loads(lora_modules_env)
|
||||
except json.JSONDecodeError as e:
|
||||
logging.error(
|
||||
"LORA_MODULES could not be parsed as JSON: %s — no LoRA adapters loaded. Value: %r",
|
||||
e, lora_modules_env,
|
||||
)
|
||||
return []
|
||||
|
||||
# Accept a single adapter dict as well as an array
|
||||
if isinstance(parsed, dict):
|
||||
parsed = [parsed]
|
||||
|
||||
if not isinstance(parsed, list):
|
||||
logging.error(
|
||||
"LORA_MODULES must be a JSON array of adapter objects, got %s — no LoRA adapters loaded.",
|
||||
type(parsed).__name__,
|
||||
)
|
||||
return []
|
||||
|
||||
adapters = []
|
||||
for i, adapter in enumerate(parsed):
|
||||
try:
|
||||
adapters.append(LoRAModulePath(**adapter))
|
||||
logging.info("Loaded LoRA adapter config [%d]: %s", i, adapter)
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
"Failed to parse LoRA adapter at index %d: %s. Config: %r",
|
||||
i, e, adapter,
|
||||
)
|
||||
|
||||
if parsed and not adapters:
|
||||
logging.error(
|
||||
"LORA_MODULES specified %d adapter(s) but none could be loaded — "
|
||||
"OpenAI model name lookups for LoRA adapters will fail.",
|
||||
len(parsed),
|
||||
)
|
||||
|
||||
return adapters
|
||||
|
||||
async def _ensure_engines_initialized(self):
|
||||
"""Initialize engines on first request to avoid event loop mismatch.
|
||||
|
||||
In Runpod Serverless, the startup code runs outside the handler's event
|
||||
loop. Deferring initialization to the first request ensures all async
|
||||
components (tokenizer pool, serving engines, LoRA state) are created in
|
||||
the correct event loop context.
|
||||
"""
|
||||
if not self._engines_initialized:
|
||||
logging.info("Initializing OpenAI serving engines...")
|
||||
await self._initialize_engines()
|
||||
self._engines_initialized = True
|
||||
logging.info("OpenAI serving engines initialized successfully")
|
||||
|
||||
async def _initialize_engines(self):
|
||||
self.model_config = await self.llm.get_model_config()
|
||||
self.model_config = self.llm.model_config
|
||||
self.base_model_paths = [
|
||||
BaseModelPath(name=self.engine_args.model, model_path=self.engine_args.model)
|
||||
BaseModelPath(name=self.served_model_name, model_path=self.engine_args.model)
|
||||
]
|
||||
|
||||
self.serving_models = OpenAIServingModels(
|
||||
engine_client=self.llm,
|
||||
base_model_paths=self.base_model_paths,
|
||||
lora_modules=self.lora_adapters,
|
||||
)
|
||||
await self.serving_models.init_static_loras()
|
||||
|
||||
# Get chat template from vLLM tokenizer if available
|
||||
chat_template = None
|
||||
if self.tokenizer and hasattr(self.tokenizer, 'tokenizer'):
|
||||
chat_template = self.tokenizer.tokenizer.chat_template
|
||||
|
||||
self.openai_serving_render = OpenAIServingRender(
|
||||
model_config=self.llm.model_config,
|
||||
renderer=self.llm.renderer,
|
||||
model_registry=self.serving_models.registry,
|
||||
request_logger=None,
|
||||
chat_template=chat_template,
|
||||
chat_template_content_format="auto",
|
||||
trust_request_chat_template=os.getenv('TRUST_REQUEST_CHAT_TEMPLATE', 'false').lower() == 'true',
|
||||
enable_auto_tools=os.getenv('ENABLE_AUTO_TOOL_CHOICE', 'false').lower() == 'true',
|
||||
exclude_tools_when_tool_choice_none=os.getenv('EXCLUDE_TOOLS_WHEN_TOOL_CHOICE_NONE', 'false').lower() == 'true',
|
||||
tool_parser=os.getenv('TOOL_CALL_PARSER', "") or None,
|
||||
reasoning_parser=os.getenv('REASONING_PARSER', "") or None,
|
||||
log_error_stack=os.getenv('LOG_ERROR_STACK', 'false').lower() == 'true',
|
||||
)
|
||||
|
||||
self.chat_engine = OpenAIServingChat(
|
||||
engine_client=self.llm,
|
||||
model_config=self.model_config,
|
||||
base_model_paths=self.base_model_paths,
|
||||
models=self.serving_models,
|
||||
response_role=self.response_role,
|
||||
chat_template=self.tokenizer.tokenizer.chat_template,
|
||||
lora_modules=None,
|
||||
prompt_adapters=None,
|
||||
request_logger=None
|
||||
openai_serving_render=self.openai_serving_render,
|
||||
request_logger=None,
|
||||
chat_template=chat_template,
|
||||
chat_template_content_format="auto",
|
||||
trust_request_chat_template=os.getenv('TRUST_REQUEST_CHAT_TEMPLATE', 'false').lower() == 'true',
|
||||
return_tokens_as_token_ids=os.getenv('RETURN_TOKENS_AS_TOKEN_IDS', 'false').lower() == 'true',
|
||||
reasoning_parser=os.getenv('REASONING_PARSER', "") or "",
|
||||
enable_auto_tools=os.getenv('ENABLE_AUTO_TOOL_CHOICE', 'false').lower() == 'true',
|
||||
exclude_tools_when_tool_choice_none=os.getenv('EXCLUDE_TOOLS_WHEN_TOOL_CHOICE_NONE', 'false').lower() == 'true',
|
||||
tool_parser=os.getenv('TOOL_CALL_PARSER', "") or None,
|
||||
enable_prompt_tokens_details=os.getenv('ENABLE_PROMPT_TOKENS_DETAILS', 'false').lower() == 'true',
|
||||
enable_force_include_usage=os.getenv('ENABLE_FORCE_INCLUDE_USAGE', 'false').lower() == 'true',
|
||||
enable_log_outputs=os.getenv('ENABLE_LOG_OUTPUTS', 'false').lower() == 'true',
|
||||
)
|
||||
self.completion_engine = OpenAIServingCompletion(
|
||||
engine_client=self.llm,
|
||||
model_config=self.model_config,
|
||||
base_model_paths=self.base_model_paths,
|
||||
lora_modules=[],
|
||||
prompt_adapters=None,
|
||||
request_logger=None
|
||||
models=self.serving_models,
|
||||
openai_serving_render=self.openai_serving_render,
|
||||
request_logger=None,
|
||||
return_tokens_as_token_ids=os.getenv('RETURN_TOKENS_AS_TOKEN_IDS', 'false').lower() == 'true',
|
||||
enable_prompt_tokens_details=os.getenv('ENABLE_PROMPT_TOKENS_DETAILS', 'false').lower() == 'true',
|
||||
enable_force_include_usage=os.getenv('ENABLE_FORCE_INCLUDE_USAGE', 'false').lower() == 'true',
|
||||
)
|
||||
self.responses_engine = OpenAIServingResponses(
|
||||
engine_client=self.llm,
|
||||
models=self.serving_models,
|
||||
openai_serving_render=self.openai_serving_render,
|
||||
request_logger=None,
|
||||
chat_template=chat_template,
|
||||
chat_template_content_format="auto",
|
||||
return_tokens_as_token_ids=os.getenv('RETURN_TOKENS_AS_TOKEN_IDS', 'false').lower() == 'true',
|
||||
reasoning_parser=os.getenv('REASONING_PARSER', "") or "",
|
||||
enable_auto_tools=os.getenv('ENABLE_AUTO_TOOL_CHOICE', 'false').lower() == 'true',
|
||||
tool_parser=os.getenv('TOOL_CALL_PARSER', "") or None,
|
||||
tool_server=None,
|
||||
enable_prompt_tokens_details=os.getenv('ENABLE_PROMPT_TOKENS_DETAILS', 'false').lower() == 'true',
|
||||
enable_force_include_usage=os.getenv('ENABLE_FORCE_INCLUDE_USAGE', 'false').lower() == 'true',
|
||||
enable_log_outputs=os.getenv('ENABLE_LOG_OUTPUTS', 'false').lower() == 'true',
|
||||
)
|
||||
self.messages_engine = AnthropicServingMessages(
|
||||
engine_client=self.llm,
|
||||
models=self.serving_models,
|
||||
response_role=self.response_role,
|
||||
openai_serving_render=self.openai_serving_render,
|
||||
request_logger=None,
|
||||
chat_template=chat_template,
|
||||
chat_template_content_format="auto",
|
||||
return_tokens_as_token_ids=os.getenv('RETURN_TOKENS_AS_TOKEN_IDS', 'false').lower() == 'true',
|
||||
reasoning_parser=os.getenv('REASONING_PARSER', "") or "",
|
||||
enable_auto_tools=os.getenv('ENABLE_AUTO_TOOL_CHOICE', 'false').lower() == 'true',
|
||||
tool_parser=os.getenv('TOOL_CALL_PARSER', "") or None,
|
||||
enable_prompt_tokens_details=os.getenv('ENABLE_PROMPT_TOKENS_DETAILS', 'false').lower() == 'true',
|
||||
enable_force_include_usage=os.getenv('ENABLE_FORCE_INCLUDE_USAGE', 'false').lower() == 'true',
|
||||
)
|
||||
|
||||
warmup = getattr(self.chat_engine, 'warmup', None)
|
||||
if callable(warmup):
|
||||
result = warmup()
|
||||
if inspect.isawaitable(result):
|
||||
await result
|
||||
|
||||
async def generate(self, openai_request: JobInput):
|
||||
# Ensure engines are ready (no-op if already initialized at startup)
|
||||
await self._ensure_engines_initialized()
|
||||
|
||||
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
|
||||
elif openai_request.openai_route == "/v1/responses":
|
||||
async for response in self._handle_responses_request(openai_request):
|
||||
yield response
|
||||
elif openai_request.openai_route == "/v1/messages":
|
||||
async for response in self._handle_messages_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()
|
||||
fixed_model = models.data[0]
|
||||
fixed_model.id = self.served_model_name
|
||||
models.data = [fixed_model]
|
||||
models = await self.serving_models.show_available_models()
|
||||
return models.model_dump()
|
||||
|
||||
async def _handle_chat_or_completion_request(self, openai_request: JobInput):
|
||||
@@ -211,3 +447,126 @@ class OpenAIvLLMEngine(vLLMEngine):
|
||||
batch = "".join(batch)
|
||||
yield batch
|
||||
|
||||
async def _handle_responses_request(self, openai_request: JobInput):
|
||||
request_id = getattr(openai_request, "request_id", "unknown")
|
||||
|
||||
try:
|
||||
request = ResponsesRequest(**openai_request.openai_input)
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
"Invalid ResponsesRequest JSON: %s",
|
||||
e,
|
||||
extra={"request_id": request_id}
|
||||
)
|
||||
yield create_error_response(
|
||||
"Invalid request format",
|
||||
err_type="BadRequestError"
|
||||
).model_dump()
|
||||
return
|
||||
|
||||
dummy_request = DummyRequest()
|
||||
try:
|
||||
response = await self.responses_engine.create_responses(request, raw_request=dummy_request)
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
"Failed to create Responses: %s",
|
||||
e,
|
||||
extra={"request_id": request_id},
|
||||
exc_info=True
|
||||
)
|
||||
yield create_error_response(
|
||||
"Internal server error during response generation",
|
||||
err_type="InternalServerError"
|
||||
).model_dump()
|
||||
return
|
||||
|
||||
if isinstance(response, (ErrorResponse, ResponsesResponse)):
|
||||
yield response.model_dump()
|
||||
return
|
||||
|
||||
try:
|
||||
async for event in response:
|
||||
if not hasattr(event, "type"):
|
||||
continue
|
||||
event_type = getattr(event, "type", "unknown")
|
||||
yield f"event: {event_type}\ndata: {event.model_dump_json(indent=None)}\n\n"
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
"Error processing responses stream: %s",
|
||||
e,
|
||||
extra={"request_id": request_id},
|
||||
exc_info=True
|
||||
)
|
||||
error_payload = create_error_response(
|
||||
"Streaming response failed",
|
||||
err_type="InternalServerError"
|
||||
).model_dump_json()
|
||||
yield f"event: error\ndata: {error_payload}\n\n"
|
||||
|
||||
async def _handle_messages_request(self, openai_request: JobInput):
|
||||
request_id = getattr(openai_request, "request_id", "unknown")
|
||||
|
||||
try:
|
||||
request = AnthropicMessagesRequest(**openai_request.openai_input)
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
"Invalid AnthropicMessagesRequest: %s",
|
||||
e,
|
||||
extra={"request_id": request_id}
|
||||
)
|
||||
yield AnthropicErrorResponse(
|
||||
error=AnthropicError(
|
||||
type="invalid_request_error",
|
||||
message="Invalid request format"
|
||||
)
|
||||
).model_dump()
|
||||
return
|
||||
|
||||
dummy_request = DummyRequest()
|
||||
|
||||
try:
|
||||
response = await self.messages_engine.create_messages(request, raw_request=dummy_request)
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
"Failed to create messages: %s",
|
||||
e,
|
||||
extra={"request_id": request_id},
|
||||
exc_info=True
|
||||
)
|
||||
yield AnthropicErrorResponse(
|
||||
error=AnthropicError(
|
||||
type="internal_error",
|
||||
message="Failed to generate messages"
|
||||
)
|
||||
).model_dump()
|
||||
return
|
||||
|
||||
if isinstance(response, ErrorResponse):
|
||||
error_type = getattr(response, "type", "internal_error")
|
||||
error_message = getattr(response, "message", "Unknown error")
|
||||
yield AnthropicErrorResponse(
|
||||
error=AnthropicError(type=error_type, message=error_message)
|
||||
).model_dump()
|
||||
return
|
||||
|
||||
if isinstance(response, AnthropicMessagesResponse):
|
||||
yield response.model_dump(exclude_none=True)
|
||||
return
|
||||
|
||||
try:
|
||||
async for chunk in response:
|
||||
yield chunk
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
"Error streaming messages: %s",
|
||||
e,
|
||||
extra={"request_id": request_id},
|
||||
exc_info=True
|
||||
)
|
||||
error_payload = AnthropicErrorResponse(
|
||||
error=AnthropicError(
|
||||
type="internal_error",
|
||||
message="Error while streaming messages"
|
||||
)
|
||||
).model_dump_json()
|
||||
yield f"event: error\ndata: {error_payload}\n\n"
|
||||
|
||||
+516
-99
@@ -1,111 +1,409 @@
|
||||
import ast
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
from typing import get_origin, get_args
|
||||
from torch.cuda import device_count
|
||||
from vllm import AsyncEngineArgs
|
||||
from vllm.model_executor.model_loader.tensorizer import TensorizerConfig
|
||||
from src.utils import convert_limit_mm_per_prompt
|
||||
|
||||
RENAME_ARGS_MAP = {
|
||||
# Backward-compat: env var names users already know → engine arg name
|
||||
ENV_ALIASES = {
|
||||
"MODEL_NAME": "model",
|
||||
"MODEL_REVISION": "revision",
|
||||
"TOKENIZER_NAME": "tokenizer",
|
||||
"MAX_CONTEXT_LEN_TO_CAPTURE": "max_seq_len_to_capture"
|
||||
}
|
||||
|
||||
# Literal defaults from original worker (used when env/local do not set a value)
|
||||
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)
|
||||
"disable_log_stats": False,
|
||||
"enable_log_requests": False,
|
||||
"gpu_memory_utilization": 0.95,
|
||||
"pipeline_parallel_size": 1,
|
||||
"tensor_parallel_size": 1,
|
||||
"skip_tokenizer_init": False,
|
||||
"tokenizer_mode": "auto",
|
||||
"trust_remote_code": False,
|
||||
"load_format": "auto",
|
||||
"dtype": "auto",
|
||||
"kv_cache_dtype": "auto",
|
||||
"seed": 0,
|
||||
"worker_use_ray": False,
|
||||
"block_size": 16,
|
||||
"enable_prefix_caching": False,
|
||||
"disable_sliding_window": False,
|
||||
"swap_space": 4,
|
||||
"cpu_offload_gb": 0,
|
||||
"max_num_seqs": 256,
|
||||
"max_logprobs": 20,
|
||||
"enforce_eager": False,
|
||||
"max_seq_len_to_capture": 8192,
|
||||
"disable_custom_all_reduce": False,
|
||||
"tokenizer_pool_size": 0,
|
||||
"tokenizer_pool_type": "ray",
|
||||
"enable_lora": False,
|
||||
"max_loras": 1,
|
||||
"max_lora_rank": 16,
|
||||
"enable_prompt_adapter": False,
|
||||
"max_prompt_adapters": 1,
|
||||
"max_prompt_adapter_token": 0,
|
||||
"fully_sharded_loras": False,
|
||||
"lora_extra_vocab_size": 256,
|
||||
"lora_dtype": "auto",
|
||||
"device": "auto",
|
||||
"ray_workers_use_nsight": False,
|
||||
"num_lookahead_slots": 0,
|
||||
"scheduler_delay_factor": 0.0,
|
||||
"guided_decoding_backend": "outlines",
|
||||
"spec_decoding_acceptance_method": "rejection_sampler",
|
||||
"stream_interval": 1,
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
def _resolve_field_type(field_type: type) -> type:
|
||||
"""Resolve Optional/Union to the concrete type for conversion."""
|
||||
origin = get_origin(field_type)
|
||||
args = get_args(field_type) if hasattr(field_type, "__args__") else ()
|
||||
if origin is not None:
|
||||
# Optional[X] is Union[X, None]; X | None is UnionType
|
||||
non_none = [a for a in args if a is not type(None)]
|
||||
if non_none:
|
||||
return non_none[0]
|
||||
return field_type
|
||||
|
||||
Returns:
|
||||
dict: Dictionary of args with renamed keys
|
||||
|
||||
def _convert_env_value_to_field_type(value: str, field_name: str, field_type: type):
|
||||
"""Convert env var string to the type expected by AsyncEngineArgs for this field."""
|
||||
val = value.strip() if isinstance(value, str) else value
|
||||
if val in ("", "None", "none"):
|
||||
args = get_args(field_type) if hasattr(field_type, "__args__") else ()
|
||||
if type(None) in (args or ()):
|
||||
return None
|
||||
raise ValueError("empty value not allowed for non-optional field")
|
||||
|
||||
# Union[bool, str, ...]: only coerce to bool for unambiguous literals;
|
||||
# otherwise preserve the string (e.g. hf_token="hf_abc..." must stay a str).
|
||||
if get_origin(field_type) is not None:
|
||||
union_types = [a for a in (get_args(field_type) or ()) if a is not type(None)]
|
||||
if bool in union_types and str in union_types:
|
||||
if str(val).lower() in ("true", "false", "1", "0", "yes", "no", "on", "off"):
|
||||
return str(val).lower() in ("true", "1", "yes", "on")
|
||||
return str(val)
|
||||
|
||||
effective_type = _resolve_field_type(field_type)
|
||||
# bool
|
||||
if effective_type is bool:
|
||||
return str(val).lower() in ("true", "1", "yes", "on")
|
||||
# int
|
||||
if effective_type is int:
|
||||
return int(val)
|
||||
# float
|
||||
if effective_type is float:
|
||||
return float(val)
|
||||
# str
|
||||
if effective_type is str:
|
||||
return str(val)
|
||||
# dict, list, or complex (try JSON)
|
||||
origin = get_origin(effective_type)
|
||||
if effective_type in (dict, list) or origin in (dict, list):
|
||||
try:
|
||||
return json.loads(val)
|
||||
except json.JSONDecodeError:
|
||||
return val
|
||||
# tuple (e.g. long_lora_scaling_factors) — comma-separated or JSON array
|
||||
if effective_type is tuple or origin is tuple:
|
||||
args = get_args(field_type) if hasattr(field_type, "__args__") else ()
|
||||
elem_types = [a for a in args if a is not Ellipsis]
|
||||
elem_type = elem_types[0] if elem_types else str
|
||||
try:
|
||||
parsed = json.loads(val)
|
||||
if isinstance(parsed, list):
|
||||
return tuple(elem_type(x) for x in parsed)
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
pass
|
||||
return tuple(elem_type(x.strip()) for x in str(val).split(",") if x.strip())
|
||||
# For dataclass/complex types, try JSON then Python literal parsing to dict
|
||||
try:
|
||||
return json.loads(val)
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
pass
|
||||
try:
|
||||
parsed = ast.literal_eval(val)
|
||||
if isinstance(parsed, (dict, list)):
|
||||
return parsed
|
||||
except (ValueError, SyntaxError):
|
||||
pass
|
||||
# Fallback: try int, float, then str
|
||||
try:
|
||||
return int(val)
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
return float(val)
|
||||
except ValueError:
|
||||
pass
|
||||
return str(val)
|
||||
|
||||
|
||||
def _get_args_from_env_auto_discover() -> dict:
|
||||
"""Auto-discover engine args from env vars using UPPERCASED field names.
|
||||
|
||||
For every field in AsyncEngineArgs, check os.getenv(FIELD_NAME).
|
||||
E.g. MAX_MODEL_LEN=4096 -> max_model_len=4096.
|
||||
Uses same type conversion as before; supports all vLLM engine args without manual listing.
|
||||
"""
|
||||
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, ""]}
|
||||
args = {}
|
||||
valid_fields = AsyncEngineArgs.__dataclass_fields__
|
||||
for field_name, field in valid_fields.items():
|
||||
env_key = field_name.upper()
|
||||
value = os.environ.get(env_key)
|
||||
if value is None:
|
||||
continue
|
||||
try:
|
||||
args[field_name] = _convert_env_value_to_field_type(
|
||||
value, field_name, field.type
|
||||
)
|
||||
except (ValueError, TypeError, json.JSONDecodeError) as e:
|
||||
logging.warning(
|
||||
"Skip env %s=%r: %s", env_key, value, e
|
||||
)
|
||||
return args
|
||||
|
||||
|
||||
def _apply_env_aliases(args: dict) -> None:
|
||||
"""Apply ENV_ALIASES: if MODEL_NAME etc. are set, set the target engine arg."""
|
||||
valid_fields = AsyncEngineArgs.__dataclass_fields__
|
||||
for alias, target in ENV_ALIASES.items():
|
||||
value = os.environ.get(alias)
|
||||
if value is None or target not in valid_fields:
|
||||
continue
|
||||
try:
|
||||
args[target] = _convert_env_value_to_field_type(
|
||||
value, target, valid_fields[target].type
|
||||
)
|
||||
except (ValueError, TypeError, json.JSONDecodeError) as e:
|
||||
logging.warning("Skip env alias %s=%r: %s", alias, value, e)
|
||||
|
||||
def get_speculative_config():
|
||||
"""Build speculative decoding configuration from environment variables.
|
||||
|
||||
Supports two modes:
|
||||
1. Full JSON config via SPECULATIVE_CONFIG env var
|
||||
2. Individual env vars for common settings
|
||||
"""
|
||||
# Option 1: Full JSON configuration
|
||||
spec_config_json = os.getenv('SPECULATIVE_CONFIG')
|
||||
if spec_config_json:
|
||||
try:
|
||||
config = json.loads(spec_config_json)
|
||||
logging.info(f"Using speculative config from SPECULATIVE_CONFIG: {config}")
|
||||
return config
|
||||
except json.JSONDecodeError as e:
|
||||
logging.error(f"Failed to parse SPECULATIVE_CONFIG JSON: {e}")
|
||||
return None
|
||||
|
||||
# Option 2: Build config from individual environment variables
|
||||
spec_method = os.getenv('SPECULATIVE_METHOD')
|
||||
spec_model = os.getenv('SPECULATIVE_MODEL')
|
||||
_num_spec_tokens = os.getenv('NUM_SPECULATIVE_TOKENS')
|
||||
_ngram_max = os.getenv('NGRAM_PROMPT_LOOKUP_MAX')
|
||||
_ngram_min = os.getenv('NGRAM_PROMPT_LOOKUP_MIN')
|
||||
|
||||
# Convert numeric vars to int so '0' (hub.json default) is treated as unset
|
||||
num_spec_tokens = (int(_num_spec_tokens) or None) if _num_spec_tokens else None
|
||||
ngram_max = (int(_ngram_max) or None) if _ngram_max else None
|
||||
ngram_min = (int(_ngram_min) or None) if _ngram_min else None
|
||||
|
||||
if not any([spec_method, spec_model, ngram_max]):
|
||||
return None
|
||||
|
||||
config = {}
|
||||
|
||||
# Determine method
|
||||
if spec_method:
|
||||
config['method'] = spec_method
|
||||
elif ngram_max and not spec_model:
|
||||
config['method'] = 'ngram'
|
||||
elif spec_model:
|
||||
model_lower = spec_model.lower()
|
||||
if 'eagle3' in model_lower:
|
||||
config['method'] = 'eagle3'
|
||||
elif 'eagle' in model_lower:
|
||||
config['method'] = 'eagle'
|
||||
elif 'medusa' in model_lower:
|
||||
config['method'] = 'medusa'
|
||||
else:
|
||||
config['method'] = 'draft_model'
|
||||
|
||||
if spec_model:
|
||||
config['model'] = spec_model
|
||||
if num_spec_tokens:
|
||||
config['num_speculative_tokens'] = num_spec_tokens
|
||||
if ngram_max:
|
||||
config['prompt_lookup_max'] = ngram_max
|
||||
if ngram_min:
|
||||
config['prompt_lookup_min'] = ngram_min
|
||||
|
||||
draft_tp = os.getenv('SPECULATIVE_DRAFT_TENSOR_PARALLEL_SIZE')
|
||||
if draft_tp:
|
||||
config['draft_tensor_parallel_size'] = int(draft_tp)
|
||||
|
||||
spec_max_len = os.getenv('SPECULATIVE_MAX_MODEL_LEN')
|
||||
if spec_max_len:
|
||||
config['max_model_len'] = int(spec_max_len)
|
||||
|
||||
disable_batch = os.getenv('SPECULATIVE_DISABLE_BY_BATCH_SIZE')
|
||||
if disable_batch:
|
||||
config['disable_by_batch_size'] = int(disable_batch)
|
||||
|
||||
spec_quant = os.getenv('SPECULATIVE_QUANTIZATION')
|
||||
if spec_quant:
|
||||
config['quantization'] = spec_quant
|
||||
|
||||
spec_revision = os.getenv('SPECULATIVE_MODEL_REVISION')
|
||||
if spec_revision:
|
||||
config['revision'] = spec_revision
|
||||
|
||||
spec_eager = os.getenv('SPECULATIVE_ENFORCE_EAGER')
|
||||
if spec_eager:
|
||||
config['enforce_eager'] = spec_eager.lower() == 'true'
|
||||
|
||||
if config:
|
||||
logging.info(f"Built speculative config from env vars: {config}")
|
||||
return config
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def _resolve_max_model_len(model, trust_remote_code=False, revision=None):
|
||||
"""Resolve max_model_len from the model's HuggingFace config."""
|
||||
try:
|
||||
from transformers import AutoConfig
|
||||
config = AutoConfig.from_pretrained(
|
||||
model,
|
||||
trust_remote_code=trust_remote_code,
|
||||
revision=revision,
|
||||
)
|
||||
for attr in ('max_position_embeddings', 'n_positions', 'max_seq_len', 'seq_length'):
|
||||
val = getattr(config, attr, None)
|
||||
if val is not None:
|
||||
logging.info(f"Resolved max_model_len={val} from model config ({attr})")
|
||||
return val
|
||||
except Exception as e:
|
||||
logging.warning(f"Could not resolve max_model_len from model config: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def _local_args_to_engine_args(local: dict) -> dict:
|
||||
"""Map local args (e.g. from /local_model_args.json) to engine arg names and filter."""
|
||||
valid = AsyncEngineArgs.__dataclass_fields__
|
||||
out = {}
|
||||
for k, v in local.items():
|
||||
target = ENV_ALIASES.get(k, k.lower().replace("-", "_"))
|
||||
if target not in valid or v in (None, "", "None"):
|
||||
continue
|
||||
out[target] = v
|
||||
return out
|
||||
|
||||
|
||||
def _sanitize_hf_overrides(hf_overrides: dict) -> dict | None:
|
||||
"""Strip rope_scaling from hf_overrides sub-configs if vLLM rejects them.
|
||||
|
||||
Older vLLM (<0.7) required explicit mrope rope_scaling in hf_overrides for
|
||||
models like Qwen2-VL. Newer vLLM auto-detects mrope and raises a ValueError
|
||||
in patch_rope_scaling_dict when it finds conflicting rope_type values. Strip
|
||||
the offending rope_scaling so the model loads with its native config.
|
||||
"""
|
||||
if not isinstance(hf_overrides, dict):
|
||||
return hf_overrides
|
||||
|
||||
try:
|
||||
from vllm.transformers_utils.config import patch_rope_scaling_dict
|
||||
except ImportError:
|
||||
return hf_overrides
|
||||
|
||||
import copy
|
||||
cleaned = {}
|
||||
changed = False
|
||||
for key, value in hf_overrides.items():
|
||||
if isinstance(value, dict) and "rope_scaling" in value:
|
||||
rope_scaling = value.get("rope_scaling")
|
||||
if isinstance(rope_scaling, dict):
|
||||
try:
|
||||
patch_rope_scaling_dict(copy.deepcopy(rope_scaling))
|
||||
except (ValueError, Exception) as e:
|
||||
logging.warning(
|
||||
"Stripping hf_overrides['%s']['rope_scaling'] because vLLM "
|
||||
"rejected it (%s). Newer vLLM auto-detects rope scaling from "
|
||||
"the model config.", key, e
|
||||
)
|
||||
stripped = {k: v for k, v in value.items() if k != "rope_scaling"}
|
||||
cleaned[key] = stripped if stripped else None
|
||||
changed = True
|
||||
continue
|
||||
cleaned[key] = value
|
||||
|
||||
if not changed:
|
||||
return hf_overrides
|
||||
|
||||
result = {k: v for k, v in cleaned.items() if v is not None}
|
||||
return result or None
|
||||
|
||||
|
||||
def _resolve_cached_model_path(model_name: str) -> str:
|
||||
"""Return a local snapshot path when the HF cache was stored with lowercase names.
|
||||
|
||||
Some model stores (e.g. RunPod pre-cached volumes) normalize repo IDs to
|
||||
lowercase. HuggingFace Hub stores caches as
|
||||
``models--{org}--{model}/snapshots/{hash}/`` preserving the original casing,
|
||||
so MODEL_NAME=Qwen/Qwen2.5-Coder-32B-Instruct-AWQ will miss a cache stored
|
||||
as ``models--qwen--qwen2.5-coder-32b-instruct-awq/``.
|
||||
|
||||
If the exact-case cache directory is absent but a lowercase variant exists,
|
||||
the latest snapshot path is returned so vLLM loads from disk rather than
|
||||
attempting a redundant download.
|
||||
"""
|
||||
if os.path.isabs(model_name):
|
||||
return model_name
|
||||
|
||||
cache_dir = (
|
||||
os.getenv("HUGGINGFACE_HUB_CACHE")
|
||||
or os.getenv("HF_HOME")
|
||||
or os.path.expanduser("~/.cache/huggingface/hub")
|
||||
)
|
||||
|
||||
folder_name = f"models--{model_name.replace('/', '--')}"
|
||||
|
||||
if os.path.isdir(os.path.join(cache_dir, folder_name)):
|
||||
return model_name
|
||||
|
||||
lower_dir = os.path.join(cache_dir, folder_name.lower())
|
||||
if not os.path.isdir(lower_dir):
|
||||
return model_name
|
||||
|
||||
snapshots_dir = os.path.join(lower_dir, "snapshots")
|
||||
if not os.path.isdir(snapshots_dir):
|
||||
return model_name
|
||||
|
||||
try:
|
||||
snapshots = sorted(os.listdir(snapshots_dir))
|
||||
except OSError:
|
||||
return model_name
|
||||
|
||||
if not snapshots:
|
||||
return model_name
|
||||
|
||||
resolved = os.path.join(snapshots_dir, snapshots[-1])
|
||||
logging.info(
|
||||
"MODEL_NAME %r not found at original casing in HF cache; "
|
||||
"resolved to lowercase cached snapshot at %r",
|
||||
model_name, resolved,
|
||||
)
|
||||
return resolved
|
||||
|
||||
|
||||
def get_local_args():
|
||||
"""
|
||||
Retrieve local arguments from a JSON file.
|
||||
@@ -120,7 +418,7 @@ def get_local_args():
|
||||
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.warning("Model name not found in /local_model_args.json. There maybe was a problem when baking the model in.")
|
||||
|
||||
logging.info(f"Using baked in model with args: {local_args}")
|
||||
os.environ["TRANSFORMERS_OFFLINE"] = "1"
|
||||
@@ -128,23 +426,46 @@ def get_local_args():
|
||||
|
||||
return local_args
|
||||
def get_engine_args():
|
||||
# Start with default args
|
||||
args = DEFAULT_ARGS
|
||||
# Start with worker custom defaults (only where we differ from vLLM)
|
||||
args = dict(DEFAULT_ARGS)
|
||||
|
||||
# Get env args that match keys in AsyncEngineArgs
|
||||
args.update(os.environ)
|
||||
# Auto-discover: every AsyncEngineArgs field from env UPPERCASED (e.g. MAX_MODEL_LEN)
|
||||
args.update(_get_args_from_env_auto_discover())
|
||||
|
||||
# Get local args if model is baked in and overwrite env args
|
||||
args.update(get_local_args())
|
||||
# Backward-compat aliases (MODEL_NAME → model, etc.)
|
||||
_apply_env_aliases(args)
|
||||
|
||||
# Local baked-in model overrides
|
||||
local = get_local_args()
|
||||
if local:
|
||||
args.update(_local_args_to_engine_args(local))
|
||||
|
||||
# Filter to valid engine args and drop sentinel empty values
|
||||
valid_fields = AsyncEngineArgs.__dataclass_fields__
|
||||
args = {
|
||||
k: v for k, v in args.items()
|
||||
if k in valid_fields and v not in (None, "", "None")
|
||||
}
|
||||
|
||||
# Special conversion for limit_mm_per_prompt (e.g. "image=1,video=0")
|
||||
limit_mm_env = os.getenv("LIMIT_MM_PER_PROMPT")
|
||||
if limit_mm_env is not None:
|
||||
args["limit_mm_per_prompt"] = convert_limit_mm_per_prompt(limit_mm_env)
|
||||
|
||||
# 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']}")
|
||||
|
||||
if "hf_overrides" in args:
|
||||
sanitized = _sanitize_hf_overrides(args["hf_overrides"])
|
||||
if sanitized:
|
||||
args["hf_overrides"] = sanitized
|
||||
else:
|
||||
del args["hf_overrides"]
|
||||
|
||||
# Rename and match to vllm args
|
||||
args = match_vllm_args(args)
|
||||
if args.get("load_format") == "bitsandbytes":
|
||||
args["quantization"] = args["load_format"]
|
||||
|
||||
# Set tensor parallel size and max parallel loading workers if more than 1 GPU is available
|
||||
num_gpus = device_count()
|
||||
@@ -154,6 +475,53 @@ def get_engine_args():
|
||||
if os.getenv("MAX_PARALLEL_LOADING_WORKERS"):
|
||||
logging.warning("Overriding MAX_PARALLEL_LOADING_WORKERS with None because more than 1 GPU is available.")
|
||||
|
||||
# LMCache requires HMA to be disabled
|
||||
try:
|
||||
_kv_transfer = args.get("kv_transfer_config")
|
||||
if isinstance(_kv_transfer, str):
|
||||
parsed = None
|
||||
try:
|
||||
parsed = json.loads(_kv_transfer)
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
pass
|
||||
if parsed is None:
|
||||
try:
|
||||
result = ast.literal_eval(_kv_transfer)
|
||||
if isinstance(result, dict):
|
||||
parsed = result
|
||||
except (ValueError, SyntaxError):
|
||||
pass
|
||||
if parsed is not None:
|
||||
_kv_transfer = parsed
|
||||
args["kv_transfer_config"] = _kv_transfer
|
||||
_kv_offload = args.get("kv_offloading_backend")
|
||||
|
||||
lmcache_via_offload = _kv_offload == "lmcache"
|
||||
lmcache_via_transfer = (
|
||||
isinstance(_kv_transfer, dict)
|
||||
and isinstance(_kv_transfer.get("kv_connector"), str)
|
||||
and "lmcache" in _kv_transfer.get("kv_connector", "").lower()
|
||||
)
|
||||
lmcache_detected = lmcache_via_offload or lmcache_via_transfer
|
||||
|
||||
if lmcache_detected:
|
||||
current = args.get("disable_hybrid_kv_cache_manager")
|
||||
if current is False:
|
||||
logging.warning(
|
||||
"disable_hybrid_kv_cache_manager=False conflicts with LMCache; "
|
||||
"overriding to True (HMA must be disabled when using LMCache)"
|
||||
)
|
||||
args["disable_hybrid_kv_cache_manager"] = True
|
||||
elif current is None:
|
||||
args["disable_hybrid_kv_cache_manager"] = True
|
||||
logging.info("LMCache detected: automatically setting disable_hybrid_kv_cache_manager=True")
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
"Failed to check LMCache configuration: %s",
|
||||
e,
|
||||
exc_info=True
|
||||
)
|
||||
|
||||
# Deprecated env args backwards compatibility
|
||||
if args.get("kv_cache_dtype") == "fp8_e5m2":
|
||||
args["kv_cache_dtype"] = "fp8"
|
||||
@@ -166,4 +534,53 @@ def get_engine_args():
|
||||
# os.environ["VLLM_ATTENTION_BACKEND"] = "FLASHINFER"
|
||||
# logging.info("Using FLASHINFER for gemma-2 model.")
|
||||
|
||||
# Set max_num_batched_tokens to max_model_len for unlimited batching.
|
||||
# vLLM defaults max_num_batched_tokens to 2048 when None, which is too low.
|
||||
|
||||
if args.get("max_model_len") == 0:
|
||||
args["max_model_len"] = None
|
||||
|
||||
if args.get("max_num_batched_tokens") == 0:
|
||||
args["max_num_batched_tokens"] = None
|
||||
|
||||
if args.get("max_num_batched_tokens") is None:
|
||||
max_model_len = args.get("max_model_len")
|
||||
if max_model_len is None:
|
||||
max_model_len = _resolve_max_model_len(
|
||||
args.get("model"),
|
||||
trust_remote_code=args.get("trust_remote_code", False),
|
||||
revision=args.get("revision"),
|
||||
)
|
||||
if max_model_len is not None:
|
||||
args["max_num_batched_tokens"] = max_model_len
|
||||
logging.info(f"Setting max_num_batched_tokens to {max_model_len}")
|
||||
|
||||
# VLLM_ATTENTION_BACKEND is deprecated, migrate to attention_backend
|
||||
if os.getenv('VLLM_ATTENTION_BACKEND'):
|
||||
logging.warning(
|
||||
"VLLM_ATTENTION_BACKEND env var is deprecated. "
|
||||
"Use ATTENTION_BACKEND instead (maps to --attention-backend CLI arg)."
|
||||
)
|
||||
if not args.get('attention_backend'):
|
||||
args['attention_backend'] = os.getenv('VLLM_ATTENTION_BACKEND')
|
||||
|
||||
# DISABLE_LOG_REQUESTS is deprecated, use ENABLE_LOG_REQUESTS instead
|
||||
if os.getenv('DISABLE_LOG_REQUESTS'):
|
||||
logging.warning(
|
||||
"DISABLE_LOG_REQUESTS env var is deprecated. "
|
||||
"Use ENABLE_LOG_REQUESTS instead (default: False)."
|
||||
)
|
||||
# Honor old behavior: if DISABLE_LOG_REQUESTS=true, don't enable logging
|
||||
if os.getenv('DISABLE_LOG_REQUESTS', 'False').lower() == 'true':
|
||||
args['enable_log_requests'] = False
|
||||
|
||||
# Add speculative decoding configuration if present
|
||||
speculative_config = get_speculative_config()
|
||||
if speculative_config:
|
||||
args["speculative_config"] = speculative_config
|
||||
|
||||
# Resolve lowercase HF cache paths (FDE-174)
|
||||
if args.get("model"):
|
||||
args["model"] = _resolve_cached_model_path(args["model"])
|
||||
|
||||
return AsyncEngineArgs(**args)
|
||||
|
||||
+42
-9
@@ -1,22 +1,55 @@
|
||||
import os
|
||||
import sys
|
||||
import multiprocessing
|
||||
import traceback
|
||||
import runpod
|
||||
from utils import JobInput
|
||||
from engine import vLLMEngine, OpenAIvLLMEngine
|
||||
from runpod import RunPodLogger
|
||||
|
||||
log = RunPodLogger()
|
||||
|
||||
vllm_engine = None
|
||||
openai_engine = None
|
||||
|
||||
vllm_engine = vLLMEngine()
|
||||
OpenAIvLLMEngine = OpenAIvLLMEngine(vllm_engine)
|
||||
|
||||
async def handler(job):
|
||||
try:
|
||||
from utils import JobInput
|
||||
job_input = JobInput(job["input"])
|
||||
engine = OpenAIvLLMEngine if job_input.openai_route else vllm_engine
|
||||
engine = openai_engine if job_input.openai_route else vllm_engine
|
||||
results_generator = engine.generate(job_input)
|
||||
async for batch in results_generator:
|
||||
yield batch
|
||||
except Exception as e:
|
||||
error_str = str(e)
|
||||
full_traceback = traceback.format_exc()
|
||||
|
||||
runpod.serverless.start(
|
||||
log.error(f"Error during inference: {error_str}")
|
||||
log.error(f"Full traceback:\n{full_traceback}")
|
||||
|
||||
# CUDA errors = worker is broken, exit to let RunPod spin up a healthy one
|
||||
if "CUDA" in error_str or "cuda" in error_str:
|
||||
log.error("Terminating worker due to CUDA/GPU error")
|
||||
sys.exit(1)
|
||||
|
||||
yield {"error": error_str}
|
||||
|
||||
|
||||
# Only run in main process to prevent re-initialization when vLLM spawns worker subprocesses
|
||||
if __name__ == "__main__" or multiprocessing.current_process().name == "MainProcess":
|
||||
|
||||
try:
|
||||
from engine import vLLMEngine, OpenAIvLLMEngine
|
||||
|
||||
vllm_engine = vLLMEngine()
|
||||
openai_engine = OpenAIvLLMEngine(vllm_engine)
|
||||
log.info("vLLM engines initialized successfully")
|
||||
except Exception as e:
|
||||
log.error(f"Worker startup failed: {e}\n{traceback.format_exc()}")
|
||||
sys.exit(1)
|
||||
|
||||
runpod.serverless.start(
|
||||
{
|
||||
"handler": handler,
|
||||
"concurrency_modifier": lambda x: vllm_engine.max_concurrency,
|
||||
"concurrency_modifier": lambda x: vllm_engine.max_concurrency if vllm_engine else 1,
|
||||
"return_aggregate_stream": True,
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [ -n "${TRANSFORMERS_VERSION}" ]; then
|
||||
echo "Installing transformers==${TRANSFORMERS_VERSION}"
|
||||
uv pip install --system "transformers==${TRANSFORMERS_VERSION}"
|
||||
fi
|
||||
|
||||
exec python3 /src/handler.py
|
||||
+4
-2
@@ -1,10 +1,12 @@
|
||||
from transformers import AutoTokenizer
|
||||
import logging
|
||||
import os
|
||||
from typing import Union
|
||||
|
||||
from transformers import AutoTokenizer
|
||||
|
||||
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}")
|
||||
logging.debug("tokenizer_name_or_path: %s, tokenizer_revision: %s, trust_remote_code: %s", tokenizer_name_or_path, tokenizer_revision, 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)
|
||||
|
||||
+17
-5
@@ -3,11 +3,10 @@ import logging
|
||||
from http import HTTPStatus
|
||||
from functools import wraps
|
||||
from time import time
|
||||
from vllm.entrypoints.openai.protocol import RequestResponseMetadata
|
||||
|
||||
try:
|
||||
from vllm.utils import random_uuid
|
||||
from vllm.entrypoints.openai.protocol import ErrorResponse
|
||||
from vllm.entrypoints.openai.engine.protocol import ErrorResponse, ErrorInfo, RequestResponseMetadata
|
||||
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")
|
||||
@@ -15,6 +14,15 @@ except ImportError:
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
# Updated to parse multiple comma-separated multimodal limits (e.g., 'image=1,video=0')
|
||||
def convert_limit_mm_per_prompt(input_string: str):
|
||||
result = {}
|
||||
pairs = input_string.split(',')
|
||||
for pair in pairs:
|
||||
key, value = pair.split('=')
|
||||
result[key] = int(value)
|
||||
return result
|
||||
|
||||
def count_physical_cores():
|
||||
with open('/proc/cpuinfo') as f:
|
||||
content = f.readlines()
|
||||
@@ -40,7 +48,11 @@ class JobInput:
|
||||
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", {}))
|
||||
samp_param = job.get("sampling_params", {})
|
||||
if "max_tokens" not in samp_param:
|
||||
samp_param["max_tokens"] = 100
|
||||
self.sampling_params = SamplingParams(**samp_param)
|
||||
# self.sampling_params = SamplingParams(max_tokens=100, **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
|
||||
@@ -75,9 +87,9 @@ class BatchSize:
|
||||
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,
|
||||
return ErrorResponse(error=ErrorInfo(message=message,
|
||||
type=err_type,
|
||||
code=status_code.value)
|
||||
code=status_code.value))
|
||||
|
||||
def get_int_bool_env(env_var: str, default: bool) -> bool:
|
||||
return int(os.getenv(env_var, int(default))) == 1
|
||||
|
||||
Submodule vllm-base-image/vllm deleted from 6a1a31c41e
@@ -1,936 +0,0 @@
|
||||
{
|
||||
"versions": {
|
||||
"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"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"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", "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