diff --git a/content/patterns/vllm-ray-inference-server/_index.adoc b/content/patterns/vllm-ray-inference-server/_index.adoc new file mode 100644 index 000000000..4b12b2b89 --- /dev/null +++ b/content/patterns/vllm-ray-inference-server/_index.adoc @@ -0,0 +1,174 @@ +--- +title: vLLM Ray Inference Server +date: 2026-11-08 +tier: sandbox +summary: This pattern deploys a large language model (LLM) server on OpenShift and a notebook that benchmarks it on your own GPU, the same way every time, so that you can size GPUs and judge an upgrade from your own measurements. An optional comparison tells real speed changes from run-to-run noise. +rh_products: + - Red Hat OpenShift Container Platform + - Red Hat OpenShift GitOps +partners: + - Eugo +industries: + - General +focus_areas: + - AI +aliases: /vllm-ray-inference-server/ +links: + github: https://github.com/eugo-inc/vllm-ray-inference-server + install: getting-started + arch: /images/vllm-ray-inference-server/architecture.svg + bugs: https://github.com/eugo-inc/vllm-ray-inference-server/issues + feedback: https://docs.google.com/forms/d/e/1FAIpQLScI76b6tD1WyPu2-d_9CCVDr3Fu5jYERthqLKJDUGwqBg7Vcg/viewform +--- +:toc: +:imagesdir: /images +:_content-type: ASSEMBLY +include::modules/comm-attributes.adoc[] +:vllm-ray-pattern: vLLM Ray Inference Server pattern + +[id="about-vllm-ray-inference-server-pattern"] += About the {vllm-ray-pattern} + +The {vllm-ray-pattern} answers one question: is your LLM server fast enough, and does a change make it faster or slower, measured on your own GPU in a way that you can trust? It helps you decide how many GPUs to buy, and whether a new release or setting is faster, from your own measurements instead of someone else's benchmark. The pattern deploys a private large language model (LLM) server on {rh-ocp}, and a notebook that measures it. The notebook reports two measures for one GPU, at 1, 8, and 32 concurrent requests, which are requests that the server serves at the same time: + +* Throughput: the tokens per second that the server produces. A token is a word or a piece of a word. +* Time to first token: how long a user waits for the start of an answer. + +Compared with the load that you expect, these give a starting estimate of how many GPUs you need. For this estimate, serve the model that you plan to use, as link:/patterns/vllm-ray-inference-server/ideas-for-customization/#changing-the-model-vllm-ray[Serving a different model] describes, because the default model is a small one. + +On {AWS}, you can measure on a cloud GPU instance before you buy GPUs; by default, the pattern creates one with an NVIDIA L4 GPU. The server is OpenAI-compatible: it uses the request format of the OpenAI API, so clients written for that API work with it. Eugo maintains the pattern as community content in the {sandbox-tier-first}. + +[WARNING] +==== +On {AWS}, the default installation creates a billable GPU instance (one `g6.2xlarge` instance with one NVIDIA L4 GPU). AWS only bills for this instance while it is running. However, be aware that uninstalling the pattern does not delete the instance. To delete the instance, see link:/patterns/vllm-ray-inference-server/getting-started/#uninstalling-the-vllm-ray-pattern[Uninstalling the pattern]. + +The pattern does not create instances on other platforms. +==== + +[id="background-vllm-ray"] +== Background + +The {vllm-ray-pattern} is for teams that serve a large language model on their own {ocp} cluster, and for teams that plan to and are choosing GPUs, not only for teams that already run vLLM. vLLM is an open source engine that runs large language models on GPUs efficiently. Ray Serve LLM is the serving layer from the open source Ray project for large language models, which runs vLLM, scales the number of vLLM replicas, and serves an OpenAI-compatible API. The pattern installs with one command, through {rh-gitops}. + +[id="problem-vllm-ray"] +=== The problem + +Every team that serves an LLM has to answer the same question, again and again: is this server fast enough, and does a change make it faster or slower? Most teams cannot answer it with numbers that they can trust, because their numbers come from someone else's hardware, or change from one run to the next: + +* *Before buying GPUs:* the only numbers available are published benchmarks, measured on other hardware with other models. Teams that size from them can buy too few GPUs, so their users get slow answers, or too many, so GPUs sit idle and still cost money. +* *Before an upgrade or a settings change:* teams time one run before the change and one run after. Two starts of the same server can differ in speed, so this comparison cannot tell a real improvement from noise. A slower release can reach users, or a real gain can be held back. +* *After an incident:* a server image that installs the newest packages changes with every build. When the server gets slower, nobody can say whether the cause was their own change or a package that changed with the build. + +[id="how-pattern-avoids-vllm-ray"] +=== How the pattern avoids it + +The pattern gives one fix for each cause: + +. *Numbers from your own hardware:* the notebook benchmarks the server on your own GPU, with the same requests every time. It reports throughput and time to first token at 1, 8, and 32 concurrent requests, which gives a starting estimate of how many GPUs you need. +. *A reproducible build:* the server image installs every Python package link:/patterns/vllm-ray-inference-server/architecture/#pinned-versions-vllm-ray[pinned by hash], so a rebuild installs the same Python packages. They change only with a commit, which can be reviewed after an incident. +. *A comparison that accounts for noise:* an link:/patterns/vllm-ray-inference-server/ideas-for-customization/#comparing-images-vllm-ray[optional comparison] runs two server images or settings, such as your current one and a candidate, in repeated rounds next to identical copies. It reports a difference only when the difference is larger than the noise between starts and passes a statistical test. + +[id="alternatives-vllm-ray"] +=== Why teams need it, and where it fits + +Teams need repeatable numbers from their own server on their own GPU, separated from the noise between starts. The alternatives each miss part of this: + +* Published benchmarks come from other hardware. +* Timing a server by hand, for example with one run of GuideLLM, a benchmark tool for LLM servers, measures one server start, so it cannot tell a real change from noise. The optional comparison runs GuideLLM across repeated starts and tests the results. + +The pattern is a reference point for what open source vLLM and Ray do on your own GPU, measured the same way each time. It complements link:https://www.redhat.com/en/products/ai/inference[Red{nbsp}Hat AI Inference] and {rhoai}, which remain the supported servers. + +[id="design-decisions-vllm-ray"] +=== Benefits of the design decisions + +* *Ray Serve LLM.* Unlike `vllm serve`, vLLM's own server, it can add vLLM replicas, copies of the engine, under load when given enough GPUs. Adding replicas is off by default. +* *Upstream packages only.* Instead of a vendor's build, the image uses the vLLM, Ray, and PyTorch projects' releases, so results apply to what anyone can install. +* *One Git repository.* Instead of a hand-built server, your fork describes the whole deployment, so every change can be reviewed. +* *One pod.* Instead of KServe, a model-serving platform for Kubernetes, or KubeRay, an Operator that runs Ray clusters on Kubernetes, the server is one standard pod, with nothing more to install. It does not serve one model across several machines; {rhoai} offers KubeRay for that. + +[id="architecture-vllm-ray"] +== Architecture + +.Architecture of the {vllm-ray-pattern} +image::/images/vllm-ray-inference-server/architecture.svg[Diagram of the vLLM Ray Inference Server pattern. The Validated Patterns Operator and OpenShift GitOps deploy secrets management, GPU enablement, the inference server, and the notebook from your Git fork.] + +* The {validated-patterns-op} installs {rh-gitops} and points its Argo CD instance, the GitOps tool that applies the content of a Git repository to the cluster, at your fork. +* {hashicorp-vault} and the {eso-op} deliver an optional Hugging Face token to the server as a Kubernetes secret. Only a gated model, which Hugging Face lets you download only after you accept its conditions, needs the token. The default model is not gated. +* The {rh-nfd} and the NVIDIA GPU Operator prepare the GPU node, which a job of the pattern creates on AWS. +* A `BuildConfig` object builds the server image inside the cluster. The server deployment runs one pod with Ray Serve LLM and the vLLM engine on one GPU. +* A persistent volume claim keeps the model weights across pod restarts. +* A JupyterLab notebook runs behind the OpenShift OAuth proxy and sends requests to the server through the in-cluster service. + +For details, see link:/patterns/vllm-ray-inference-server/architecture/[Architecture]. + +[id="requirements-vllm-ray"] +== Requirements + +Check the following before you install. For details, see link:/patterns/vllm-ray-inference-server/cluster-sizing/[Cluster sizing]. + +* {ocp} 4.18 or later, with cluster administrator access. +* One NVIDIA GPU node: +** On {AWS}, the pattern creates the GPU node. Your AWS account needs enough GPU instance quota. +** On other platforms, and on AWS clusters that were installed into existing subnets, add the GPU node yourself before you install. +** The server runs on `amd64` nodes by default. For an `arm64` GPU node, see link:/patterns/vllm-ray-inference-server/cluster-sizing/#gpu-node-requirements-vllm-ray[GPU node requirements]. +* 50 GiB of free ephemeral storage for the server image build, on a node without the `nvidia.com/gpu` taint. Ephemeral storage is the local disk space of a node for temporary files and container images. A taint keeps pods that do not tolerate it, such as the build, off the node. +* A storage class that provisions persistent volumes dynamically. +* The {ocp-registry} in the `Managed` state, and the `Build` and `ImageRegistry` cluster capabilities enabled, because the cluster builds the server and notebook images itself and stores them in this registry. +* Network access from the cluster to GitHub, PyPI, container registries, and Hugging Face, the source of the model. +* Optional: a Hugging Face token, only to serve a gated model. +* Your own fork of the pattern repository on GitHub, and Podman 4.3 or later, Git, and the `oc` CLI on your workstation. + +If the cluster already runs the {rh-nfd} or the NVIDIA GPU Operator, the pattern can conflict with them. link:/patterns/vllm-ray-inference-server/getting-started/#deploying-the-vllm-ray-pattern[Getting started] checks for them before you install. + +[id="components-vllm-ray"] +== Technologies that the pattern uses + +Of the technologies in the following lists, only {rh-ocp} must already run. The pattern installs the others, or builds them into its images. With the `global.gpuOperators: reuse` setting, which you choose in link:/patterns/vllm-ray-inference-server/getting-started/#deploying-the-vllm-ray-pattern[Getting started], it uses the cluster's own {rh-nfd} and NVIDIA GPU Operator instead. + +[id="red-hat-technologies-vllm-ray"] +=== Red Hat technologies + +* {rh-ocp}, which must already run +* {rh-gitops} +* The {eso-op} for Red{nbsp}Hat OpenShift +* The {rh-nfd} +* Optional: the Red{nbsp}Hat Custom Metrics Autoscaler, only with `global.scaleOut.mode: keda`. See link:/patterns/vllm-ray-inference-server/ideas-for-customization/#scale-out-vllm-ray[Scaling out the server under load]. + +[id="other-technologies-vllm-ray"] +=== Other technologies this pattern uses + +* The {validated-patterns-op}, a community Operator +* The NVIDIA GPU Operator, from the certified Operators catalog +* {hashicorp-vault}, from the {solution-name-upstream} Helm chart +* vLLM, Ray Serve LLM, and PyTorch, which the server image build installs from PyPI +* The NVIDIA CUDA image based on Red{nbsp}Hat Universal Base Image 9, as the base of the server image +* JupyterLab, in the notebook image +* GuideLLM, a benchmark for LLM servers, which sends the requests of the link:/patterns/vllm-ray-inference-server/ideas-for-customization/#comparing-images-vllm-ray[optional image comparison] + +[id="applications-vllm-ray"] +=== Applications that the pattern deploys + +* The inference server. Ray Serve LLM runs the vLLM engine and serves an OpenAI-compatible API on port 8000. The default model is `Qwen/Qwen2.5-0.5B-Instruct`. +* The notebook. A JupyterLab notebook measures the running server, as described in link:/patterns/vllm-ray-inference-server/architecture/#notebook-measurements-vllm-ray[How the notebook measures the server]. + +The link:https://github.com/eugo-inc/vllm-ray-inference-server#what-is-in-the-stock-stack[pattern README] lists the exact version of each component. + +[id="partner-results-summary-vllm-ray"] +== Partner results: Eugo + +Eugo timed how long each server took to start and stream its first token, in Docker containers on one NVIDIA DGX Spark, not on {ocp}. As shipped, the median start of the upstream `vllm/vllm-openai` v0.33.0 image took 3.6 times as long as that of Eugo's next release build in one comparison, and 4.5 times as long in another. For the settings and the other runs, see link:/patterns/vllm-ray-inference-server/partner-results/#partner-results-vllm-ray[Partner results: Eugo]. + +[id="support-vllm-ray"] +== Support + +Eugo maintains the pattern and supports it on a best-effort basis through link:https://github.com/eugo-inc/vllm-ray-inference-server/issues[GitHub issues] in the pattern repository. The maintainers do not guarantee a response time. Red{nbsp}Hat does not produce, support, or validate this pattern. For an issue with a product that the pattern deploys, contact the vendor of that product. + +[id="next-steps-vllm-ray"] +== Next steps + +* link:/patterns/vllm-ray-inference-server/getting-started/[Getting started] +* link:/patterns/vllm-ray-inference-server/architecture/[Architecture] +* link:/patterns/vllm-ray-inference-server/cluster-sizing/[Cluster sizing] +* link:/patterns/vllm-ray-inference-server/ideas-for-customization/[Ideas for customization] +* link:/patterns/vllm-ray-inference-server/troubleshooting/[Troubleshooting] +* link:/patterns/vllm-ray-inference-server/partner-results/[Partner results: Eugo] diff --git a/content/patterns/vllm-ray-inference-server/architecture.adoc b/content/patterns/vllm-ray-inference-server/architecture.adoc new file mode 100644 index 000000000..7af4ebbca --- /dev/null +++ b/content/patterns/vllm-ray-inference-server/architecture.adoc @@ -0,0 +1,66 @@ +--- +title: Architecture +weight: 20 +aliases: /vllm-ray-inference-server/architecture/ +--- + +:toc: +:imagesdir: /images +:_content-type: ASSEMBLY +include::modules/comm-attributes.adoc[] +:vllm-ray-pattern: vLLM Ray Inference Server pattern + +[id="architecture-details-vllm-ray"] +== How the {vllm-ray-pattern} works + +This page describes how the pattern deploys from your fork, how the inference server runs, what the pattern pins, and how the notebook measures the server. For the architecture diagram and a summary of each component, see link:/patterns/vllm-ray-inference-server/#architecture-vllm-ray[Architecture] on the pattern overview page. + +[id="terms-vllm-ray"] +=== Terms used on this page + +Token:: A word or a piece of a word. Models read and write text as tokens, so server speed is counted in tokens. +Time to first token:: How long a user waits for the first token of an answer. +Throughput:: Tokens per second that the server produces across all requests that it serves at the same time. +Pinned by hash:: A package is installed only if its file matches a recorded checksum, so every build gets the same file. +Gated model:: A Hugging Face model that you can download only with your access token, after you accept its conditions. + +[id="deploying-from-your-fork-vllm-ray"] +=== How the pattern deploys from your fork + +Your fork of the pattern repository describes the whole deployment: GPU enablement, the server, a model cache, a secret for gated models, and a timing notebook. You run the `./pattern.sh make install` command one time. The {validated-patterns-op} installs {rh-gitops} and points its Argo CD instance, the GitOps tool that applies the content of a Git repository to the cluster, at your fork. The `clustergroup` Helm chart of the {solution-name-upstream} framework then creates the namespaces, Operator subscriptions, and Argo CD applications that the `variants/prod/values-prod.yaml` file in your fork lists. After that, {rh-gitops} syncs each commit on your branch. It does not delete the objects that a commit removes, and it does not change the image of the running server or notebook. A job in the cluster starts new image builds: every 10 minutes, it starts a build when the server or notebook folder changed and no build of that image is running. For details, see link:https://github.com/eugo-inc/vllm-ray-inference-server/blob/main/AGENTS.md#updating-a-running-install[Updating a running install] in the pattern repository. + +[id="first-installation-vllm-ray"] +=== What happens during the first installation + +The first installation runs in roughly the following order: + +. The Operators install, and {hashicorp-vault-short} starts. +. On AWS, a job of the pattern, which runs every 10 minutes, creates the GPU node. The NVIDIA GPU Operator then installs the NVIDIA driver on the node. +. The cluster builds the server image. This build pulls a multi-gigabyte CUDA development image and installs several gigabytes of Python packages, so the build node needs plenty of free ephemeral storage. +. The server pod stays in the `Pending` state until a node advertises the `nvidia.com/gpu` resource. +. On its first start, the server downloads the model into the `ray-serve-llm-models` persistent volume claim, where the model stays across restarts. vLLM and FlashInfer, a library of GPU kernels for inference that vLLM uses, also compile GPU kernels, the functions that run on the GPU. The pattern does not keep these compiled kernels by default, so every new server pod compiles them again. +. The pod reports `Ready` only after the model loads. + +[id="inference-server-vllm-ray"] +=== How the inference server runs + +The server runs Ray Serve LLM and the vLLM engine in one pod of a standard deployment, without KServe or KubeRay. Ray, vLLM, and PyTorch come from PyPI and run on the NVIDIA CUDA image that is based on Red{nbsp}Hat Universal Base Image 9. The pattern creates no KServe `InferenceService` or `ServingRuntime` resource. The server image turns off the usage statistics of Ray and vLLM. + +The server deployment uses the `Recreate` strategy, because a rolling update needs a second GPU and the same `ReadWriteOnce` persistent volume claim, and with one GPU it cannot finish. As a result, the server is down during each rollout. + +[id="pinned-versions-vllm-ray"] +=== What the pattern pins + +The pattern pins every Python package by hash and installs wheels only. It pins the base images of the server and the notebook by digest, and the default model by its Hugging Face commit. Some parts are not pinned, among them the system packages that the server image installs with `dnf`, the Operator versions, and the patch versions of the Validated Patterns Helm charts. Two builds from the same commit therefore install the same Python packages, but their system packages can differ. + +[id="notebook-measurements-vllm-ray"] +=== How the notebook measures the server + +The notebook measures the server in your cluster: the time from pod start to `Ready`, the time to first token, the decode speed of one stream, which is how fast the server writes one answer, and the token throughput at 1, 8, and 32 concurrent requests. The notebook chooses its prompts from a fixed seed, and every request uses a fixed number of output tokens and a temperature of 0, so the model always picks its most likely next token. The time to `Ready` is in whole seconds and can trail the server by up to about 2 seconds. + +[id="next-steps-vllm-ray-architecture"] +== Next steps + +* link:/patterns/vllm-ray-inference-server/getting-started/[Getting started] +* link:/patterns/vllm-ray-inference-server/cluster-sizing/[Cluster sizing] +* link:/patterns/vllm-ray-inference-server/ideas-for-customization/[Ideas for customization] diff --git a/content/patterns/vllm-ray-inference-server/cluster-sizing.adoc b/content/patterns/vllm-ray-inference-server/cluster-sizing.adoc new file mode 100644 index 000000000..f1cc6e2a5 --- /dev/null +++ b/content/patterns/vllm-ray-inference-server/cluster-sizing.adoc @@ -0,0 +1,140 @@ +--- +title: Cluster sizing +weight: 30 +aliases: /vllm-ray-inference-server/cluster-sizing/ +--- + +:toc: +:imagesdir: /images +:_content-type: ASSEMBLY +include::modules/comm-attributes.adoc[] +:vllm-ray-pattern: vLLM Ray Inference Server pattern + +[id="cluster-sizing-vllm-ray"] +== Cluster sizing for the {vllm-ray-pattern} + +The pattern runs on one {ocp} cluster. The cluster needs ordinary nodes for the Operators, {hashicorp-vault-short}, the image builds, and the notebook, and one GPU node for the inference server. + +[id="tested-cluster-vllm-ray"] +=== Tested cluster + +The pattern requires {ocp} 4.18 or later. With a GPU, it has been tested only on {ocp} 4.22.18, on new clusters on {AWS}. Other clouds and bare metal have not been tested. The pattern has installed and served the default model on a compact cluster with the following nodes: + +.Tested cluster on AWS +[cols="<,^,<,<,<",options="header"] +|=== +| Node type | Number of nodes | Instance type | vCPUs and memory of each node | GPU + +| Control plane and worker +| 3 +| `m5.2xlarge` +| 8 vCPUs, 32 GiB +| None + +| GPU worker, created by the pattern +| 1 +| `g6.2xlarge` +| 8 vCPUs, 32 GiB +| One NVIDIA L4 GPU with 24 GB of memory +|=== + +The `global.gpuOperators: reuse` setting has run on one test cluster so far, and the pattern has not been tested on a cluster that runs {rhoai}. For a model larger than the default model, see <>. For how each optional feature was tested, see link:/patterns/vllm-ray-inference-server/ideas-for-customization/[Ideas for customization]. + +[id="gpu-node-requirements-vllm-ray"] +=== GPU node requirements + +The inference server requests one whole GPU, as the `nvidia.com/gpu` resource, and tolerates the `nvidia.com/gpu` taint. + +* On AWS, the pattern creates one `g6.2xlarge` node with one NVIDIA L4 GPU by default. For billing and how to delete the instance, see the warning on the link:/patterns/vllm-ray-inference-server/[pattern overview]. The instance counts as 8 vCPUs against the Running On-Demand G and VT instances quota of your AWS account. That quota can be 0 on a new account, so you might need to request an increase first. See link:https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-instance-quotas.html[Amazon EC2 instance type quotas]. +* To skip that instance and use a GPU node that you provide instead, set `global.gpuMachineSet: none` in the `values-global.yaml` file in your fork, and push the change before you install. On an AWS cluster that was installed into existing subnets, the job that creates the GPU node fails, so set `global.gpuMachineSet: none` and add a GPU node yourself. For the steps, see the section about adding a GPU node in link:https://docs.redhat.com/en/documentation/openshift_container_platform/4.18/html/machine_management/managing-compute-machines-with-the-machine-api#creating-machineset-aws[Creating a compute machine set on AWS] in the {ocp} documentation. +* On other platforms, add a node with an NVIDIA GPU that the NVIDIA GPU Operator supports, as listed in link:https://docs.nvidia.com/datacenter/cloud-native/gpu-operator/latest/platform-support.html[Platform support] in the NVIDIA documentation. For Azure and Google Cloud, link:https://docs.redhat.com/en/documentation/openshift_container_platform/4.18/html/machine_management/managing-compute-machines-with-the-machine-api[Managing compute machines with the Machine API] in the {ocp} documentation also describes how to add a GPU node. +* The server image runs CUDA 13, which needs NVIDIA driver version 580 or later. +* The vLLM 0.29.0 packages in the server image are built for NVIDIA GPUs of compute capability 7.5, 8.0, 8.6, 8.9, 9.0, 10.0, and 12.0 on `amd64`, and 8.0, 8.7, 8.9, 9.0, 10.0, 11.0, and 12.0 on `arm64`, as the link:https://github.com/vllm-project/vllm/blob/v0.29.0/.buildkite/release-pipeline.yaml[vLLM 0.29.0 release build list] sets. To find the compute capability of your GPU, see link:https://developer.nvidia.com/cuda-gpus[CUDA GPU Compute Capability] on the NVIDIA website. The NVIDIA L4 GPU has compute capability 8.9. On {ocp}, only the NVIDIA L4 GPU has been tested. +* The server runs on `amd64` nodes by default. If your GPU node is an `arm64` node, set `arch: arm64` in the `charts/all/ray-serve-llm/values.yaml` file in your fork before you install. The server image build also needs an `arm64` node without the `nvidia.com/gpu` taint. An `arm64` GPU node has not been tested on {ocp}. For details, read the prerequisites in the link:https://github.com/eugo-inc/vllm-ray-inference-server/blob/main/AGENTS.md#prerequisites[AGENTS.md file] in the pattern repository. + +[id="choosing-a-gpu-vllm-ray"] +=== Choosing a GPU for your model + +The server gives vLLM 85% of the memory of the GPU (`gpu_memory_utilization: 0.85`) and a context of up to 8,192 link:/patterns/vllm-ray-inference-server/architecture/#terms-vllm-ray[tokens] per request, the prompt and the answer together (`max_model_len: 8192`), in the engine settings of the `ray-serve-llm` Helm chart. The weights of the model must fit in that share, together with the KV cache: the memory in which vLLM keeps calculations for the earlier tokens of each request that it serves, so that it does not repeat them for every new token. The smaller the KV cache, the fewer requests vLLM can serve at the same time. + +To check whether a model fits your GPU: + +. On the Hugging Face page of the model, add up the sizes of its weight files, such as the `.safetensors` files, on the *Files and versions* tab. The weights of the default model, `Qwen/Qwen2.5-0.5B-Instruct`, are one file of about 0.99 GB. +. Compare that total with 85% of the memory of your GPU, and leave room for the KV cache. The NVIDIA L4 GPU, the GPU that the pattern has been tested with, has 24 GB of memory. +. Serve the model, as link:/patterns/vllm-ray-inference-server/ideas-for-customization/#changing-the-model-vllm-ray[Serving a different model] describes, and check that the server pod reports `Ready`. The server log reports the size of the KV cache that vLLM got, in the line that contains `GPU KV cache size`. + +For a model that does not fit, choose a GPU with more memory, or lower the context length. For other ways to use less memory, see link:https://docs.vllm.ai/en/v0.29.0/configuration/conserving_memory.html[Conserving memory] in the vLLM documentation. To see how the model performs on your GPU, run the notebook after the change. + +[id="workload-resources-vllm-ray"] +=== Resource requests of the pattern workloads + +The following table lists the resources that the main workloads of the pattern request, with the default settings: + +.Resource requests with the default settings +[cols="<,<,<,<,<",options="header"] +|=== +| Workload | CPU request | Memory request | Memory limit | Other + +| Inference server pod +| 2 +| 12 GiB +| 24 GiB +| One GPU + +| Server image build +| 1 +| 4 GiB +| None +| 50 GiB of ephemeral storage, on a node without the `nvidia.com/gpu` taint + +| Notebook pod: notebook container +| 250m +| 512 MiB +| 2 GiB +| None + +| Notebook pod: OAuth proxy container +| 50m +| 64 MiB +| 256 MiB +| None + +| Notebook image build +| 500m +| 1 GiB +| None +| 10 GiB of ephemeral storage + +| Image comparison runner, only with `global.compare.enabled: true` +| 2 +| 2 GiB +| 8 GiB +| None + +| Each image comparison side, only with `global.compare.enabled: true` +| 2 +| 12 GiB +| 24 GiB +| One GPU +|=== + +A comparison run scales the inference server to zero pods, so each side uses the GPU of the server. + +[id="storage-registry-vllm-ray"] +=== Storage, image registry, and network access + +* The model cache uses one 50 GiB persistent volume claim with the `ReadWriteOnce` access mode, so the cluster needs a storage class that provisions persistent volumes dynamically. Server pods on more than one node, with the `global.scaleOut.mode: keda` setting, need the `ReadWriteMany` access mode. See link:/patterns/vllm-ray-inference-server/ideas-for-customization/#scale-out-vllm-ray[Scaling out the server under load]. +* The {ocp-registry} in the `Managed` state, and the `Build` and `ImageRegistry` cluster capabilities enabled. The cluster builds the server image and the notebook image itself. On bare metal and on vSphere, the registry starts in the `Removed` state. To check the registry state and the enabled capabilities, run the following commands: ++ +[source,terminal] +---- +$ oc get configs.imageregistry.operator.openshift.io cluster -o jsonpath='{.spec.managementState}' +$ oc get clusterversion version -o jsonpath='{.status.capabilities.enabledCapabilities}' +---- +* Network access from the cluster to GitHub, PyPI, `nvcr.io`, `registry.access.redhat.com`, the package repositories of the base images, and Hugging Face. The cluster clones your fork, builds the images, and downloads the model itself. The optional image comparison also pulls the images of its two sides, such as `docker.io/vllm/vllm-openai`, and the GuideLLM image from `ghcr.io`. + +[id="next-steps-vllm-ray-sizing"] +== Next steps + +* link:/patterns/vllm-ray-inference-server/getting-started/[Getting started] +* link:/patterns/vllm-ray-inference-server/troubleshooting/[Troubleshooting] diff --git a/content/patterns/vllm-ray-inference-server/getting-started.adoc b/content/patterns/vllm-ray-inference-server/getting-started.adoc new file mode 100644 index 000000000..f6f14a0e0 --- /dev/null +++ b/content/patterns/vllm-ray-inference-server/getting-started.adoc @@ -0,0 +1,236 @@ +--- +title: Getting started +weight: 10 +aliases: /vllm-ray-inference-server/getting-started/ +--- + +:toc: +:imagesdir: /images +:_content-type: ASSEMBLY +include::modules/comm-attributes.adoc[] +:vllm-ray-pattern: vLLM Ray Inference Server pattern + +[id="deploying-the-vllm-ray-pattern"] +== Deploying the {vllm-ray-pattern} + +You deploy the pattern from your own fork of the pattern repository. {rh-gitops} deploys the content of your fork on GitHub, not the files on your workstation, so commit and push every change before you install the pattern. + +.Prerequisites + +* An {ocp} 4.18 or later cluster, and cluster administrator access. +* A GPU node that meets the link:/patterns/vllm-ray-inference-server/cluster-sizing/#gpu-node-requirements-vllm-ray[GPU node requirements]. On {AWS}, the pattern can create it. +* 50 GiB of free ephemeral storage for the server image build, on a node without the `nvidia.com/gpu` taint. See link:/patterns/vllm-ray-inference-server/cluster-sizing/#workload-resources-vllm-ray[Resource requests of the pattern workloads]. +* A dynamic storage class, and the {ocp-registry} in the `Managed` state with the `Build` and `ImageRegistry` cluster capabilities. See link:/patterns/vllm-ray-inference-server/cluster-sizing/#storage-registry-vllm-ray[Storage, image registry, and network access]. +* Network access from the cluster to the sites that it downloads from. See link:/patterns/vllm-ray-inference-server/cluster-sizing/#storage-registry-vllm-ray[Storage, image registry, and network access]. +* A GitHub account for your fork, and Podman 4.3 or later, Git, and the `oc` CLI on your workstation. For the other tool dependencies, see link:https://validatedpatterns.io/learn/quickstart/[Patterns quick start]. + +The procedure checks whether the cluster already runs the {rh-nfd} or the NVIDIA GPU Operator, because the pattern can conflict with them. + +.Procedure + +. Log in to the cluster: ++ +[source,terminal,subs="+quotes"] +---- +$ oc login --token=____ --server=____ +---- ++ +If you set the `KUBECONFIG` environment variable, it must point to a file in your home directory. + +. Check whether the cluster already runs the {rh-nfd} or the NVIDIA GPU Operator, which the pattern installs by default: +.. List the Operators that were installed from OperatorHub: ++ +[source,terminal] +---- +$ oc get subscriptions.operators.coreos.com -A | grep -E 'nfd|gpu-operator-certified' +---- ++ +No output means that no subscription for either Operator exists. +.. List the objects that each Operator uses. These commands also find the objects of Operators that were installed in another way: ++ +[source,terminal] +---- +$ oc get nodefeaturediscoveries.nfd.openshift.io -A +$ oc get clusterpolicies.nvidia.com +---- ++ +`No resources found`, or an error that the server does not have the resource type, means that the cluster has no such object. + +. Choose the `global.gpuOperators` setting before you install, because switching a running installation between `install` and `reuse` is not supported. In the results of the previous step, an Operator counts as found when any of the commands lists its subscription or its object. +** If neither Operator is found, keep the default setting, `install`. +** Use `reuse`, so that the pattern uses the cluster's own Operators and does not change them, only if all of the following are true: +*** Both Operators are found. +*** The `nodefeaturediscoveries` command lists an object. +*** The `clusterpolicies` command lists an object with `ready` in its `STATUS` column. +** In any other case, such as only one Operator found, or both found without these objects, do not install the pattern yet. The pattern supports neither setting on such a cluster. Either finish the installation of both Operators and their objects, as the link:https://docs.nvidia.com/datacenter/cloud-native/openshift/latest/steps-overview.html[NVIDIA GPU Operator on OpenShift] guide describes, and run the check again, or open an issue in the link:https://github.com/eugo-inc/vllm-ray-inference-server/issues[pattern repository] with the output of these commands. + ++ +The `reuse` setting has run on one test cluster so far, and the pattern has not been tested on a cluster that runs {rhoai}. For what these Operators must provide, see link:https://github.com/eugo-inc/vllm-ray-inference-server#reuse-the-clusters-gpu-operators[Reuse the cluster's GPU operators] in the pattern README. + +. Fork the link:https://github.com/eugo-inc/vllm-ray-inference-server[vllm-ray-inference-server] repository on GitHub. + +. Clone your fork: ++ +[source,terminal,subs="+quotes"] +---- +$ git clone https://github.com/____/vllm-ray-inference-server.git +---- + +. Go to the root directory of the repository: ++ +[source,terminal] +---- +$ cd vllm-ray-inference-server +---- + +. Edit the `values-global.yaml` file: +** Set `global.gpuOperators` to `install` or `reuse`, as you chose after the Operator check. +** Set `global.gpuMachineSet` to `none` to skip the billable `g6.2xlarge` node that the default, `create`, adds on {AWS}: for example, when you provide the GPU node, or when the AWS cluster was installed into existing subnets. See link:/patterns/vllm-ray-inference-server/cluster-sizing/#gpu-node-requirements-vllm-ray[GPU node requirements]. +** Optional: To serve a different model from Hugging Face, set `global.model.id`, `global.model.source`, and `global.model.revision`. + +. Commit and push the change: ++ +[source,terminal] +---- +$ git commit -am "Configure the pattern" +$ git push +---- + +. Optional: To serve a gated model, create the secrets file for the pattern and add your Hugging Face token: +.. Copy the secrets template: ++ +[source,terminal] +---- +$ mkdir -p ~/.config/validated-patterns +$ cp values-secret.yaml.template \ + ~/.config/validated-patterns/values-secret-vllm-ray-inference-server.yaml +---- +.. In the copied file, set the `value` of the `hftoken` field to your Hugging Face token, which starts with `hf_`. Do not commit this file. + +. Install the pattern: ++ +[source,terminal] +---- +$ ./pattern.sh make install +---- ++ +On {AWS}, with the default `global.gpuMachineSet: create` setting, this command creates the billable `g6.2xlarge` GPU instance. AWS bills for the instance for as long as it runs. ++ +The installer waits up to 60 minutes for every Argo CD application to report `Synced` and `Healthy`. A first installation can take longer. If the wait times out, the pattern stays installed; see link:/patterns/vllm-ray-inference-server/troubleshooting/#troubleshooting-install-timeout-vllm-ray[The installation command fails after about an hour]. + +. Watch the deployment: ++ +[source,terminal] +---- +$ oc get applications.argoproj.io -A +$ oc get builds -n vllm-inference +$ oc get pods -n vllm-inference -w +---- ++ +The server pod stays in the `Pending` state until a node advertises the `nvidia.com/gpu` resource. The pod reports `Ready` after it loads the model. + +[id="verifying-the-vllm-ray-pattern"] +== Verifying the inference server + +The server is reachable inside the cluster at `http://ray-serve-llm.vllm-inference.svc:8000`. To send a test request from your workstation, forward the server port. + +.Procedure + +. Forward the server port to your workstation: ++ +[source,terminal] +---- +$ oc port-forward svc/ray-serve-llm 8000:8000 -n vllm-inference +---- + +. In another terminal, list the models that the server serves: ++ +[source,terminal] +---- +$ curl -s http://localhost:8000/v1/models +---- + +. Send a chat request: ++ +[source,terminal] +---- +$ curl -s http://localhost:8000/v1/chat/completions \ + -H 'Content-Type: application/json' \ + -d '{ + "model": "qwen2.5-0.5b-instruct", + "messages": [{"role": "user", "content": "Say hello in one sentence."}], + "max_tokens": 64 + }' +---- ++ +The `model` field takes the value of `global.model.id`. Any OpenAI-compatible client works with the base URL `http://localhost:8000/v1`. + +[id="opening-the-notebook-vllm-ray"] +== Opening the notebook + +The notebook pod runs JupyterLab behind the OpenShift OAuth proxy. Users who can edit the `vllm-notebook` namespace, and cluster administrators, can open it. + +.Procedure + +. Get the URL of the notebook route: ++ +[source,terminal] +---- +$ oc get route -n vllm-notebook +---- + +. Open the URL in a browser and log in with your OpenShift account. + +. Open the `inference_timings.ipynb` notebook and run all cells. The notebook pod copies the notebook folder to a scratch directory each time that it starts, so download any change that you want to keep. + +. Optional: To give another user access to the notebook, grant the `edit` role in the `vllm-notebook` namespace: ++ +[source,terminal,subs="+quotes"] +---- +$ oc adm policy add-role-to-user edit ____ -n vllm-notebook +---- + +[id="uninstalling-the-vllm-ray-pattern"] +== Uninstalling the pattern + +The {solution-name-upstream} framework marks uninstallation as experimental. Uninstalling the pattern leaves the {validated-patterns-op} and {rh-gitops} installed, and it does not delete the AWS GPU node. AWS bills for the GPU instance for as long as it runs, so delete it with its machine set, as the following steps describe. + +.Procedure + +. Uninstall the pattern: ++ +[source,terminal] +---- +$ ./pattern.sh make uninstall +---- + +. List the machine sets with their instance types: ++ +[source,terminal] +---- +$ oc get machinesets -n openshift-machine-api \ + -o custom-columns=NAME:.metadata.name,TYPE:.spec.template.spec.providerSpec.value.instanceType +---- + +. Delete the machine set of the `g6.2xlarge` instance type. Delete it only after the uninstallation finishes, or after the `global.gpuMachineSet: none` setting syncs. Otherwise, the job creates the machine set again. ++ +[source,terminal,subs="+quotes"] +---- +$ oc delete machineset ____ -n openshift-machine-api +---- + +. Check for a leftover persistent volume from the `vllm-inference/ray-serve-llm-models` claim: ++ +[source,terminal] +---- +$ oc get pv +---- + +[id="next-steps-vllm-ray-getting-started"] +== Next steps + +* If the installation or the server does not work as expected, see link:/patterns/vllm-ray-inference-server/troubleshooting/[Troubleshooting]. +* For other models and the optional features, see link:/patterns/vllm-ray-inference-server/ideas-for-customization/[Ideas for customization]. +* For how the pattern works, see link:/patterns/vllm-ray-inference-server/architecture/[Architecture]. +* For the web console installation, private forks, and updates, see the link:https://github.com/eugo-inc/vllm-ray-inference-server/blob/main/AGENTS.md[AGENTS.md file] in the pattern repository. +* For the pattern overview, see link:/patterns/vllm-ray-inference-server/[{vllm-ray-pattern}]. diff --git a/content/patterns/vllm-ray-inference-server/ideas-for-customization.adoc b/content/patterns/vllm-ray-inference-server/ideas-for-customization.adoc new file mode 100644 index 000000000..6123e70ff --- /dev/null +++ b/content/patterns/vllm-ray-inference-server/ideas-for-customization.adoc @@ -0,0 +1,160 @@ +--- +title: Ideas for customization +weight: 40 +aliases: /vllm-ray-inference-server/ideas-for-customization/ +--- + +:toc: +:imagesdir: /images +:_content-type: ASSEMBLY +include::modules/comm-attributes.adoc[] +:vllm-ray-pattern: vLLM Ray Inference Server pattern + +[id="ideas-for-customization-vllm-ray"] +== Ideas for customizing the {vllm-ray-pattern} + +The default installation serves one small model on one GPU, from one server pod. The following ideas change what the pattern serves and measures: + +* <>. +* <> before you change the server. +* <>. +* <>. + +Commit and push each change to your fork: {rh-gitops} deploys the content of your fork on GitHub, not the files on your workstation. + +[id="changing-the-model-vllm-ray"] +=== Serving a different model + +To benchmark the model that you plan to run, on your own GPU, serve it instead of the default model. The model must fit in the memory of the GPU, together with the engine settings in the `ray-serve-llm` Helm chart. For the GPU memory that the server gives vLLM, see link:/patterns/vllm-ray-inference-server/cluster-sizing/#choosing-a-gpu-vllm-ray[Choosing a GPU for your model]. + +.Prerequisites + +* To serve a gated model, you loaded your Hugging Face token, as described in link:/patterns/vllm-ray-inference-server/getting-started/[Getting started]. + +.Procedure + +. Set the following values in the `values-global.yaml` file in your fork: +** `global.model.id`: the model name that clients use. +** `global.model.source`: the Hugging Face repository ID of the model. +** `global.model.revision`: the Hugging Face commit of the new model, or an empty value for its latest version. Do not keep the commit of the old model. +. Commit and push the change. + +{rh-gitops} then updates the configuration of the server, and the server pod restarts and downloads the new model. Changing the model of a running installation has not been tested on a cluster. + +[id="comparing-images-vllm-ray"] +=== Comparing two server images or two sets of engine settings + +Before you move the server to a new vLLM release, or change its engine settings, compare the two on your GPU. Two starts of the same server image can differ even when nothing changed, so one run of each often cannot show whether a small change is faster or slower. The image comparison is off by default. + +[IMPORTANT] +==== +A run scales the inference server to zero pods for its whole length, so the server does not answer requests until the run ends. With the default settings, a run has 34 server starts. The one timed run with these settings, with upstream vLLM 0.33.0 and the pattern's own server as its two sides, took 3 hours 46 minutes on {ocp} with one NVIDIA L4 GPU. Runs with slower-starting sides take longer. Plan each run as a maintenance window, as link:https://github.com/eugo-inc/vllm-ray-inference-server#plan-it-as-a-maintenance-window[Plan it as a maintenance window] in the pattern README describes. +==== + +A job in the cluster starts the two sides, the two images or settings that you compare, in rounds, on the same GPU with the same model and requests. In each round, it also starts an identical copy of each side, to measure the noise between starts. GuideLLM 0.8.1 sends the requests. + +A case is one figure that the job measures in every server start, such as the median time to first token at 32 concurrent requests. Each case ends with a verdict, such as FASTER, SLOWER, or TIE, or with NO VERDICT and a reason. + +A rule that is fixed before the first start decides each case: a difference counts only when it is larger than the gap between the copies and holds up in a statistical test over the rounds. The test is a sign test, which checks whether one side wins the rounds more consistently than chance explains. + +Only the verdicts of the primary cases count as findings. Only the primary cases get Holm's correction, which keeps the chance of a false finding low when several cases are tested at the same time. The `global.compare.analysis.primary` key in the `values-global.yaml` file sets the primary cases, and the pattern README lists the default ones. + +The sign test, Holm's correction, and the fewest rounds that a verdict needs come from link:https://github.com/eugo-inc/pairbench[pairbench] 0.1.0, an open source Python package from Eugo, which the pattern installs unmodified from PyPI with pinned hashes. For the full rule and the metrics that the job records, see link:https://github.com/eugo-inc/vllm-ray-inference-server#how-the-verdicts-are-decided[How the verdicts are decided] in the pattern README. + +.Prerequisites + +* The first installation has finished, and the notebook image has been built. The job takes its code and its statistics package from the notebook image. +* You can take the inference server offline for the length of the run. + +.Procedure + +. In the `values-global.yaml` file in your fork, set `global.compare.enabled: true`, a run name, and the two sides to compare. Side A is the baseline, and side B is the candidate. The following example shows the default run name and sides in that file, which compare two upstream vLLM releases, pinned by digest. Change only these keys, and keep the other keys under `global.compare`, such as `rounds`, `load`, and `analysis`, as they are: ++ +[source,yaml] +---- +global: + compare: + enabled: true + runName: vllm-two-releases + sides: + - name: vllm-0-32-0 + image: docker.io/vllm/vllm-openai:v0.32.0@sha256:befccf0e7e4089aa23926bb6f887a85c0d46c2a99e6de5c5ffdf5cb7957c5b34 + preset: vllm-openai + - name: vllm-0-33-0 + image: docker.io/vllm/vllm-openai:v0.33.0@sha256:d825baf9ce4b1b6bfc5ecc7b79880c7e6748c65a72d697ce3d47607aafa84c6e + preset: vllm-openai +---- ++ +Each side is a server image, a preset that says how to start it, and optional arguments in an `args` field. The `vllm-openai` preset starts an upstream vLLM image, and the `ray-serve-llm` preset starts the pattern's own server image. For an upstream vLLM image, the arguments are `vllm serve` flags. For the pattern's own server, they are vLLM engine arguments, such as `--attention-backend FLASHINFER`, `--max-num-seqs=64`, or `--enforce-eager`. To compare two sets of engine settings, give both sides the same image and different arguments; only the names of the two sides must differ. A side with arguments of its own has not run on {ocp}, and neither has a comparison of two sets of engine settings on one image. +. Commit and push the change. {rh-gitops} creates the comparison job in the `vllm-notebook` namespace. +. Follow the run: ++ +[source,terminal] +---- +$ oc get configmap -n vllm-notebook -l app.kubernetes.io/component=compare-run +---- +. When the run ends, open the `compare_images.ipynb` notebook to see the results. + +For the other settings and the steps after a run, see link:https://github.com/eugo-inc/vllm-ray-inference-server#run-a-comparison[Run a comparison] in the pattern README. + +On {ocp}, the image comparison has had one full-length run with the default rounds and load, on a new cluster on AWS with one NVIDIA L4 GPU, where the pattern reused the cluster's GPU Operators. It compared upstream vLLM 0.33.0 with the pattern's own server (vLLM 0.29.0 on Ray Serve LLM), and gave verdicts on all 4 of its primary cases. Upstream vLLM 0.33.0 came out ahead in all 4. The two sides differ in both vLLM version and serving stack, so the run does not say which of the two made the difference. Shorter comparisons, also in the scale-out mode, finished every server start. For the settings and what has not been checked, see the link:https://github.com/eugo-inc/vllm-ray-inference-server#compare-two-images[Compare two images] section of the pattern README. + +[id="tuning-engine-settings-vllm-ray"] +=== Tuning the engine settings + +The vLLM engine settings of the server, such as the share of GPU memory that vLLM uses (`gpu_memory_utilization`) and the longest context per request (`max_model_len`), are in `server.engineKwargs` in the `charts/all/ray-serve-llm/values.yaml` file. To see how a change of these settings affects the speed of the server on your GPU, measure before and after the change. + +.Procedure + +. Open the `inference_timings.ipynb` notebook, run all cells, and keep the results. +. Change the setting under `server.engineKwargs` in the `charts/all/ray-serve-llm/values.yaml` file in your fork, and commit and push the change. {rh-gitops} updates the configuration of the server, and the server pod restarts with the new settings. The server does not answer requests until the new pod is ready. Changing the engine settings of a running installation has not been tested on a cluster. +. Run the notebook again, and compare the results. + +One run of each setting often cannot show a small difference, because two starts of the same server can differ even when nothing changed. To compare two sets of settings against that noise, use the image comparison with the pattern's own server image on both sides and different arguments, as described in <>. + +[id="scale-out-vllm-ray"] +=== Scaling out the server under load + +When more requests arrive than one vLLM replica answers quickly, the server can grow under load. Scale-out is off by default, and the pattern offers it in two places: Ray Serve can add vLLM replicas inside the server pod, or the Red{nbsp}Hat Custom Metrics Autoscaler, the supported build of KEDA (Kubernetes Event-driven Autoscaling), can add whole server pods. + +To measure how a second replica helps under load, the image comparison also has a scale-out mode: at a fixed request rate, it starts a second replica of each side at a fixed time, and measures how soon that replica gives its first answer and what share of the requests meets the latency goals. + +[id="scale-out-in-pod-vllm-ray"] +==== Adding vLLM replicas inside the server pod + +On a node with several GPUs, more vLLM replicas in the one server pod serve more requests at the same time. + +On a node with one GPU, two replicas can only share that GPU, with `server.gpuPerReplica: 0.5` and `server.engineKwargs.gpu_memory_utilization: 0.4`. They add no GPU compute: they take turns on the GPU, and each has less memory for its cache. Use that setup to watch the autoscaler work, not to serve more requests. The test runs on {ocp} used it. + +.Prerequisites + +* A node with enough GPUs for every replica. The chart refuses a `server.gpuCount` below `server.autoscaling.maxReplicas` times `server.gpuPerReplica`. + +.Procedure + +. In the `charts/all/ray-serve-llm/values.yaml` file in your fork, set `server.autoscaling.maxReplicas` above 1, set `server.autoscaling.targetOngoingRequests`, and give the replicas enough GPUs with `server.gpuCount` and `server.gpuPerReplica`. For an example, see link:https://github.com/eugo-inc/vllm-ray-inference-server#inside-the-pod-more-vllm-replicas[Inside the pod: more vLLM replicas] in the pattern README. +. Commit and push the change. + +[id="scale-out-pods-vllm-ray"] +==== Adding server pods + +With `global.scaleOut.mode: keda`, the Red{nbsp}Hat Custom Metrics Autoscaler adds whole server pods when the vLLM count of waiting requests per pod rises above a set limit, and removes them after a cooldown. + +.Prerequisites + +* Monitoring for user-defined projects is enabled on the cluster: `enableUserWorkload: true` in the `cluster-monitoring-config` config map in the `openshift-monitoring` namespace. The pattern does not change that cluster setting. +* Each additional server pod needs a GPU: a second GPU node, or GPU time-slicing on the one node, which shares that GPU and adds no compute. With two time-sliced shares, set `server.engineKwargs.gpu_memory_utilization` to 0.4, or the second pod fails to start. Nothing checks this setting. Turn time-slicing off before an image comparison in its default mode: time-slicing applies to every namespace, so a GPU pod from another namespace can share the GPU during a timed start, and nothing flags the run. To turn time-slicing on, see link:https://github.com/eugo-inc/vllm-ray-inference-server#across-pods-ray-serve-pods-scaled-out-by-openshift[Across pods] in the pattern README. +* Server pods on more than one node need `modelStorage.accessMode: ReadWriteMany` in the `ray-serve-llm` Helm chart and a storage class that offers it. A claim's access mode cannot change after the claim is created. To keep the compiled kernels for server pods on more than one node, use `compileCache.mode: shared`, not `node`. The `node` and `shared` modes have not run on {ocp}. + +.Procedure + +. Set `global.scaleOut.mode: keda` in the `values-global.yaml` file in your fork. +. Commit and push the change. + +On {ocp}, both autoscalers have had only short test runs, on new clusters on AWS, each with one NVIDIA L4 GPU. Each autoscaler added a second vLLM replica or pod under load. A node with several GPUs, server pods on more than one node, and the two autoscalers together have not been tried. For the settings, the steps, and what has not been checked, see the link:https://github.com/eugo-inc/vllm-ray-inference-server#scale-out[Scale out] section of the pattern README. + +[id="next-steps-vllm-ray-customization"] +== Next steps + +* link:/patterns/vllm-ray-inference-server/cluster-sizing/[Cluster sizing] +* link:/patterns/vllm-ray-inference-server/troubleshooting/[Troubleshooting] diff --git a/content/patterns/vllm-ray-inference-server/partner-results.adoc b/content/patterns/vllm-ray-inference-server/partner-results.adoc new file mode 100644 index 000000000..e37571d69 --- /dev/null +++ b/content/patterns/vllm-ray-inference-server/partner-results.adoc @@ -0,0 +1,63 @@ +--- +title: "Partner results: Eugo" +weight: 60 +aliases: /vllm-ray-inference-server/partner-results/ +--- + +:toc: +:imagesdir: /images +:_content-type: ASSEMBLY +include::modules/comm-attributes.adoc[] +:vllm-ray-pattern: vLLM Ray Inference Server pattern + +[id="partner-results-vllm-ray"] +== Partner results: Eugo + +Eugo measured its next release build against the upstream `vllm/vllm-openai` v0.33.0 image, with Qwen2.5-0.5B-Instruct on one NVIDIA DGX Spark shared with other jobs, in Docker containers, not on {ocp}. The Eugo build runs a vLLM development snapshot taken after 0.33.0 branched off, plus Eugo's fixes. Every start was a new container with empty compile caches, with the model files already in memory and the image already on the machine. Both sides got the same settings apart from the attention setting that the table names. Some of those settings were not the defaults. Every run in the table gave vLLM 12% of GPU memory (vLLM's default is 92%, this pattern's 85%), because the NVIDIA DGX Spark's GPU shares its memory with the CPU and with those other jobs. In the rows that name `--safetensors-load-strategy eager`, both sides used it in place of vLLM's default weight loading. Each lead is the median of the differences over paired rounds. + +[cols="3,3,3,2",options="header"] +|=== +|Against upstream vLLM 0.33.0 |How the servers ran |Eugo sooner by (median) |Eugo sooner in + +|As shipped, with no attention setting on either side +|Plain `vllm serve`, both sides with `--safetensors-load-strategy eager`, to the first streamed token +|93.6 seconds (71%); median starts 131.3 seconds and 36.2 seconds, so upstream's took 3.6 times as long +|12 of 12 rounds + +|As shipped, with only the 12% GPU memory setting +|Plain `vllm serve`, both sides with vLLM's default weight loading, to the first streamed token +|169.5 seconds (77%); median starts 219.4 seconds and 48.4 seconds, so upstream's took 4.5 times as long +|12 of 12 rounds + +|As shipped +|This pattern's Ray Serve LLM server, both sides with vLLM's default weight loading, to the first answer +|159.8 seconds (70%). Upstream's engine was started again in 1 of its 17 launches (Eugo's in none), after vLLM's start-up memory check had stopped it; that launch, in round 1, is one the results count. +|8 of 8 rounds + +|Tuned with `--attention-backend FLASHINFER` and TRT-LLM attention turned off +|Plain `vllm serve`, both sides with `--safetensors-load-strategy eager`, to the first streamed token +|10.8 seconds (21%) +|12 of 12 rounds + +|Tuned with `--attention-backend TRITON_ATTN` +|Plain `vllm serve`, both sides with `--safetensors-load-strategy eager`, to the first streamed token +|14.1 seconds (28%) +|12 of 12 rounds + +|Tuned with `--attention-backend FLASHINFER` +|Plain `vllm serve`, both sides with `--safetensors-load-strategy eager`, to the first streamed token +|17.5 seconds (30%) +|12 of 12 rounds +|=== + +In the tuned runs, the vLLM start-up memory check stopped 2 of 36 upstream first tries and none of 12 Eugo first tries, too few to show a difference by Fisher's exact test. In the run with only the 12% GPU memory setting, every upstream and Eugo start succeeded on its first try (12 of 12 starts each). + +Against upstream as shipped, the time per output token was a tie, at one stream through this pattern's server, in a short check. Most of that time is set by the hardware: at one stream, each output token needs all of the model's weights, about 0.99 GB, read from memory, which at the NVIDIA DGX Spark's published memory bandwidth of 273 GB/s takes at least 3.6 ms of the measured 5.8 ms per token for both servers. The rest depends on the software and on how much of that bandwidth the GPU reaches; in this check both servers used FlashAttention-2 for attention. + +For the settings that each run used and what is not yet measured, see the link:https://github.com/eugo-inc/vllm-ray-inference-server#partner-results-eugo[Partner results: Eugo] section of the pattern README. + +[id="next-steps-vllm-ray-partner-results"] +== Next steps + +* link:/patterns/vllm-ray-inference-server/[{vllm-ray-pattern}] +* link:/patterns/vllm-ray-inference-server/getting-started/[Getting started] diff --git a/content/patterns/vllm-ray-inference-server/troubleshooting.adoc b/content/patterns/vllm-ray-inference-server/troubleshooting.adoc new file mode 100644 index 000000000..7e51b0c6d --- /dev/null +++ b/content/patterns/vllm-ray-inference-server/troubleshooting.adoc @@ -0,0 +1,192 @@ +--- +title: Troubleshooting +weight: 50 +aliases: /vllm-ray-inference-server/troubleshooting/ +--- + +:toc: +:imagesdir: /images +:_content-type: ASSEMBLY +include::modules/comm-attributes.adoc[] +:vllm-ray-pattern: vLLM Ray Inference Server pattern + +[id="troubleshooting-vllm-ray"] +== Troubleshooting the {vllm-ray-pattern} + +Use this page to diagnose common issues when you install or run the pattern. For more entries, see the Troubleshooting section of the link:https://github.com/eugo-inc/vllm-ray-inference-server/blob/main/AGENTS.md#troubleshooting[AGENTS.md file] in the pattern repository. + +[id="troubleshooting-gpu-operators-vllm-ray"] +=== The GPU Operators fail to install, or a second copy appears + +By default, the pattern installs the {rh-nfd} and the NVIDIA GPU Operator itself. On a cluster that already runs them, it adds a second copy of both Operators, with a second `OperatorGroup` object in their namespace, and it can write its own `Subscription` and `NodeFeatureDiscovery` objects over the cluster's objects where the names match. + +.Diagnosis + +. Check the Operator versions in the namespaces of the pattern's copies: ++ +[source,terminal] +---- +$ oc get csv -n openshift-nfd +$ oc get csv -n nvidia-gpu-operator +---- ++ +A `ClusterServiceVersion` object in the `Failed` phase with the reason `TooManyOperatorGroups` means that its namespace has two `OperatorGroup` objects. To see them, run `oc get operatorgroups -n openshift-nfd` and `oc get operatorgroups -n nvidia-gpu-operator`. This failure follows from how Operator Lifecycle Manager handles more than one `OperatorGroup` object in a namespace; it has not been reproduced on a test cluster. + +. List the Operator subscriptions on the cluster: ++ +[source,terminal] +---- +$ oc get subscriptions.operators.coreos.com -A | grep -E 'nfd|gpu-operator-certified' +---- ++ +One subscription for each Operator does not rule out the conflict, because the pattern can write its own `Subscription` object over the cluster's object. + +.Resolution + +* To prevent the conflict on a cluster that already runs both Operators, set `global.gpuOperators: reuse` in the `values-global.yaml` file in your fork before you install, and push the change. The pattern then uses the cluster's own Operators and does not change them. For what these Operators must provide, see link:https://github.com/eugo-inc/vllm-ray-inference-server#reuse-the-clusters-gpu-operators[Reuse the cluster's GPU operators] in the pattern README. The reuse setting has run on one test cluster so far. The pattern has not been tested on a cluster that runs {rhoai}. +* If the pattern is already installed with the default `install` setting and the second copy is running, the pattern has no tested way to remove that copy: +** Switching a running installation between `install` and `reuse` is not supported, and neither switch has been tried on a cluster. +** A switch to `reuse` is expected to leave the second copy in place, because {rh-gitops} does not delete the objects that a commit removes. +** A switch from `reuse` to `install` is expected to add a second copy of both Operators, because the `install` setting adds them. +** Uninstalling the pattern is not a tested way to remove the copy either. The uninstall is experimental and has not been tested on such a cluster. Where the pattern's copy shares a namespace with the cluster's Operator, the uninstall can delete that namespace with the cluster's Operator in it. +** To get help with an installation that already runs a second copy, open an issue in the link:https://github.com/eugo-inc/vllm-ray-inference-server/issues[pattern repository] with the output of the commands in the diagnosis, and describe your cluster and the Operators that it runs. + +[id="troubleshooting-install-timeout-vllm-ray"] +=== The installation command fails after about an hour + +The `./pattern.sh make install` command waits up to 60 minutes for every Argo CD application to report `Synced` and `Healthy`. A first installation can take longer, because the cluster builds a large server image, the GPU node joins the cluster, and the server downloads the model. When the wait times out, the pattern is already installed and its secrets are loaded. + +.Resolution + +. Check the image build and the server pod: ++ +[source,terminal] +---- +$ oc get builds -n vllm-inference +$ oc get pods -n vllm-inference +---- ++ +A server pod in the `Pending` state has no GPU yet. A server pod that is running but not ready is still loading the model. + +. If the build failed, read the build log, fix the cause, and start the build again: ++ +[source,terminal] +---- +$ oc logs -f bc/ray-serve-llm -n vllm-inference +$ oc start-build ray-serve-llm -n vllm-inference --follow +---- + +. When the build and the server pod finish, check the applications again: ++ +[source,terminal] +---- +$ ./pattern.sh make argo-healthcheck +---- + +To skip the wait on a later installation, run `VP_SKIP_ARGO_HEALTHCHECK=true ./pattern.sh make install`, and then run `./pattern.sh make argo-healthcheck` later. + +[id="troubleshooting-pending-gpu-vllm-ray"] +=== The server pod stays in the Pending state + +The server pod reports `Insufficient nvidia.com/gpu` when no node advertises the `nvidia.com/gpu` resource yet. The GPU node goes through the following chain: on AWS, the job creates the node; the node joins the cluster; the {rh-nfd} labels the node; and the NVIDIA GPU Operator installs the driver and the device plugin. The `ClusterPolicy` object of the NVIDIA GPU Operator must tolerate the `nvidia.com/gpu` taint. + +.Resolution + +. Check for GPU nodes, the NVIDIA GPU Operator pods, and the GPU resource of the node: ++ +[source,terminal,subs="+quotes"] +---- +$ oc get nodes -l nvidia.com/gpu.present=true +$ oc get pods -n nvidia-gpu-operator +$ oc describe node ____ | grep nvidia.com/gpu +---- + +. With `global.gpuOperators: reuse`, the `ClusterPolicy` object is the cluster's own. Check that the `oc get clusterpolicies` command shows it as `ready`, check its `spec.daemonsets.tolerations` field, and check that it offers the `nvidia.com/gpu` resource, not a `.shared` resource name or a MIG resource name, such as `nvidia.com/mig-1g.10gb`, which NVIDIA Multi-Instance GPU (MIG) uses for one part of a split GPU. The NVIDIA GPU Operator of the cluster can run in a namespace other than `nvidia-gpu-operator`. + +. If no GPU node joined on an AWS cluster that was installed into existing subnets, the job that creates the GPU node failed. On such a cluster, set `global.gpuMachineSet: none` in the `values-global.yaml` file in your fork, push the change, and add a GPU node yourself. + +[id="troubleshooting-build-registry-vllm-ray"] +=== The image build fails to push, or no build runs + +The cluster builds the server image and the notebook image itself, so the {ocp-registry} must be in the `Managed` state, and the `Build` cluster capability must be enabled. On bare metal and on vSphere, the registry starts in the `Removed` state, because there is no shared object storage. + +.Resolution + +* Give the registry storage, and set the registry to the `Managed` state. +* Alternatively, set `image.override` in both the server and the notebook Helm charts to prebuilt images that you host. The `image.override` setting has not been tested on a cluster. Without the internal registry, also set `oauthProxy.image` in the notebook Helm chart to a Red{nbsp}Hat image, such as `registry.redhat.io/openshift4/ose-oauth-proxy-rhel9:v4.19`, because the default proxy image is pulled through the internal registry. On a running installation, changing `image.override` needs extra steps. For the steps, see the link:https://github.com/eugo-inc/vllm-ray-inference-server/blob/main/AGENTS.md#troubleshooting[AGENTS.md file] in the pattern repository. + +[id="troubleshooting-no-rebuild-vllm-ray"] +=== The image does not change after a push, or the first build failed + +The rebuild job starts a new build only after a push changes the folder of the image, and it does not retry a failed build. + +.Resolution + +. Read the build log, and fix the cause: ++ +[source,terminal] +---- +$ oc logs -f bc/ray-serve-llm -n vllm-inference +---- + +. Start the build by hand: ++ +[source,terminal] +---- +$ oc start-build ray-serve-llm -n vllm-inference --follow +---- ++ +For the notebook image, run `oc start-build notebook -n vllm-notebook --follow`. + +[id="troubleshooting-vault-sealed-vllm-ray"] +=== The secret store reports that Vault is sealed + +Right after the installation, the `vault-backend` cluster secret store can report `Vault is sealed` (code 503) or a 403 error, and the `huggingface-secret` external secret can report that the store is not ready. The {eso-op} checks the store as soon as the store exists, and {hashicorp-vault-short} starts sealed. A job of the {solution-name-upstream} framework unseals {hashicorp-vault-short}, and the `./pattern.sh make install` command waits for that job, and then loads the secrets. Until then, the `openshift-external-secrets` and `ray-serve-llm` applications can show `Degraded`. + +.Resolution + +On a command-line installation, no action is needed. If the store is still not valid after 10 minutes, or the secret is still missing after 15 minutes, check the store and the jobs: + +[source,terminal] +---- +$ oc get clustersecretstore vault-backend +$ oc get jobs -n imperative +---- + +After a web console installation, the store turns valid by itself, but the `huggingface-secret` external secret stays not ready until you load the secrets with the `./pattern.sh make load-secrets` command. The web console installation has not been tested. + +[id="troubleshooting-gated-model-vllm-ray"] +=== A gated model fails to download with a 401 or 403 error + +The Hugging Face token is missing or not loaded. The server ignores a token that does not start with `hf_`. + +.Resolution + +. Put your Hugging Face token, which starts with `hf_`, in the secrets file. +. Load the secrets: ++ +[source,terminal] +---- +$ ./pattern.sh make load-secrets +---- +. Wait for the secret to refresh, and then delete the server pod: ++ +[source,terminal] +---- +$ oc delete pod -l app.kubernetes.io/name=ray-serve-llm -n vllm-inference +---- + +[id="troubleshooting-slow-start-vllm-ray"] +=== Every new server pod takes a long time to start + +vLLM and FlashInfer, a library of GPU kernels for inference that vLLM uses, compile GPU kernels, the functions that run on the GPU, when the server starts. By default, the compiled kernels are written to a temporary volume that is deleted with the pod, so every new server pod compiles them again. + +.Resolution + +To keep the compiled kernels for later pods, set `compileCache.mode` in the `charts/all/ray-serve-llm/values.yaml` file in your fork to `node`, for one GPU node, or to `shared`, for a storage class that offers the `ReadWriteMany` access mode, and push the change. The `node` and `shared` modes have not run on {ocp}. + +[id="next-steps-vllm-ray-troubleshooting"] +== Next steps + +* link:/patterns/vllm-ray-inference-server/getting-started/[Getting started] +* link:/patterns/vllm-ray-inference-server/cluster-sizing/[Cluster sizing] diff --git a/static/images/vllm-ray-inference-server/architecture.svg b/static/images/vllm-ray-inference-server/architecture.svg new file mode 100644 index 000000000..012e72bf3 --- /dev/null +++ b/static/images/vllm-ray-inference-server/architecture.svg @@ -0,0 +1 @@ +OpenShift clusterNamespacevllm-notebookNamespacevllm-inferenceGPU enablementSecretsGithftokenSecrethuggingface-secretmodel weights at/modelsOpenAI-compatible HTTPYour fork of this repositoryYou, in a browserValidated Patterns OperatorOpenShift GitOps: Argo CD instancevp-gitopsclustergroup app-of-apps, variant prodHashiCorp VaultExternal Secrets OperatorNode Feature DiscoveryNVIDIA GPU OperatorMachineSet job, AWS only: oneg6.2xlarge with one NVIDIA L4BuildConfig ray-serve-llmImageStream ray-serve-llmDeployment ray-serve-llm: Ray head +Ray Serve + vLLM, one GPUPVC ray-serve-llm-modelsService ray-serve-llm, port 8000BuildConfig and ImageStreamnotebookNotebook pod: JupyterLab +oauth-proxyRoute with OpenShift login \ No newline at end of file