From ebbac3e476a7168fd2991640ecf8ffe4c8fb39d6 Mon Sep 17 00:00:00 2001 From: Tai An Date: Sat, 11 Jul 2026 18:20:07 -0700 Subject: [PATCH] feat(operator): support shmSize on VLLMRuntime for tensor parallelism The VLLMRuntime CRD had no way to enlarge /dev/shm, so tensor-parallel vLLM pods were stuck with the container default (typically 64Mi), which is too small for the shared-memory IPC that TP uses. The Helm chart can work around this with extra volumes, but the operator could not. Add a DeploymentConfig.shmSize field. When set, the controller mounts an emptyDir with medium=Memory at /dev/shm sized to the given quantity (e.g. "24Gi"); an unparseable value still yields a Memory-backed /dev/shm without a size limit rather than crashing the reconcile. Fixes #899 Signed-off-by: Tai An --- operator/api/v1alpha1/vllmruntime_types.go | 7 +++++++ .../production-stack.vllm.ai_vllmruntimes.yaml | 7 +++++++ .../controller/vllmruntime_controller.go | 17 +++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/operator/api/v1alpha1/vllmruntime_types.go b/operator/api/v1alpha1/vllmruntime_types.go index 94910a1c4..7dbaa88a1 100644 --- a/operator/api/v1alpha1/vllmruntime_types.go +++ b/operator/api/v1alpha1/vllmruntime_types.go @@ -45,6 +45,13 @@ type DeploymentConfig struct { // +kubebuilder:default=nvidia RuntimeClass string `json:"runtimeClass,omitempty"` + // ShmSize, when set, mounts an emptyDir with medium=Memory at /dev/shm + // sized to this value (e.g. "24Gi"). Tensor parallelism uses shared + // memory for inter-process communication and the container default + // /dev/shm (typically 64Mi) is too small. Accepts any Kubernetes quantity. + // +optional + ShmSize string `json:"shmSize,omitempty"` + // Resource requirements Resources ResourceRequirements `json:"resources"` diff --git a/operator/config/crd/bases/production-stack.vllm.ai_vllmruntimes.yaml b/operator/config/crd/bases/production-stack.vllm.ai_vllmruntimes.yaml index cabb854a4..0b8e6d7d7 100644 --- a/operator/config/crd/bases/production-stack.vllm.ai_vllmruntimes.yaml +++ b/operator/config/crd/bases/production-stack.vllm.ai_vllmruntimes.yaml @@ -283,6 +283,13 @@ spec: default: nvidia description: RuntimeClass type: string + shmSize: + description: |- + ShmSize, when set, mounts an emptyDir with medium=Memory at /dev/shm + sized to this value (e.g. "24Gi"). Tensor parallelism uses shared + memory for inter-process communication and the container default + /dev/shm (typically 64Mi) is too small. Accepts any Kubernetes quantity. + type: string sidecarConfig: description: Sidecar configuration properties: diff --git a/operator/internal/controller/vllmruntime_controller.go b/operator/internal/controller/vllmruntime_controller.go index 3dd8e470b..e662c5442 100644 --- a/operator/internal/controller/vllmruntime_controller.go +++ b/operator/internal/controller/vllmruntime_controller.go @@ -738,6 +738,23 @@ func (r *VLLMRuntimeReconciler) deploymentForVLLMRuntime( }) } + // Mount an emptyDir (medium=Memory) at /dev/shm when a size is requested. + // Tensor parallelism communicates over shared memory, and the container + // default /dev/shm is usually too small for it. + if vllmRuntime.Spec.DeploymentConfig.ShmSize != "" { + shmSource := corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{Medium: corev1.StorageMediumMemory}, + } + if q, err := resource.ParseQuantity(vllmRuntime.Spec.DeploymentConfig.ShmSize); err == nil { + shmSource.EmptyDir.SizeLimit = &q + } + volumes = append(volumes, corev1.Volume{Name: "dshm", VolumeSource: shmSource}) + volumeMounts = append(volumeMounts, corev1.VolumeMount{ + Name: "dshm", + MountPath: "/dev/shm", + }) + } + var affinity *corev1.Affinity if vllmRuntime.Spec.DeploymentConfig.NodeSelectorTerms != nil {