Skip to content

feat(ray-cluster): add an inference variant that serves a model with vLLM - #245

Merged
taylorburmeister-runpod merged 24 commits into
developfrom
ray-cluster-inference
Nov 20, 2026
Merged

taylorburmeister-runpod merged 24 commits into
developfrom
ray-cluster-inference

Conversation

@taylorburmeister-runpod

@taylorburmeister-runpod taylorburmeister-runpod commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the inference variant described in runpod/docs#977. It's the Ray cluster image plus vLLM 0.32.0 behind LiteLLM's proxy, and it serves one Hugging Face model across the whole cluster, configured with environment variables only.

Published as runpod/ray-cluster:<version>-inference-cu1300-torch2130-ubuntu2404.

Behaviour

  • Head: waits until NUM_NODES nodes have joined Ray, then runs vllm serve $MODEL_REPO on 127.0.0.1:8000, with tensor parallelism set to the GPUs per node and pipeline parallelism set to the node count. LiteLLM's proxy serves the API on 4000 (LiteLLM's default) in front of it.
  • Workers: run Ray only.
  • Plain pod (no NODE_RANK): the same on its own GPUs, without Ray.
  • While loading: LiteLLM starts only once vLLM answers /health. Until then nothing listens on 4000, and the Runpod proxy returns 502. If vLLM exits first, LiteLLM isn't started.
  • The pod stays up with SSH, Jupyter and monitoring if vLLM or LiteLLM isn't started or exits.
Variable Default Effect
MODEL_REPO none Model to serve, and the model name clients send. Unset: vLLM is skipped.
HF_TOKEN none For gated or private models.
LITELLM_MASTER_KEY head's JUPYTER_PASSWORD Bearer token for every route except LiteLLM's health checks. With neither set, nothing starts. none turns auth off.
MAX_MODEL_LENGTH vLLM's --max-model-len
VLLM_EXTRA_ARGS none Appended to vllm serve; can override the parallelism. --api-key is refused.

Changes

  • LiteLLM on 4000 (inference/litellm/, inference/start.sh):
    • LiteLLM 1.108.11 (the LTS line) in its own venv at /opt/litellm, installed --require-hashes from a committed lock file. LiteLLM 1.82.7 and 1.82.8 were removed from PyPI earlier this year (consistent with a compromised release), so the pin is exact and every dependency's hash is checked.
    • It runs with a master key and no database. The admin UI is off, and LiteLLM uses its bundled model price map instead of fetching one.
    • prisma is installed even though there's no database, because LiteLLM's error handler imports it. Without it, a request with no key gets a 500 instead of a 401.
    • The master key can be any string except a publicly known default such as sk-1234, which LiteLLM refuses to start with.
  • Depends on fix: remove the unused nginx 8001 proxy to localhost:8000 #248 for port 8001: the base image's nginx relays 8001 to localhost:8000 with no auth, and here that's vLLM. fix: remove the unused nginx 8001 proxy to localhost:8000 #248 removes that relay from the base. Merge fix: remove the unused nginx 8001 proxy to localhost:8000 #248 first, so no published inference image carries it.
  • Image:
    • Built FROM the cu1300-torch2130 Ray target in the same bake run. vLLM pins torch exactly, and 0.32.0 is its last release on torch 2.13.
    • The build fails if installing vLLM would replace torch or Ray.
    • PyJWT is installed beside Debian's copy, which pip can't uninstall.
  • Metrics (inference/post_start.sh, inference/config/):
    • The head's Prometheus scrapes vLLM at 127.0.0.1:8000, with no key.
    • It scrapes LiteLLM's /metrics, which requires the key, by sending the key from a root-only file.
    • LiteLLM's hashed_api_key label is excluded, because it records a rejected key in plain text.
    • vLLM's three dashboards and LiteLLM's "Prod v2" dashboard appear in an Inference folder in Grafana.
  • Node wait (inference/wait_for_nodes.py): waits for NUM_NODES nodes and checks they all have the same nonzero GPU count.

Testing

On a GPU cluster (2 nodes × 2 GPUs, MODEL_REPO=Qwen/Qwen3-0.6B):

  • The head waited for both nodes, then started vLLM with --pipeline-parallel-size 2 --tensor-parallel-size 2 on the Ray executor.
  • Chat completions through LiteLLM on 4000 with the master key work, including tool calling with VLLM_EXTRA_ARGS=--enable-auto-tool-choice --tool-call-parser hermes.
  • That run predates the readiness gate below. During the load, requests got LiteLLM's 500 "Cannot connect to host 127.0.0.1:8000", the behaviour the gate replaces.

Local, with a stand-in OpenAI server on 127.0.0.1:8000 in place of vLLM (LiteLLM on 4000):

Case Result
Valid key (JUPYTER_PASSWORD fallback, a non-sk- value with $ and ") Chat completions proxied, 200
No key 401
Wrong key 400 No connected db. (refused)
/metrics without the key 401
/health/liveliness 200
vLLM still loading (stand-in up after 20 s) Nothing on 4000; LiteLLM starts when /health answers, then 200
vLLM exits before ready LiteLLM not started; the log says why
LITELLM_MASTER_KEY (whitespace trimmed) set alongside JUPYTER_PASSWORD Takes priority
none Open
Head's Prometheus vllm and litellm targets up; LiteLLM request counts queryable; no raw key in the labels
Grafana All four dashboards in the Inference folder

Not yet tested: the readiness gate with a real vLLM. CI's smoke test starts the image without MODEL_REPO, so it doesn't start either service.

Notes

🤖 Generated with Claude Code

murat-runpod
murat-runpod previously approved these changes Nov 18, 2026
…vLLM

runpod/ray-cluster:<version>-inference-cu1300-torch2130-ubuntu2404 is the Ray
cluster image plus vLLM 0.32.0, configured only with environment variables.
The head waits for NUM_NODES nodes to join Ray, then runs `vllm serve
$MODEL_REPO` on 8000 across the cluster (tensor parallelism = GPUs per node,
pipeline parallelism = node count); workers only run Ray. Every route except
/health, /ping and /metrics needs VLLM_API_KEY, else the head's
JUPYTER_PASSWORD, enforced by the runpod_vllm_auth middleware.

Built FROM the cu1300/torch2130 Ray target of the same bake run, since vLLM
pins torch exactly; the build fails if vLLM would replace torch or Ray, or
stops loading --middleware.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r on 8001

vLLM now listens on 127.0.0.1:8000 only, and the base image's nginx serves
the API on 8001, checking the key before proxying. Every route except
/health and /ping needs it, including /metrics and any route a future vLLM
adds, and auth no longer depends on vLLM's --middleware hook, so the
runpod_vllm_auth copy is gone. While vLLM isn't listening, 8001 answers 503.

The start script writes the accepted header to a root-only nginx map and
reloads nginx; the shipped map accepts nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he head

The inference variant's /post_start.sh runs the Ray image's hook, then adds a
Prometheus `vllm` job for 127.0.0.1:8000/metrics (no key needed: only
nginx's 8001 is reachable from outside). vLLM's example Grafana dashboards,
vendored from vllm-project/vllm v0.32.0, load into a vLLM folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pod without MODEL_REPO is an interactive pod, not a failure, and the GPU
smoke test's log scan fails any boot that logs "error". Worded like
start.sh's "JUPYTER_PASSWORD is not set; skipping JupyterLab" instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LiteLLM's proxy (1.108.11, the LTS line) now serves the API on 8001 in front
of vLLM, which stays on 127.0.0.1:8000. It runs in its own venv from a
hash-locked requirements file. The master key is LITELLM_MASTER_KEY, else the
head's JUPYTER_PASSWORD; LITELLM_MASTER_KEY=none turns auth off. No database
and no admin UI.

The nginx front door is gone. The image also removes the base nginx's 8001
server, which proxied to localhost:8000 with no auth and would have exposed
vLLM (and held the port LiteLLM needs); the build fails if anything in nginx
still listens on 8001.

The head's Prometheus scrapes LiteLLM's /metrics with the master key from a
root-only file, besides vLLM's, with the raw-key `hashed_api_key` label
excluded. LiteLLM's "Prod v2" dashboard joins vLLM's in an Inference folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… 4000

8001 was kept from the earlier nginx front door. 4000 is where LiteLLM's
docs and users expect it, and it doesn't share a port with the base nginx's
8001 slot. That block (proxying to localhost:8000 without auth) is still
removed, since 8000 is vLLM here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#248 removes the base's unused 8001 -> localhost:8000 block. The inference
image builds on published Ray images, which keep it until that's released,
so its removal step now accepts either state; the guard that nothing in
nginx listens on 8001 is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#248 removes the base's unused 8001 -> localhost:8000 relay for every image,
so the inference image no longer strips it itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LiteLLM used to start alongside vLLM, so every request during the model load
(a minute or more on a multi-node cluster) got a 500 and a logged traceback.
It now waits for vLLM's /health: until then nothing listens on 4000 and the
Runpod proxy answers 502. If vLLM exits first, LiteLLM is not started.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ometheus

The vendored vLLM and LiteLLM dashboards kept the variable values their
authors exported: a datasource uid from their Grafana (three of the four) and
a model name from their deployment (vLLM, Performance Statistics), so their
panels queried a datasource or a model that isn't here and showed nothing.
DS_PROMETHEUS now selects uid prometheus, and the query variables start
empty or All and refresh on load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It was only in hadolint-push.yml, which runs on pushes to main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ode wait

- Check VLLM_EXTRA_ARGS and MAX_MODEL_LENGTH before waiting for the
  cluster, which has no deadline, so a bad setting is reported at once.
- Refuse --api_key as well as --api-key: vLLM reads both the same way.
- Split VLLM_EXTRA_ARGS like a shell command line (shlex), so a quoted
  JSON value with spaces stays one argument; nothing is expanded.
- Refuse a MODEL_REPO starting with '-', which vllm serve would take
  as an option.
- Time out each vLLM /health probe after 5s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As requirements.txt does for Ray: vLLM's unpinned or ranged direct
requirements, resolved with the base's torch and Ray, minus those a
lower layer already pins at a version vLLM accepts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…inputs

- Add the vllm and litellm Prometheus jobs only with a MODEL_REPO;
  without one they are only ever down.
- Put ray-cluster-inference in the CUDA group of INFERENCE_BASE rather
  than a hard-coded cu1300.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs start.sh whole with fakes for nvidia-smi, vllm, curl and LiteLLM:
every refusal starts nothing and hands off to /start.sh, and every
acceptance checks the exact vllm command line, the key LiteLLM gets,
the key file's permissions and the LiteLLM config. wait_for_nodes.py's
shape check moves into shape_error() and is tested with a fake ray.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ev repo

The inference tag lacked ${REPO_SUFFIX}, so develop/PR builds targeted the
public runpod/ray-cluster repo and the push failed with 401.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Verdict: ready to merge. Merge #248 first, as the description says. The image already strips the 8001 → 8000 relay itself and fails the build if one is left, so this ordering is now belt-and-braces rather than required.

Findings: none open. This push adds no new findings.

Fixed since last review

  • inference/Dockerfile:63: the 8001 → localhost:8000 nginx relay no longer depends on fix: remove the unused nginx 8001 proxy to localhost:8000 #248. The Dockerfile strips it and fails the build if nginx still proxies to 8000. I checked the perl regex against the current container-template/proxy/nginx.conf: it removes exactly the 8001 block.
  • README.md: weights are now documented as going to the /workspace volume (HF_HOME), and the README says to size the volume, not the container disk.
  • inference/start.sh: the node wait, the download, vLLM and LiteLLM now run in the background beside /start.sh, so SSH, Jupyter and monitoring come up while workers join.
  • inference/download_model.py: when the Hub can't be reached, it serves the cached snapshot, but only one marked complete (.runpod-complete) for the same load format. A partial snapshot is refused. Only Hub-unreachable errors are caught; any other failure is reported.
  • inference/start.sh:110-136: --load-format, --revision and --download-dir are passed to the pre-download.
  • inference/start.sh:216: LiteLLM uses --served-model-name when one is given.
  • inference/start.sh:129: --config is refused, so a YAML file can't set options the script doesn't see (raised before, outdated).
  • .github/workflows/harness-tests.yml: download_model.py and post_start.sh are now in both path lists.

Risk to current users: low.

  • The existing runpod/ray-cluster tags (cu1281/1290/1300/1320) are rebuilt and get the minor bump, but their content is unchanged: the PR only adds the -inference target and does not touch the non-inference Dockerfile or scripts.
  • The -inference-cu1300-torch2130-ubuntu2404 tag is new, so no existing /workspace state or setup depends on it.
  • When it ships, it needs:
    • a new console template that maps 4000 and sets MODEL_REPO, plus LITELLM_MASTER_KEY or JUPYTER_PASSWORD;
    • the Create documentation for Ray Clusters docs#977 updates listed in the description: port 4000, LITELLM_MASTER_KEY, 502 while loading, pod logs, the tag.

Release: this rebuilds the ray-cluster family only (depends_on: [pytorch-cluster]; nothing builds FROM it). The feat: title gives a minor bump, which is correct for a new variant.

Test on a live pod: CI starts the image without MODEL_REPO, so neither vLLM nor LiteLLM runs there. On a 2-node cluster with runpod/ray-cluster:<rc>-inference-cu1300-torch2130-ubuntu2404 and MODEL_REPO=Qwen/Qwen3-0.6B, check:

  1. While the model loads, nothing listens on 4000 (502). After vLLM is ready; starting LiteLLM on 4000, /v1/chat/completions returns 200 with the key and 401 without it. The description says this readiness gate hasn't been tested with a real vLLM.
  2. The head's Prometheus shows the vllm and litellm targets up, and the Grafana "Inference" folder has data.
  3. A pod restart with the model already cached and HF_HUB_OFFLINE=1 still serves the model.

…e image

The base nginx relays 8001 to localhost:8000, which in the inference variant
is vLLM without LiteLLM's key. #248 removes it from the base, but this image
builds FROM a published pytorch-cluster that may still carry it. Strip the
block here and fail the build if nginx still proxies to 8000, so the merge
order of the two PRs doesn't matter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The base puts HF_HOME on /workspace, so the weights land on the volume, not
the container disk as the README said, and with one network volume shared by
every node all vLLM workers downloaded the same repo into the same cache at
once (huggingface_hub's file locks don't hold across hosts).

The head now downloads the model first, in the background vLLM job so SSH
and Jupyter come up meanwhile; workers then find a complete cache. Only what
vLLM loads is fetched: the first weight format present, the index's
safetensors when there is one, never original/. --revision and
--download-dir in VLLM_EXTRA_ARGS apply to it, and a local directory is
served as is. The README now sizes the volume, not the container disk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread .github/workflows/harness-tests.yml Resolved
…LLM reads

The head ran wait_for_nodes.py in the foreground, so SSH, Jupyter and
monitoring stayed down until every worker joined, forever if one never did.
The wait now runs in the background job, after the download, so workers join
while the model downloads.

The pre-download now picks exactly the weight files vLLM 0.32.0 downloads.
Under --load-format auto, vLLM serves a repo with a consolidated*.safetensors
(Mistral's) in Mistral's format, so the shards it fetched were never read and
every node still downloaded the consolidated copy at once. --load-format is
passed on, and formats served by other loaders (gguf, ...) leave the weights
to vLLM. When the Hub can't be reached, a snapshot already in the cache is
served instead of refusing to start vLLM.

The harness unit tests now also run when download_model.py changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…able

download_model.py fell back to the cached snapshot on any failure, and
snapshot_download(local_files_only=True) accepts one only partly
downloaded: the index fetched first creates it. On a full volume (ENOSPC or
EDQUOT) the head then logged "serving the snapshot already in the cache" and
started vLLM, whose workers downloaded the missing shards at once; a refused
HF_TOKEN or a download cut short on an earlier boot did the same.

The fallback now covers only an unreachable Hub (offline mode, an httpx2
transport error, or a file not cached because of either), and only a
snapshot whose download completed here for the same load format, marked by
.runpod-complete. Any other failure stops vLLM with the start script's
message about HF_TOKEN and free space.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LiteLLM's one model was always MODEL_REPO, so a --served-model-name in
VLLM_EXTRA_ARGS broke every request: vLLM answered 404 for MODEL_REPO, and
LiteLLM refused the served name, having no deployment by it.

The start script now reads --served-model-name with the other flags it
reads from VLLM_EXTRA_ARGS (the last one given wins, as in vLLM) and names
LiteLLM's model, and the hosted_vllm/ model it forwards to, after its first
name, the one vLLM answers with. Without one, it is MODEL_REPO as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vLLM's argparse keeps allow_abbrev, so it takes any unambiguous prefix of
an option, but the start script matched VLLM_EXTRA_ARGS by exact name.
--api-k got past the --api-key refusal (vLLM then demanded a key LiteLLM
never sends, and logged it), --served-model left LiteLLM's model under the
wrong name, and --revis, --download-d or --load-f sent the pre-download
somewhere other than what vLLM reads.

The script now maps a prefix of --api-key, --revision, --download-dir,
--load-format or --served-model-name to that option, after turning
underscores into dashes, as vLLM does. An ambiguous prefix fails vLLM
anyway, so reading it as one of these is harmless.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the settings

post_start.sh added the vllm and litellm scrape jobs whenever MODEL_REPO
was set, so a head that refused its settings (no key, --api-key, a bad
NUM_NODES, no GPU) left Prometheus two targets that never came up, the
litellm one with a credentials_file that didn't exist.

The start script now writes the master key only once those checks pass,
and first removes one left from an earlier boot; post_start.sh adds the
jobs only when the key is there.

Also pins httpx2, which download_model.py imports, at the version that
resolves with vLLM, torch and Ray, and passes check=False and re.MULTILINE
in the tests, for Ruff.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vLLM's --config reads options from a YAML file, so it could set --api-key,
--served-model-name, --revision, --download-dir or --load-format where the
start script never sees them: the refusal of --api-key and the names and
paths the script reads from VLLM_EXTRA_ARGS would no longer hold.

The script now refuses --config (and its abbreviations, such as --conf),
asking for its options in VLLM_EXTRA_ARGS instead. --config-format, a
different option, still passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@taylorburmeister-runpod
taylorburmeister-runpod merged commit 70b2d93 into develop Nov 20, 2026
48 checks passed
@taylorburmeister-runpod
taylorburmeister-runpod deleted the ray-cluster-inference branch November 20, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants