The platform for continuously improving AI agents.
Enable vLLM sleep routes for dedicated snapshot engines. (#290)
Rohit Guptaac3d7ef369c5
diff --git a/overbae/modal/modal_vllm_worker.py b/overbae/modal/modal_vllm_worker.pyindex e60e6d9b..aa1c425c 100644--- a/overbae/modal/modal_vllm_worker.py+++ b/overbae/modal/modal_vllm_worker.py@@ -317,8 +317,10 @@ class _BaseVLLMWorker:# URL params in parametrized classes.full_path = f"{WEIGHTS_MOUNT}/{self.model_path}"- # Exception stacks to inference clients only outside prod.- _os.environ["VLLM_SERVER_DEV_MODE"] = "1" if self.snapshot_weights or not IS_PROD else "0"+ # /sleep and /wake_up exist only in dev mode, and a snapshot engine calls both.+ # Dev mode also returns exception stacks to clients.+ needs_dev_routes = self.snapshot_weights or getattr(self, "snapshot_engine", False)+ _os.environ["VLLM_SERVER_DEV_MODE"] = "1" if needs_dev_routes or not IS_PROD else "0"# A container's Volume mount is a point-in-time view, so weights RegisterAPIServer# commits after this container is scheduled stay invisible until reload(). Deploydiff --git a/tests/test_dedicated_lora_merge.py b/tests/test_dedicated_lora_merge.pyindex c796f96c..f654f32c 100644--- a/tests/test_dedicated_lora_merge.py+++ b/tests/test_dedicated_lora_merge.py@@ -1,7 +1,10 @@"""A dedicated LoRA boots on its own worker and folds one adapter at startup."""import importlib+import json+import osfrom types import SimpleNamespace+from unittest.mock import Mockimport pytest@@ -45,6 +48,33 @@ def test_dedicated_lora_uses_the_plain_worker_and_no_runtime_adapter():assert "adapter" not in sent+def test_prod_snapshot_engine_enables_the_sleep_route(monkeypatch, tmp_path):+ obj = serving._BaseVLLMWorker()+ obj.model_path = "base"+ obj._journal = Mock()+ obj.model_name = "dedicated/ft"+ obj.max_model_len = 512+ obj.enable_lora = False+ obj.max_lora_rank = 16+ obj.gpu_type = "A100-80GB"+ obj.snapshot_engine = True+ (tmp_path / "base").mkdir()+ monkeypatch.setattr(serving, "WEIGHTS_MOUNT", str(tmp_path))+ monkeypatch.setattr(serving, "weights_vol", Mock())+ monkeypatch.setattr(serving, "IS_PROD", True)+ monkeypatch.setattr(serving.subprocess, "Popen", Mock())+ monkeypatch.setattr(serving, "_wait_for_vllm", Mock())+ slept = Mock()+ monkeypatch.setattr(serving, "_vllm_control", slept)+ monkeypatch.setenv("VLLM_SERVER_DEV_MODE", "0")++ obj._startup_inner(_json=json, _os=os)++ assert os.environ["VLLM_SERVER_DEV_MODE"] == "1"+ assert "--enable-sleep-mode" in obj._serve_command+ slept.assert_called_once_with("/sleep?level=1")++def test_dedicated_worker_is_not_the_serverless_class():discovery = importlib.import_module("modal._partial_function")flags = discovery._PartialFunctionFlags