Skip to content

The platform for continuously improving AI agents.

Retry dedicated decision starts when the release rejects pool. (#293)

Rohit Guptaaf8f10e7c79d
diff --git a/.agents/skills/backend-architecture/references/serving.md b/.agents/skills/backend-architecture/references/serving.md
index 2657a946..92e32841 100644
--- a/.agents/skills/backend-architecture/references/serving.md
+++ b/.agents/skills/backend-architecture/references/serving.md
@@ -10,7 +10,7 @@
## Dedicated deployments
-A ready `DeployedModel` has at most one live `DedicatedDeployment` on the private `overmind-dedicated` app. The menu is every GPU at or above the memory floor, including H100 whenever A100-80GB fits. Serverless `select_gpu` still skips H100. Chat shapes are `lora_bf16` and `merged_fp8`. Decision models use `DecisionEndpoint` with a per-deployment `pool` and report latency only. Speed comes from `overbae/modal/serving_benchmarks.json` (one bench per base, shape, and GPU); a missing cell stays unmeasured. The hourly price is the live Modal GPU rate plus that worker's CPU and memory (100 credits = $1); a missing rate refuses start. `min_containers` is the replica floor, `scaledown_window` is the idle timeout, and scale-up is demand up to `max_containers` (at most 8). Chat vLLM stores the KV cache in FP8. The sequence cap is how many full-context sequences fit on that GPU, at most 32; a lower cap is also that container's Modal input target. The 15-second deployment controller meters whole minutes of running replicas at the snapshotted rate and stops the deployment when billing is on and the balance cannot cover the next minute. Zero replicas cost nothing. Stopping drains the runtime with a zero replica floor while retaining the saved GPU and scaling configuration for restart; the Console joins Configure GPU and Start/Stop, and MCP uses the same start/stop services. A dedicated LoRA is applied while `{gpu}_vllm_dedicated` reads the base shards. Those shards are symlinked into the serve directory, not copied. That name is separate from the serverless `{gpu}_vllm` global, because Modal loads the class by module attribute. That container sleeps the loaded engine and Modal snapshots it; later replicas of the same deployment wake the snapshot. A chat or decision request connects to the container the controller already scaled; it does not call `update_autoscaler` or reread the base manifest. Chat completions with `stream: true` use the worker's `infer_stream` and flush each server-sent event. `run_inference` and the inference-request job still wait for the finished reply, because a tool result has no open token stream. Gateway ids `dedicated/<trained model id>` skip `inference-ft-model` charges. The capability alias stays on the shared active model. The Console lists each model's current dedicated deployment and opens it on that model's inference page. MCP tools are `list_dedicated_gpus`, `start_dedicated_deployment`, `update_dedicated_deployment`, and `stop_dedicated_deployment`; `run_inference` accepts `dedicated/<trained model id>`. `seed_demo` does not create a live dedicated row.
+A ready `DeployedModel` has at most one live `DedicatedDeployment` on the private `overmind-dedicated` app. The menu is every GPU at or above the memory floor, including H100 whenever A100-80GB fits. Serverless `select_gpu` still skips H100. Chat shapes are `lora_bf16` and `merged_fp8`. Decision models use `DecisionEndpoint` and report latency only. A release that accepts `pool` isolates one deployment; a release published before that parameter shares one option set per artifact and GPU. Speed comes from `overbae/modal/serving_benchmarks.json` (one bench per base, shape, and GPU); a missing cell stays unmeasured. The hourly price is the live Modal GPU rate plus that worker's CPU and memory (100 credits = $1); a missing rate refuses start. `min_containers` is the replica floor, `scaledown_window` is the idle timeout, and scale-up is demand up to `max_containers` (at most 8). Chat vLLM stores the KV cache in FP8. The sequence cap is how many full-context sequences fit on that GPU, at most 32; a lower cap is also that container's Modal input target. The 15-second deployment controller meters whole minutes of running replicas at the snapshotted rate and stops the deployment when billing is on and the balance cannot cover the next minute. Zero replicas cost nothing. Stopping drains the runtime with a zero replica floor while retaining the saved GPU and scaling configuration for restart; the Console joins Configure GPU and Start/Stop, and MCP uses the same start/stop services. A dedicated LoRA is applied while `{gpu}_vllm_dedicated` reads the base shards. Those shards are symlinked into the serve directory, not copied. That name is separate from the serverless `{gpu}_vllm` global, because Modal loads the class by module attribute. That container sleeps the loaded engine and Modal snapshots it; later replicas of the same deployment wake the snapshot. A chat or decision request connects to the container the controller already scaled; it does not call `update_autoscaler` or reread the base manifest. Chat completions with `stream: true` use the worker's `infer_stream` and flush each server-sent event. `run_inference` and the inference-request job still wait for the finished reply, because a tool result has no open token stream. Gateway ids `dedicated/<trained model id>` skip `inference-ft-model` charges. The capability alias stays on the shared active model. The Console lists each model's current dedicated deployment and opens it on that model's inference page. MCP tools are `list_dedicated_gpus`, `start_dedicated_deployment`, `update_dedicated_deployment`, and `stop_dedicated_deployment`; `run_inference` accepts `dedicated/<trained model id>`. `seed_demo` does not create a live dedicated row.
## Workers
diff --git a/overbae/services/dedicated.py b/overbae/services/dedicated.py
index ca6b10c7..26661a8f 100644
--- a/overbae/services/dedicated.py
+++ b/overbae/services/dedicated.py
@@ -370,7 +370,7 @@ def serve_decision(row: DedicatedDeployment, decisions: list) -> dict:
raise InputValidationError("This dedicated deployment is a chat model.")
if row.status != DedicatedDeployment.Status.ONLINE:
raise InputValidationError(NOT_ONLINE)
- return dedicated_runtime.predict(dedicated_runtime.connect(row), decisions)
+ return dedicated_runtime.predict(dedicated_runtime.connect(row), decisions, row)
def complete_request(payload: dict) -> dict:
diff --git a/overbae/services/dedicated_runtime.py b/overbae/services/dedicated_runtime.py
index b05d9123..f20dd49f 100644
--- a/overbae/services/dedicated_runtime.py
+++ b/overbae/services/dedicated_runtime.py
@@ -23,6 +23,9 @@ WORKER_UNAVAILABLE = "Dedicated worker is not deployed."
# min, max, and idle through update_autoscaler, or a GPU change leaves the old set running.
_STABLE_MAX = 8
_STABLE_WINDOW = 3600
+# Releases published before the pool parameter reject the name. Those dedicated
+# starts share one option set per artifact and GPU.
+_unpooled_apps: set[str] = set()
def environment() -> str:
@@ -46,15 +49,34 @@ def worker_class_name(_deployed, gpu_type: str) -> str:
return f"{token}_vllm_dedicated"
+def _app_name(deployed) -> str:
+ runtime = deployed.serving_runtime if isinstance(deployed.serving_runtime, dict) else {}
+ return str(runtime.get("app") or "")
+
+
+def _pool_rejected(exc: BaseException) -> bool:
+ text = str(exc)
+ return "pool" in text and "not defined" in text
+
+
+def _drop_pool(deployment, exc: BaseException) -> bool:
+ if deployment.deployed_model.inference_contract != "decision" or not _pool_rejected(exc):
+ return False
+ _unpooled_apps.add(_app_name(deployment.deployed_model))
+ return True
+
+
def parameters(deployment) -> dict:
deployed = deployment.deployed_model
if deployed.inference_contract == "decision":
- return {
+ params = {
"weights_path": deployed.weights_path,
"artifact_identity": deployed.checkpoint_hash,
"max_model_len": deployed.max_model_len,
- "pool": str(deployment.id),
}
+ if _app_name(deployed) not in _unpooled_apps:
+ params["pool"] = str(deployment.id)
+ return params
path = rel_weights_path(deployed.weights_path)
params = {
"model_path": path,
@@ -110,7 +132,7 @@ def _variant(cls, deployment, *, maximum: int, idle_seconds: int):
return cls
-def _scale(cls, deployment, *, minimum: int, maximum: int, idle_seconds: int):
+def _scale_once(cls, deployment, *, minimum: int, maximum: int, idle_seconds: int):
instance = cls(**parameters(deployment))
method = getattr(instance, "update_autoscaler", None)
if method is not None:
@@ -124,6 +146,19 @@ def _scale(cls, deployment, *, minimum: int, maximum: int, idle_seconds: int):
return instance
+def _scale(cls, deployment, *, minimum: int, maximum: int, idle_seconds: int):
+ try:
+ return _scale_once(
+ cls, deployment, minimum=minimum, maximum=maximum, idle_seconds=idle_seconds
+ )
+ except Exception as exc:
+ if not _drop_pool(deployment, exc):
+ raise
+ return _scale_once(
+ cls, deployment, minimum=minimum, maximum=maximum, idle_seconds=idle_seconds
+ )
+
+
def release(deployment, gpu_type: str) -> None:
"""Drop every autoscaler variant for one GPU class."""
deployed = deployment.deployed_model
@@ -383,12 +418,21 @@ def iter_chat_stream(instance, deployment, body: bytes):
close()
-def predict(instance, decisions: list) -> dict:
+def _read_prediction(instance, decisions: list) -> dict:
result = instance.predict.remote(decisions)
if not isinstance(result, dict) or result.get("error_code"):
raise InputValidationError(WORKER_UNAVAILABLE)
return result
+def predict(instance, decisions: list, deployment=None) -> dict:
+ try:
+ return _read_prediction(instance, decisions)
+ except Exception as exc:
+ if deployment is None or not _drop_pool(deployment, exc):
+ raise
+ return _read_prediction(connect(deployment), decisions)
+
+
def minute_usd(rate: Decimal, replicas: int) -> Decimal:
return (rate * Decimal(replicas)) / Decimal(60)
diff --git a/tests/test_dedicated_lora_merge.py b/tests/test_dedicated_lora_merge.py
index f654f32c..3cf0d278 100644
--- a/tests/test_dedicated_lora_merge.py
+++ b/tests/test_dedicated_lora_merge.py
@@ -9,6 +9,7 @@ from unittest.mock import Mock
import pytest
from overbae.modal import modal_vllm_worker as serving
+from overbae.services import dedicated_runtime
from overbae.services.dedicated_runtime import chat, parameters, worker_class_name
pytestmark = pytest.mark.covers("model-runtime")
@@ -88,3 +89,79 @@ def test_dedicated_worker_is_not_the_serverless_class():
find = discovery._find_partial_methods_for_user_cls
assert set(find(dedicated, flags.ENTER_PRE_SNAPSHOT)) == {"startup"}
assert set(find(dedicated, flags.ENTER_POST_SNAPSHOT)) == {"wake"}
+
+
+def _decision(app="overmind-decision-serve-old"):
+ return SimpleNamespace(
+ id="dep-1",
+ gpu_type="A100-80GB",
+ max_replicas=1,
+ idle_shutdown_seconds=900,
+ deployed_model=SimpleNamespace(
+ inference_contract="decision",
+ serving_runtime={"app": app, "environment": "overmind-prod"},
+ weights_path="/weights/.decisions/abc",
+ checkpoint_hash="abc",
+ max_model_len=4096,
+ ),
+ )
+
+
+def test_older_decision_release_scales_without_pool(monkeypatch):
+ dedicated_runtime._unpooled_apps.clear()
+ seen = []
+
+ class Endpoint:
+ def __init__(self, **kwargs):
+ seen.append(kwargs)
+ self.kwargs = kwargs
+
+ def update_autoscaler(self, **_kwargs):
+ if "pool" in self.kwargs:
+ raise RuntimeError(
+ "parameter names were provided but are not defined "
+ "class modal.parameters for the class: pool"
+ )
+
+ class Remote:
+ def with_options(self, **_kwargs):
+ return Endpoint
+
+ monkeypatch.setattr(dedicated_runtime.modal.Cls, "from_name", lambda *_a, **_k: Remote())
+ dedicated_runtime.bind(_decision(), minimum=1, maximum=1, idle_seconds=900)
+ assert "pool" in seen[0]
+ assert "pool" not in seen[1]
+ dedicated_runtime._unpooled_apps.clear()
+
+
+def test_decision_predict_retries_when_the_release_rejects_pool(monkeypatch):
+ dedicated_runtime._unpooled_apps.clear()
+ deployment = _decision("overmind-decision-serve-other")
+ calls = []
+
+ class Instance:
+ def __init__(self, **kwargs):
+ self.kwargs = kwargs
+
+ class Predict:
+ def remote(self, _decisions):
+ calls.append(kwargs)
+ if "pool" in kwargs:
+ raise RuntimeError(
+ "parameter names were provided but are not defined "
+ "class modal.parameters for the class: pool"
+ )
+ return {"predictions": [{"key": "0"}]}
+
+ self.predict = Predict()
+
+ monkeypatch.setattr(
+ dedicated_runtime,
+ "connect",
+ lambda row: Instance(**dedicated_runtime.parameters(row)),
+ )
+ result = dedicated_runtime.predict(Instance(**parameters(deployment)), [], deployment)
+ assert result["predictions"] == [{"key": "0"}]
+ assert "pool" in calls[0]
+ assert "pool" not in calls[1]
+ dedicated_runtime._unpooled_apps.clear()