|
| 1 | +# Dynamic LORA Adapter Sidecar for vLLM |
| 2 | + |
| 3 | +This is a sidecar-based tool to help rolling out new LoRA adapters to a set of running vLLM model servers. The user deploys the sidecar with a vLLM server, and using a ConfigMap, the user can express their intent as to which LoRA adapters they want to have the running vLLM servers to be configure with. The sidecar watches the ConfigMap and sends load/unload requests to the vLLM container to actuate on the user intent. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The sidecar continuously monitors a ConfigMap mounted as a YAML configuration file. This file defines the desired state of LORA adapters, including: |
| 8 | + |
| 9 | +- **Adapter ID:** Unique identifier for the adapter. |
| 10 | +- **Source:** Path to the adapter's source files. |
| 11 | +- **Base Model:** The base model to which the adapter should be applied. |
| 12 | +- **toRemove:** (Optional) Indicates whether the adapter should be unloaded. |
| 13 | + |
| 14 | +The sidecar uses the vLLM server's API to load or unload adapters based on the configuration. It also periodically reconciles the registered adapters on the vLLM server with the desired state defined in the ConfigMap, ensuring consistency. |
| 15 | + |
| 16 | +## Features |
| 17 | + |
| 18 | +- **Dynamic Loading and Unloading:** Load and unload LORA adapters without restarting the vLLM server. |
| 19 | +- **Continuous Reconciliation:** Ensures the vLLM server's state matches the desired configuration. |
| 20 | +- **ConfigMap Integration:** Leverages Kubernetes ConfigMaps for easy configuration management. |
| 21 | +- **Easy Deployment:** Provides a sample deployment YAML for quick setup. |
| 22 | + |
| 23 | +## Repository Contents |
| 24 | + |
| 25 | +- **`sidecar.py`:** Python script for the sidecar container. |
| 26 | +- **`Dockerfile`:** Dockerfile to build the sidecar image. |
| 27 | +- **`configmap.yaml`:** Example ConfigMap YAML file. |
| 28 | +- **`deployment.yaml`:** Example Kubernetes deployment YAML. |
| 29 | + |
| 30 | +## Usage |
| 31 | + |
| 32 | +1. **Build the Docker Image:** |
| 33 | + ```bash |
| 34 | + docker build -t <your-image-name> . |
| 35 | +2. **Create a configmap:** |
| 36 | + ```bash |
| 37 | + kubectl create configmap name-of-your-configmap --from-file=your-file.yaml |
| 38 | +3. **Mount the configmap and configure sidecar in your pod** |
| 39 | + ```yaml |
| 40 | + volumeMounts: # DO NOT USE subPath |
| 41 | + - name: config-volume |
| 42 | + mountPath: /config |
| 43 | + ``` |
| 44 | + Do not use subPath, since configmap updates are not reflected in the file |
| 45 | + |
| 46 | +[deployment]: deployment.yaml it uses [sidecar](https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/)(`initContainer` with `restartPolicy` set to `always`) which is beta feature enabled by default since k8s version 1.29. They need to be enabled in 1.28 and prior to 1.28 sidecar are not officially supported. |
| 47 | + |
| 48 | +## Configuration Fields |
| 49 | +- `vLLMLoRAConfig`[**required**] base key |
| 50 | +- `host` [*optional*]Model server's host. defaults to localhost |
| 51 | +- `port` [*optional*] Model server's port. defaults to 8000 |
| 52 | +- `name`[*optional*] Name of this config |
| 53 | +- `ensureExist`[*optional*] List of models to ensure existence on specified model server. |
| 54 | + - `models`[**required**] [list] |
| 55 | + - `base-model`[*optional*] Base model for lora adapter |
| 56 | + - `id`[**required**] unique id of lora adapter |
| 57 | + - `source`[**required**] path (remote or local) to lora adapter |
| 58 | +- `ensureNotExist` [*optional*] |
| 59 | + - `models`[**required**] [list] |
| 60 | + - `id`[**required**] unique id of lora adapter |
| 61 | + - `source`[**required**] path (remote or local) to lora adapter |
| 62 | + - `base-model`[*optional*] Base model for lora adapter |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +## Screenshots & Testing |
| 68 | +The sidecar was tested with the Deployment and ConfigMap specified in this repo. Here are screen grabs of the logs from the sidecar and vllm server. One can verify that the adapters were loaded by querying `v1/models` and looking at vllm logs. |
| 69 | + |
| 70 | + |
| 71 | + |
0 commit comments