The platform for continuously improving AI agents.
Add Kev decision models for training and serving (#343)
Rohit Guptac6cfd4eba6ae
diff --git a/.agents/skills/backend-architecture/references/training.md b/.agents/skills/backend-architecture/references/training.mdindex b2d9a9a5..897dd33f 100644--- a/.agents/skills/backend-architecture/references/training.md+++ b/.agents/skills/backend-architecture/references/training.md@@ -46,7 +46,7 @@ The no-progress observer compares native stage, completed work, attempt and chec- A train cell may carry a `decision` object instead of messages. `modal_shared/decisions.py` validates state, question, kind, options, full target distributions and positive weights. Targets never enter the encoder (`modal_shared/decision_encoding.py`); oversized inputs fail without truncation.- The separately pinned decision image supplies Unsloth `FastDecisionModel`, `DecisionTrainer` and the Clef joint head. The measured contract selects distribution cross entropy or mixed distribution and ordinal-mean supervision. It never invents a distribution from a mean or turns soft labels into argmax text.-- The catalogue lists Clef, D3 and D1. Only Clef launches; D3 and D1 stay disabled until their preparation, checkpoint and serving runtimes pass the same checks. The supported method is one-GPU Modal LoRA.+- The catalogue lists Clef, Kev, D3 and D1. Clef and Kev launch; D3 and D1 stay disabled until their preparation, checkpoint and serving runtimes pass the same checks. Clef trains on the Unsloth decision image and serves through vLLM. Kev trains with `kev.train` on its own image and serves through SGLang 0.5.23. The supported method is one-GPU Modal LoRA.- Artifacts hold the adapter, full-precision head, upstream head and config files, tokenizer and `decision.json`. Checkpoints publish only after exact tensor reload and a nonempty probability check.- `hyperparameters.pre_training_baseline` defaults to true; false skips only the starting-model development evaluation, and telemetry records `not_requested`.- Decision checkpoints use typed probabilities and never enter chat evaluation or deployment.diff --git a/.agents/skills/finetuning-model-onboarding/SKILL.md b/.agents/skills/finetuning-model-onboarding/SKILL.mdindex 447531c1..96a18533 100644--- a/.agents/skills/finetuning-model-onboarding/SKILL.md+++ b/.agents/skills/finetuning-model-onboarding/SKILL.md@@ -5,7 +5,7 @@ description: Rules for adding a new model or model family to the finetuning pipe# Finetuning model onboarding-All finetuning runs on Modal with Unsloth (`overbae/services/sft_assets/engine_unsloth.py`). Every chat model and family goes through the same engine — the rules below exist to keep it that way. Decision families (Clef, D3, D1) run `sft_assets/decision_engine.py` instead.+All finetuning runs on Modal with Unsloth (`overbae/services/sft_assets/engine_unsloth.py`). Every chat model and family goes through the same engine — the rules below exist to keep it that way. Clef, D3 and D1 run `sft_assets/decision_engine.py`. Kev runs `sft_assets/kev_engine.py`.## 1. Never branch on model/family in the shared scriptdiff --git a/frontend/src/components/model-provider-chip.tsx b/frontend/src/components/model-provider-chip.tsxindex 638654e5..45388e48 100644--- a/frontend/src/components/model-provider-chip.tsx+++ b/frontend/src/components/model-provider-chip.tsx@@ -44,6 +44,24 @@ export { getModelProviderInfo } from "@/components/model-provider";type ProviderIcon = React.ComponentType<{ className?: string; size?: number | string }>;+/** @lobehub/icons ships no Jared Palmer mark. */+function JaredPalmer({ className, size = "1em" }: { className?: string; size?: number | string }) {+ return (+ <svg+ aria-hidden+ className={className}+ data-testid="logo-jaredpalmer"+ fill="currentColor"+ height={size}+ viewBox="0 0 24 24"+ width={size}+ xmlns="http://www.w3.org/2000/svg"+ >+ <path d="M5 4h2.2l4.8 7.4L16.8 4H19l-6.2 9.2V20h-2.2v-6.8L5 4Z" />+ </svg>+ );+}+/** @lobehub/icons ships no TypeSafe mark. */function TypeSafe({ className, size = "1em" }: { className?: string; size?: number | string }) {return (@@ -81,6 +99,7 @@ const PROVIDER_ICONS: Record<Exclude<ProviderId, "unknown">, ProviderIcon> = {google: Gemini,inception: Inception,inflection: Inflection,+ jaredpalmer: JaredPalmer,kimi: Kimi,liquid: Liquid,meta: Meta,diff --git a/frontend/src/components/model-provider.test.ts b/frontend/src/components/model-provider.test.tsindex 7028f9d5..794e03e1 100644--- a/frontend/src/components/model-provider.test.ts+++ b/frontend/src/components/model-provider.test.ts@@ -15,6 +15,7 @@ describe("getModelProviderInfo", () => {expect(getModelProviderInfo("mixtral-8x7b").id).toBe("mistral");expect(getModelProviderInfo("qwen3.5-0.8b").id).toBe("qwen");expect(getModelProviderInfo("jev-1.13").id).toBe("typesafe");+ expect(getModelProviderInfo("kev-0.8b").id).toBe("jaredpalmer");expect(getModelProviderInfo("grok-4").id).toBe("xai");expect(getModelProviderInfo("command-r").id).toBe("cohere");expect(getModelProviderInfo("glm-5.2").id).toBe("zhipu");@@ -48,6 +49,8 @@ describe("getModelProviderInfo", () => {expect(getModelProviderInfo("bytedance-seed/seed-2.0-lite").id).toBe("bytedance");expect(getModelProviderInfo("nousresearch/hermes-4-70b").id).toBe("nous");expect(getModelProviderInfo("tencent/hunyuan-a13b-instruct").id).toBe("tencent");+ expect(getModelProviderInfo("jaredpalmer/kev-0.8b").id).toBe("jaredpalmer");+ expect(getModelProviderInfo("jaredpalmer/kev-0.8b").providerLabel).toBe("Jared Palmer");expect(getModelProviderInfo("typesafe/jev-1.13").id).toBe("typesafe");expect(getModelProviderInfo("typesafe/jev-1.13").providerLabel).toBe("TypeSafe");expect(getModelProviderInfo("stepfun/step-3.5-flash").id).toBe("stepfun");diff --git a/frontend/src/components/model-provider.ts b/frontend/src/components/model-provider.tsindex 818947b7..13457dec 100644--- a/frontend/src/components/model-provider.ts+++ b/frontend/src/components/model-provider.ts@@ -15,6 +15,7 @@ export type ProviderId =| "google"| "inception"| "inflection"+ | "jaredpalmer"| "kimi"| "liquid"| "meta"@@ -99,6 +100,7 @@ const PROVIDER_BY_SLUG: Record<Exclude<ProviderId, "unknown">, ProviderBundle> =google: { id: "google", providerLabel: "Gemini", providerSlug: "google" },inception: { id: "inception", providerLabel: "Inception", providerSlug: "inception" },inflection: { id: "inflection", providerLabel: "Inflection", providerSlug: "inflection" },+ jaredpalmer: { id: "jaredpalmer", providerLabel: "Jared Palmer", providerSlug: "jaredpalmer" },kimi: { id: "kimi", providerLabel: "Kimi", providerSlug: "moonshotai" },liquid: { id: "liquid", providerLabel: "Liquid", providerSlug: "liquid" },meta: { id: "meta", providerLabel: "Meta", providerSlug: "meta" },@@ -213,6 +215,10 @@ function inferProviderFromModelId(modelId: string): ProviderBundle | null {return PROVIDER_BY_SLUG.typesafe;}+ if (normalized === "kev" || normalized.startsWith("kev-")) {+ return PROVIDER_BY_SLUG.jaredpalmer;+ }+if (normalized.startsWith("grok-")) {return PROVIDER_BY_SLUG.xai;}diff --git a/frontend/src/openapi/models/FamilyEnum.ts b/frontend/src/openapi/models/FamilyEnum.tsindex cb8d7de6..eb9fc409 100644--- a/frontend/src/openapi/models/FamilyEnum.ts+++ b/frontend/src/openapi/models/FamilyEnum.ts@@ -17,12 +17,14 @@* * `clef` - clef* * `d3` - d3* * `d1` - d1+ * * `kev` - kev* @export*/export const FamilyEnum = {clef: 'clef',d3: 'd3',- d1: 'd1'+ d1: 'd1',+ kev: 'kev'} as const;export type FamilyEnum = typeof FamilyEnum[keyof typeof FamilyEnum];diff --git a/modal_shared/decision_artifact.py b/modal_shared/decision_artifact.pyindex d40e303f..870fc528 100644--- a/modal_shared/decision_artifact.py+++ b/modal_shared/decision_artifact.py@@ -30,12 +30,15 @@ def inventory(directory):):raise ValueError("Decision artifact has no adapter weights")contract = json.loads((directory / "decision.json").read_text())+ renderer = contract.get("renderer")if (- contract.get("renderer") == "unsloth_clef"+ renderer == "unsloth_clef"and not {"joint_head.safetensors", "joint_head_config.json", "unsloth_decision_config.json"}<= files.keys()):raise ValueError("Decision artifact is missing its trained head or configuration")+ if renderer == "kev_pointer" and "head.pt" not in files:+ raise ValueError("Kev artifact is missing head.pt")return filesdiff --git a/modal_shared/images/serve.py b/modal_shared/images/serve.pyindex 99789cb1..f7ea91da 100644--- a/modal_shared/images/serve.py+++ b/modal_shared/images/serve.py@@ -5,7 +5,7 @@ from __future__ import annotationsimport modalfrom modal_shared.images import attach_modelfam, attach_serving_args-from modal_shared.stacks import SERVE_SGLANG, SERVE_SGLANG_LFM3, SERVE_VLLM+from modal_shared.stacks import SERVE_SGLANG, SERVE_SGLANG_KEV, SERVE_SGLANG_LFM3, SERVE_VLLM_SERVE_ENV = {# Container-local. Serving resolves every model by path — a merged checkpoint, or an adapter@@ -68,6 +68,14 @@ dedicated_sglang_image = attach_serving_args(.entrypoint([]).pip_install("runai-model-streamer>=0.15.7"))+dedicated_sglang_kev_image = attach_serving_args(+ modal.Image.from_registry(+ "lmsysorg/sglang:v0.5.23",+ setup_dockerfile_commands=["RUN ln -sf $(command -v python3) /usr/local/bin/python"],+ )+ .entrypoint([])+ .pip_install("runai-model-streamer==0.16.1")+)# LFM3 conv layers are absent from v0.5.22 and from vLLM 0.33. Support is the# untagged image built from sgl-project/sglang#46858. Do not point other models here.dedicated_sglang_lfm3_image = attach_serving_args(@@ -83,6 +91,7 @@ SERVE_IMAGES: dict[str, modal.Image] = {SERVE_VLLM: vllm_image,SERVE_SGLANG: dedicated_sglang_image,SERVE_SGLANG_LFM3: dedicated_sglang_lfm3_image,+ SERVE_SGLANG_KEV: dedicated_sglang_kev_image,}# The snapshot reader uses a version-specific pinned-buffer allocation site.diff --git a/modal_shared/images/train.py b/modal_shared/images/train.pyindex 5c3a5693..c27675d8 100644--- a/modal_shared/images/train.py+++ b/modal_shared/images/train.py@@ -9,7 +9,9 @@ import modalfrom modal_shared.images import attach_modelfam, attach_sft_assetsfrom modal_shared.stacks import (+ KEV_REV,TRAIN_DECISION,+ TRAIN_KEV,TRAIN_U2026_7,TRAIN_U2026_8_18,TRAIN_U2026_8_GPOS,@@ -281,8 +283,39 @@ _decision = _finish(},)+_kev = _finish(+ _base_cuda.pip_install(+ "torch==2.8.0",+ index_url="https://download.pytorch.org/whl/cu128",+ )+ .pip_install(+ "transformers==5.17.0",+ "peft==0.22.0",+ "accelerate==1.16.0",+ "datasets==5.2.0",+ "pydantic==2.14.4",+ "safetensors==0.8.0",+ "sentencepiece==0.2.3",+ "protobuf==7.36.2",+ "huggingface_hub==1.33.0",+ "einops==0.8.2",+ # The image is Python 3.11. NumPy 2.5 requires 3.12.+ "numpy==2.4.6",+ )+ .run_commands(+ "git clone https://github.com/jaredpalmer/kev.git /opt/kev"+ f" && git -C /opt/kev checkout {KEV_REV}"+ ),+ {+ **_SFT_ENV,+ "UNSLOTH_IMAGE": TRAIN_KEV,+ "PYTHONPATH": "/opt/kev",+ },+)+TRAIN_IMAGES: dict[str, modal.Image] = {TRAIN_DECISION: _decision,+ TRAIN_KEV: _kev,TRAIN_U2026_7: _u2026_7,TRAIN_U2026_8_TF510: _u2026_8_tf510,TRAIN_U2026_8_TF515: _u2026_8_tf515,diff --git a/modal_shared/kev_bases.py b/modal_shared/kev_bases.pynew file mode 100644index 00000000..5f434196--- /dev/null+++ b/modal_shared/kev_bases.py@@ -0,0 +1,16 @@+"""Released Kev checkpoints and the Qwen bases their heads were trained on."""++BASES = {+ "jaredpalmer/kev-0.8b": (+ "Qwen/Qwen3.5-0.8B-Base",+ "dc7cdfe2ee4154fa7e30f5b51ca41bfa40174e68",+ ),+ "jaredpalmer/kev-4b": (+ "Qwen/Qwen3.5-4B-Base",+ "1001bb4d826a52d1f399e183466143f4da7b741b",+ ),+ "jaredpalmer/kev-9b": (+ "Qwen/Qwen3.5-9B-Base",+ "68c46c4b3498877f3ef123c856ecfde50c39f404",+ ),+}diff --git a/modal_shared/modelfam/families.py b/modal_shared/modelfam/families.pyindex 28129d3c..b85d2834 100644--- a/modal_shared/modelfam/families.py+++ b/modal_shared/modelfam/families.py@@ -4,7 +4,9 @@ from __future__ import annotationsfrom modal_shared.modelfam.spec import FamilySpecfrom modal_shared.stacks import (+ SERVE_SGLANG_KEV,TRAIN_DECISION,+ TRAIN_KEV,TRAIN_U2026_8_GPOS,TRAIN_U2026_8_TF510,TRAIN_U2026_8_TF515,@@ -12,6 +14,14 @@ from modal_shared.stacks import (TRAIN_U2026_10_7,)+KEV = FamilySpec(+ key="kev",+ patterns=("jaredpalmer/kev-",),+ train_image=TRAIN_KEV,+ serve_image=SERVE_SGLANG_KEV,+ notes="Pointer head. Trains with kev.train and serves on SGLang 0.5.23.",+)+CLEF = FamilySpec(key="clef",patterns=(diff --git a/modal_shared/modelfam/registry.py b/modal_shared/modelfam/registry.pyindex fd1dc923..b1b1ed27 100644--- a/modal_shared/modelfam/registry.py+++ b/modal_shared/modelfam/registry.py@@ -13,6 +13,7 @@ from modal_shared.modelfam.families import (DEFAULT,GEMMA4,GPT_OSS,+ KEV,LFM2,LFM3,LLAMA,@@ -33,6 +34,7 @@ from modal_shared.modelfam.spec import FamilySpec# Order is load-bearing — specific before general (qwen35/coder before qwen_mm before qwen)._FAMILIES: tuple[FamilySpec, ...] = (+ KEV,CLEF,D3,D1,diff --git a/modal_shared/serving/decision_http.py b/modal_shared/serving/decision_http.pyindex 7ef86132..281754a6 100644--- a/modal_shared/serving/decision_http.py+++ b/modal_shared/serving/decision_http.py@@ -53,6 +53,22 @@ def decision_vllm_command(]+def decision_sglang_command(*, model_path: str, max_model_len: int, port: int = 8000) -> list[str]:+ """SGLang 0.5.23 loads a Kev pointer head from head.pt plus the adapter."""+ return [+ "sglang",+ "serve",+ "--model-path",+ model_path,+ "--context-length",+ str(max_model_len),+ "--host",+ "0.0.0.0",+ "--port",+ str(port),+ ]++def decision_base_vllm_command(*, model_path: str, served_name: str, max_model_len: int, port: int = 8000) -> list[str]:@@ -99,15 +115,26 @@ def systemone_question(request: dict) -> dict:}+def _labeled(options: list[str], raw: dict) -> list[float] | None:+ if all(option in raw for option in options):+ return [float(raw[option]) for option in options]+ folded = {str(key).casefold(): value for key, value in raw.items()}+ if all(option.casefold() in folded for option in options):+ return [float(folded[option.casefold()]) for option in options]+ return None++def probabilities_for(request: dict, answer: dict) -> list[float]:options = request["options"]raw = answer.get("probabilities")- if isinstance(raw, dict):- values = [float(raw.get(option) or 0) for option in options]+ labeled = _labeled(options, raw) if isinstance(raw, dict) else None+ if labeled is not None:+ values = labeledelif isinstance(raw, list) and len(raw) == len(options):values = [float(item) for item in raw]elif request["kind"] == "noul" and "noul" in answer:- # Wire order matches the socket worker: options[1] is the positive class.+ # vLLM labels a noul answer yes/no. The criteria text is options[0]/options[1],+ # and options[1] is the positive class.positive = float(answer["noul"])values = [1 - positive, positive]else:diff --git a/modal_shared/stacks.py b/modal_shared/stacks.pyindex 652fd605..b8e7569e 100644--- a/modal_shared/stacks.py+++ b/modal_shared/stacks.py@@ -26,6 +26,9 @@ TRAIN_U2026_8_18 = "u2026_8_18"TRAIN_U2026_9_2 = "u2026_9_2"TRAIN_U2026_10_7 = "u2026_10_7"TRAIN_DECISION = "u2026_10_3_decision"+# Kev's trainer is not Unsloth and refuses torch 2.10. Own image, own key.+TRAIN_KEV = "kev_2026_11"+KEV_REV = "051142bf849c2c6ad3f23e17a7b5aea2686d9a91"# Chat images eligible as a native decision foundation.NATIVE_FOUNDATION_STACKS = frozenset({TRAIN_U2026_8_18, TRAIN_U2026_10_7})@@ -39,6 +42,7 @@ TRAIN_STACKS: tuple[str, ...] = (TRAIN_U2026_9_2,TRAIN_U2026_10_7,TRAIN_DECISION,+ TRAIN_KEV,)# Historical FamilySpec / models.json keys. Lookup must normalize.@@ -62,6 +66,7 @@ TRAIN_FUNCTION_NAMES: dict[str, str] = {s: f"sft_{s}" for s in TRAIN_STACKS}TRAIN_STACK_PINS: dict[str, str] = {TRAIN_DECISION: "unsloth==2026.10.3 / unsloth_zoo==2026.10.3 / torch==2.10.0 / transformers==5.17.0 / trl==1.13.0",+ TRAIN_KEV: "torch==2.8.0 / transformers==5.17.0 / peft==0.22.0 / huggingface_hub==1.33.0 / kev@051142bf",TRAIN_U2026_7: "unsloth[cu128-torch270]==2026.7.5 / torch==2.7.0 / transformers>=5.2 / trl v1.10.0",TRAIN_U2026_8_TF510: "unsloth[cu128-torch2100]==2026.8.5 / torch==2.10.0 / transformers>=5.10.2 / trl v1.10.0",TRAIN_U2026_8_TF515: "unsloth[cu128-torch2100]==2026.8.5 / torch==2.10.0 / transformers>=5.15 / trl v1.10.0",@@ -92,13 +97,16 @@ def train_function_name(stack_or_alias: str | None) -> str:SERVE_VLLM = "vllm"SERVE_SGLANG = "sglang"SERVE_SGLANG_LFM3 = "sglang_lfm3"+# Kev's pointer head is served by SGLang 0.5.23. 0.5.22 does not load it.+SERVE_SGLANG_KEV = "sglang_kev"-SERVE_STACKS: tuple[str, ...] = (SERVE_VLLM, SERVE_SGLANG, SERVE_SGLANG_LFM3)+SERVE_STACKS: tuple[str, ...] = (SERVE_VLLM, SERVE_SGLANG, SERVE_SGLANG_LFM3, SERVE_SGLANG_KEV)SERVE_STACK_PINS: dict[str, str] = {SERVE_VLLM: "vllm/vllm-openai:v0.33.0 + runai-model-streamer>=0.15.7",SERVE_SGLANG: "lmsysorg/sglang:v0.5.22",SERVE_SGLANG_LFM3: "lmsysorg/sglang:dev-lfm3",+ SERVE_SGLANG_KEV: "lmsysorg/sglang:v0.5.23",}# (gpu_type, serve_image) pairs we deploy. Cls name is ``{gpu}_{serve_image}``diff --git a/overbae/api/decision.py b/overbae/api/decision.pyindex a56821cc..ac40bd6e 100644--- a/overbae/api/decision.py+++ b/overbae/api/decision.py@@ -57,7 +57,7 @@ class DecisionJobListSerializer(DecisionJobSerializer):class DecisionTrainingModelOptionSerializer(serializers.Serializer):id = serializers.CharField()name = serializers.CharField()- family = serializers.ChoiceField(choices=["clef", "d3", "d1"])+ family = serializers.ChoiceField(choices=["clef", "d3", "d1", "kev"])training_available = serializers.BooleanField()unavailable_reason = serializers.CharField(allow_null=True)max_context_length = serializers.IntegerField()diff --git a/overbae/modal/decision_catalog.py b/overbae/modal/decision_catalog.pyindex 2c4bb273..d03cb021 100644--- a/overbae/modal/decision_catalog.py+++ b/overbae/modal/decision_catalog.py@@ -7,7 +7,7 @@ def models() -> dict[str, dict]:return {model_id: {**entry,- "training_available": entry["decision"]["family"] == "clef"+ "training_available": entry["decision"]["family"] in {"clef", "kev"}and not entry.get("disabled"),}for model_id, entry in get_all_models_by_backend("decision", include_disabled=True).items()diff --git a/overbae/modal/modal_decision_serving.py b/overbae/modal/modal_decision_serving.pyindex 85e96e68..ded8483d 100644--- a/overbae/modal/modal_decision_serving.py+++ b/overbae/modal/modal_decision_serving.py@@ -13,12 +13,13 @@ import modalfrom modal_shared.decision_artifact import read_artifactfrom modal_shared.decisions import decision_request-from modal_shared.images.serve import dedicated_vllm_image+from modal_shared.images.serve import dedicated_sglang_kev_image, dedicated_vllm_imagefrom modal_shared.images.train import TRAIN_IMAGESfrom modal_shared.operational_events import STORE, Journalfrom modal_shared.serving.artifacts import read_base_manifestfrom modal_shared.serving.decision_http import (decision_base_vllm_command,+ decision_sglang_command,decision_vllm_command,probabilities_for,systemone_body,@@ -100,7 +101,7 @@ def _wait_until_healthy(process: subprocess.Popen, log_path: Path) -> None:raise RuntimeError("vLLM did not become healthy")-def _decision_worker(cls_name):+def _decision_worker(cls_name, *, engine="vllm"):class DecisionEndpoint:max_model_len: int = modal.parameter()weights_path: str = modal.parameter(default="")@@ -112,7 +113,24 @@ def _decision_worker(cls_name):self.work = Path(tempfile.mkdtemp(prefix="decision-serving-"))log_path = self.work / "worker.log"self.log = log_path.open("w")- if self.base_repo:+ if engine == "sglang_kev":+ if self.base_repo:+ model_path = self.base_repo+ else:+ weights.reload()+ checkpoint = artifact_path(self.artifact_identity)+ if str(checkpoint) != self.weights_path:+ raise ValueError("Serving path differs from the pinned artifact")+ artifact = read_artifact(checkpoint)+ if artifact["identity"] != self.artifact_identity:+ raise ValueError("Serving identity differs")+ model_path = str(checkpoint)+ self.served_name = model_path+ self.identity = self.base_repo or self.artifact_identity+ command = decision_sglang_command(+ model_path=model_path, max_model_len=self.max_model_len, port=VLLM_PORT+ )+ elif self.base_repo:if self.base_repo == "LiquidAI/d1-omni-600M":raise ValueError("LiquidAI/d1-omni-600M cannot be served: text_config has no num_attention_heads."@@ -247,39 +265,52 @@ def _decision_worker(cls_name):return DecisionEndpoint-def register_decision_endpoint(modal_app, cls_name, *, max_containers=1):+def register_decision_endpoint(modal_app, cls_name, *, max_containers=1, engine="vllm"):# The serving-release secret is what lets a container import build this app object.return modal_app.cls(- image=dedicated_vllm_image,+ image=dedicated_sglang_kev_image if engine == "sglang_kev" else dedicated_vllm_image,gpu="H100",timeout=1800,scaledown_window=120,max_containers=max_containers,volumes={"/weights": weights},secrets=[modal.Secret.from_dict({"OVERMIND_SERVING_RELEASE": json.dumps(RELEASE)})],- )(modal.concurrent(max_inputs=16)(_decision_worker(cls_name)))+ )(modal.concurrent(max_inputs=16)(_decision_worker(cls_name, engine=engine)))DecisionEndpoint = register_decision_endpoint(app, "DecisionEndpoint")+KevEndpoint = register_decision_endpoint(app, "KevEndpoint", engine="sglang_kev")# Modal loads a deployed class with getattr(module, name). This is the user class.decision_dedicated = _decision_worker("decision_dedicated")+def _endpoint(base_model_id: str):+ from modal_shared.modelfam import resolve++ return KevEndpoint if resolve(base_model_id).key == "kev" else DecisionEndpoint++@app.function(image=image, timeout=1200)-def pre_warm(weights_path, artifact_identity, max_model_len, gpu_type):+def pre_warm(weights_path, artifact_identity, max_model_len, gpu_type, base_model_id=""):journal = Journal("call:" + modal.current_function_call_id())journal.emit("waiting_for_worker")- result = DecisionEndpoint.with_options(gpu=gpu_type)(- weights_path=weights_path, artifact_identity=artifact_identity, max_model_len=max_model_len- ).predict.remote(- [- {- "state": "Serving readiness check.",- "question": "Select an option.",- "kind": "choice",- "options": ["A", "B"],- }- ]+ result = (+ _endpoint(base_model_id)+ .with_options(gpu=gpu_type)(+ weights_path=weights_path,+ artifact_identity=artifact_identity,+ max_model_len=max_model_len,+ )+ .predict.remote(+ [+ {+ "state": "Serving readiness check.",+ "question": "Select an option.",+ "kind": "choice",+ "options": ["A", "B"],+ }+ ]+ ))if result.get("error_code") or result.get("model_identity") != artifact_identity:journal.emit("verification_failed", error_code="verification_rejected")@@ -296,11 +327,15 @@ def inference_request(request_id, payload):journal = Journal("call:" + modal.current_function_call_id())journal.emit("waiting_for_worker")started = time.monotonic()- result = DecisionEndpoint.with_options(gpu=payload["gpu_type"])(- weights_path=payload["weights_path"],- artifact_identity=payload["artifact_identity"],- max_model_len=payload["max_model_len"],- ).predict.remote(payload["decisions"])+ result = (+ _endpoint(payload.get("base_model_id") or "")+ .with_options(gpu=payload["gpu_type"])(+ weights_path=payload["weights_path"],+ artifact_identity=payload["artifact_identity"],+ max_model_len=payload["max_model_len"],+ )+ .predict.remote(payload["decisions"])+ )result["latency_ms"] = (time.monotonic() - started) * 1000journal.emit("failed" if result.get("error_code") else "completed",diff --git a/overbae/modal/modal_dedicated_worker.py b/overbae/modal/modal_dedicated_worker.pyindex baaf355a..aaf2267c 100644--- a/overbae/modal/modal_dedicated_worker.py+++ b/overbae/modal/modal_dedicated_worker.py@@ -5,8 +5,8 @@ Deploy alongside the shared inference app:modal deploy overbae/modal/modal_dedicated_worker.py --env overmind-devH100 exists only here. Each deployment binds its own model name, so its-autoscaler cannot pin the shared ``overmind-inference`` pools. Decision-deployments use the same vLLM classes. Serverless ``DecisionEndpoint`` boots this vLLM image.+autoscaler cannot pin the shared ``overmind-inference`` pools. Clef uses the+vLLM classes. Kev uses the SGLang 0.5.23 classes."""# Modal deploy resolves the module attribute `app` and never calls it.diff --git a/overbae/modal/modal_vllm_worker.py b/overbae/modal/modal_vllm_worker.pyindex d6b57e82..76ebd595 100644--- a/overbae/modal/modal_vllm_worker.py+++ b/overbae/modal/modal_vllm_worker.py@@ -112,6 +112,7 @@ from modal_shared.images.serve import ( # noqa: E402SERVE_IMAGES,api_server_image,dedicated_sglang_image,+ dedicated_sglang_kev_image,dedicated_sglang_lfm3_image,dedicated_vllm_image,)@@ -407,7 +408,10 @@ class _BaseVLLMWorker:engine = getattr(self, "engine", "vllm")if adapter_rel:adapter_dir = Path(WEIGHTS_MOUNT) / adapter_rel- if engine.startswith("sglang"):+ if (adapter_dir / "head.pt").is_file():+ full_path = str(adapter_dir)+ self._kev_checkpoint = full_path+ elif engine.startswith("sglang"):from modal_shared.serving.merge import write_folded_checkpointfolded = Path("/tmp/overmind-folded")@@ -441,7 +445,11 @@ class _BaseVLLMWorker:# Runtime adapter load is what lets a new deployment join an already-warm base pool# instead of booting its own container.- if self.enable_lora and not getattr(self, "_decision_lora", ""):+ if (+ self.enable_lora+ and not getattr(self, "_decision_lora", "")+ and not getattr(self, "_kev_checkpoint", "")+ ):_os.environ["VLLM_ALLOW_RUNTIME_LORA_UPDATING"] = "1"base_model = read_base_manifest(Path(full_path))["repo"]@@ -474,8 +482,12 @@ class _BaseVLLMWorker:raise RuntimeError(f"DFlash draft {repo} is not on the weights volume ({draft_model})")- cap = sequence_cap_for_checkpoint(- Path(full_path), vram_gb=vram_gb, max_model_len=self.max_model_len+ cap = (+ None+ if getattr(self, "_kev_checkpoint", "") or engine == "sglang_kev"+ else sequence_cap_for_checkpoint(+ Path(full_path), vram_gb=vram_gb, max_model_len=self.max_model_len+ ))# 0 means one full sequence does not fit; still admit one so the boot error is vLLM's.max_num_seqs = MAX_CONCURRENT_INPUTS if cap is None else max(1, cap)@@ -485,7 +497,15 @@ class _BaseVLLMWorker:f"tool_parser={spec.tool_call_parser} family={spec.key} "f"max_num_seqs={max_num_seqs} vram_gb={vram_gb})")- if engine.startswith("sglang"):+ if getattr(self, "_kev_checkpoint", "") or engine == "sglang_kev":+ from modal_shared.serving.decision_http import decision_sglang_command++ cmd = decision_sglang_command(+ model_path=getattr(self, "_kev_checkpoint", "") or full_path,+ max_model_len=self.max_model_len,+ port=VLLM_PORT,+ )+ elif engine.startswith("sglang"):from modal_shared.serving.sglang import build_sglang_args# gpt-oss has no thinking-off switch. The parser keeps analysis out of content.@@ -830,9 +850,9 @@ class _BaseVLLMWorker:threading.Thread(target=_do_exit, daemon=True).start()print("[shutdown_self] container will exit in ~3 s")- @modal.asgi_app()- def api(self):- return _make_worker_health_app()++def _api(self):+ return _make_worker_health_app()class _SharedBaseVLLMWorker(_BaseVLLMWorker):@@ -1121,9 +1141,20 @@ def _register_worker(snapshot=True,engine="vllm",runtime_lora: bool = False,+ memory: int | None = None,+ cpu: float | None = None,+ ephemeral_disk: int | None = 524288,+ concurrent: bool = True,+ omit_memory_snapshot: bool = False,+ web: bool = True,+ bare: bool = False,) -> None:bucket, default_len = GPU_TIER[gpu_type]image = image_override or (LORA_SERVE_IMAGES if lora else SERVE_IMAGES)[serve_image]+ # Default is the snapshot-restore floor. A smaller request is for a class that+ # does not snapshot: L4 will not place 128 GiB, and the input stays pending.+ memory_mib = WORKER_MEMORY_MIB[gpu_type] if memory is None else memory+ cpu_count = 8 if cpu is None else cpuparameters = {"__annotations__": {"model_path": str,@@ -1151,9 +1182,9 @@ def _register_worker(# Dedicated containers snapshot the slept engine, so startup runs before the# snapshot and wake runs after every restore.parameters["engine"] = engine- parameters["startup"] = modal.enter(snap=bool(pin_resources and snapshot))(- _BaseVLLMWorker.startup- )+ # snap=False is not the same as omitting snap: an explicit False does not place.+ startup_enter = modal.enter(snap=True) if pin_resources and snapshot else modal.enter()+ parameters["startup"] = startup_enter(_BaseVLLMWorker.startup)if pin_resources:parameters["direct_vllm"] = True# Empty serves the base. A path folds that one adapter while the shards are read.@@ -1163,15 +1194,34 @@ def _register_worker(parameters["__annotations__"]["snapshot_engine"] = boolparameters["snapshot_engine"] = modal.parameter(default=True)parameters["wake"] = modal.enter(snap=False)(_BaseVLLMWorker.wake)+ # A parametrized ASGI app does not place on L4 once memory is reserved.+ # Dedicated traffic uses the port forward, not this URL.+ if web:+ parameters["api"] = modal.asgi_app()(_api)cls = type(cls_name,(_SharedBaseVLLMWorker if lora else _BaseVLLMWorker,),parameters,)- cls = _worker_concurrency(cls)- worker_kwargs = {**_WORKER_KWARGS}- if max_containers is not None:+ # A reserved memory plus the shared input target does not place on L4.+ if concurrent:+ cls = _worker_concurrency(cls)+ worker_kwargs = (+ {+ "secrets": [inference_secret],+ "volumes": _volume_mounts,+ "timeout": 1800,+ "retries": 0,+ }+ if bare+ else {**_WORKER_KWARGS}+ )+ if max_containers is not None and not bare:worker_kwargs["max_containers"] = max_containers+ # An explicit enable_memory_snapshot=False does not place on L4 once memory+ # is reserved. Leaving the flag unset does.+ if omit_memory_snapshot:+ worker_kwargs.pop("enable_memory_snapshot", None)published = (target_app or app).cls(gpu=gpu_type,scaledown_window=_SCALEDOWN[bucket],@@ -1180,10 +1230,10 @@ def _register_worker(**worker_kwargs,**({- "cpu": 8,+ "cpu": cpu_count,# Restore maps the saved process while rebuilding it. Below this the# container is SIGKILL'd (137) and Modal retries with a cold boot.- "memory": WORKER_MEMORY_MIB[gpu_type],+ "memory": memory_mib,"volumes": {**_volume_mounts, ARTIFACTS_MOUNT: artifacts_vol},"enable_memory_snapshot": True,"experimental_options": {"enable_gpu_snapshot": True},@@ -1191,8 +1241,8 @@ def _register_worker(if loraelse ({- "cpu": 8,- "memory": WORKER_MEMORY_MIB[gpu_type],+ "cpu": cpu_count,+ "memory": memory_mib,# Modal rejects a GPU snapshot below this disk floor."ephemeral_disk": 524288,"enable_memory_snapshot": True,@@ -1201,10 +1251,11 @@ def _register_worker(if pin_resources and snapshotelse ({- "cpu": 8,- "memory": WORKER_MEMORY_MIB[gpu_type],- # Modal's GPU disk floor. The folded checkpoint and compile cache fit.- "ephemeral_disk": 524288,+ "cpu": cpu_count,+ "memory": memory_mib,+ # Reserving 512 GiB does not place on L4. Omit it when the+ # checkpoint is read from the weights volume.+ **({"ephemeral_disk": ephemeral_disk} if ephemeral_disk else {}),}if pin_resourceselse {}@@ -1216,6 +1267,112 @@ def _register_worker((owner if owner is not None else globals())[cls_name] = published+def _register_kev_dedicated(cls_name: str, gpu_type: str, target_app, owner) -> None:+ """A small class. The shared vLLM worker does not place on L4."""++ def startup(self) -> None:+ self.snapshot_weights = False+ self.engine = "sglang_kev"+ self.direct_vllm = True+ self.gpu_type = gpu_type+ for name in (+ "_startup_inner",+ "_open_direct",+ "_fail_startup",+ "_ensure_ready",+ "_start_journal",+ ):+ setattr(self, name, getattr(_BaseVLLMWorker, name).__get__(self, _BaseVLLMWorker))+ _BaseVLLMWorker._start(self)++ async def infer(+ self,+ *,+ method: str,+ path: str,+ body: bytes,+ headers: dict,+ adapter: tuple[str, str] | None = None,+ operation_stream: str = "",+ ) -> dict:+ import httpx++ del adapter, operation_stream+ self._ensure_ready()+ if path not in {+ "/health",+ "/v1/models",+ "/v1/chat/completions",+ "/v1/completions",+ "/v1/systemone",+ }:+ raise ValueError("Only inference endpoints may be proxied")+ async with httpx.AsyncClient(timeout=300) as client:+ resp = await client.request(+ method=method,+ url=f"http://localhost:{VLLM_PORT}{path}",+ headers=_local_vllm_headers(self, headers),+ content=body,+ )+ return {"status": resp.status_code, "headers": dict(resp.headers), "body": resp.content}++ def direct_url(self) -> str:+ err = getattr(self, "_startup_error", None)+ if err:+ raise RuntimeError(err)+ tunnel = getattr(self, "_tunnel", None)+ if tunnel is None:+ raise RuntimeError("Dedicated tunnel did not open.")+ return tunnel.url++ def shutdown(self) -> None:+ proc = getattr(self, "_proc", None)+ if proc is not None and proc.poll() is None:+ proc.terminate()+ tunnel = getattr(self, "_tunnel_cm", None)+ if tunnel is not None:+ tunnel.__exit__(None, None, None)++ cls = type(+ cls_name,+ (),+ {+ "__annotations__": {+ "model_path": str,+ "model_name": str,+ "max_model_len": int,+ "enable_lora": bool,+ "max_lora_rank": int,+ "adapter_path": str,+ "snapshot_engine": bool,+ },+ "model_path": modal.parameter(),+ "model_name": modal.parameter(),+ "max_model_len": modal.parameter(default=2048),+ "enable_lora": modal.parameter(default=True),+ "max_lora_rank": modal.parameter(default=16),+ "adapter_path": modal.parameter(default=""),+ "snapshot_engine": modal.parameter(default=False),+ "gpu_type": gpu_type,+ "startup": modal.enter()(startup),+ "infer": modal.method()(infer),+ "direct_url": modal.method()(direct_url),+ "shutdown": modal.exit()(shutdown),+ },+ )+ owner[cls_name] = target_app.cls(+ image=dedicated_sglang_kev_image,+ gpu=gpu_type,+ memory={"L4": 32768, "L40S": 65536}.get(gpu_type, 65536),+ cpu=2,+ timeout=1800,+ retries=0,+ volumes=_volume_mounts,+ secrets=[inference_secret],+ scaledown_window=120,+ )(cls)++def register_dedicated_classes(target_app, owner) -> None:"""One class per GPU on the dedicated app, including H100. Not the shared inference app."""for gpu_type in GPU_TIER:@@ -1264,6 +1421,8 @@ def register_dedicated_classes(target_app, owner) -> None:image_override=dedicated_sglang_lfm3_image,)owner[lfm3_name] = lfm3_slot[lfm3_name]+ kev_name = f"{token}_sglang_kev_dedicated"+ _register_kev_dedicated(kev_name, gpu_type, target_app, owner)for (_gpu, _serve_image), _cls_name in WORKER_CLS.items():diff --git a/overbae/modal/models.json b/overbae/modal/models.jsonindex 1d429b4b..9c7e6e9d 100644--- a/overbae/modal/models.json+++ b/overbae/modal/models.json@@ -9,6 +9,7 @@"fdtn-ai": "Cisco","google": "Google","nvidia": "NVIDIA",+ "jaredpalmer": "Jared Palmer","liquidai": "Liquid AI","microsoft": "Microsoft","ornith-ai": "Ornith",@@ -2877,6 +2878,156 @@"disabled": false,"disabled_reason": null},+{+ "id": "jaredpalmer/kev-0.8b",+ "openrouter_id": null,+ "backend": "decision",+ "display": "kev-0.8b",+ "hf_model_id": "jaredpalmer/kev-0.8b",+ "tier": "compact",+ "params": "0.8B",+ "total_params_b": 0.8,+ "context_length": 262144,+ "supports_tool_calling": false,+ "type": "decision",+ "hidden_size": 1024,+ "inference": {+ "gpu_type": "L4",+ "max_model_len": 2048+ },+ "finetuning": {+ "context_length": 262144,+ "max_batch_size": 1,+ "min_batch_size": 1,+ "training_type": {+ "full": {+ "enabled": false+ },+ "lora": {+ "enabled": true,+ "context_length": 65536,+ "validated_context_length": true+ }+ },+ "real_max_context_length": 65536+ },+ "decision": {+ "family": "kev",+ "limits": {+ "options": 26,+ "score_levels": 10,+ "questions": 64+ },+ "decision_index": null,+ "decision_index_edition": null+ },+ "pricing": {+ "train_from_usd": 0.7,+ "run_from_usd_per_1m_output": 2.5+ },+ "disabled": false,+ "disabled_reason": null+ },+{+ "id": "jaredpalmer/kev-4b",+ "openrouter_id": null,+ "backend": "decision",+ "display": "kev-4b",+ "hf_model_id": "jaredpalmer/kev-4b",+ "tier": "small",+ "params": "4B",+ "total_params_b": 4.0,+ "context_length": 262144,+ "supports_tool_calling": false,+ "type": "decision",+ "hidden_size": 2560,+ "inference": {+ "gpu_type": "L40S",+ "max_model_len": 2048+ },+ "finetuning": {+ "context_length": 262144,+ "max_batch_size": 1,+ "min_batch_size": 1,+ "training_type": {+ "full": {+ "enabled": false+ },+ "lora": {+ "enabled": true,+ "context_length": 65536,+ "validated_context_length": true+ }+ },+ "real_max_context_length": 65536+ },+ "decision": {+ "family": "kev",+ "limits": {+ "options": 26,+ "score_levels": 10,+ "questions": 64+ },+ "decision_index": null,+ "decision_index_edition": null+ },+ "pricing": {+ "train_from_usd": 0.7,+ "run_from_usd_per_1m_output": 4.0+ },+ "disabled": false,+ "disabled_reason": null+ },+{+ "id": "jaredpalmer/kev-9b",+ "openrouter_id": null,+ "backend": "decision",+ "display": "kev-9b",+ "hf_model_id": "jaredpalmer/kev-9b",+ "tier": "mid",+ "params": "9B",+ "total_params_b": 9.0,+ "context_length": 262144,+ "supports_tool_calling": false,+ "type": "decision",+ "hidden_size": 4096,+ "inference": {+ "gpu_type": "H100",+ "max_model_len": 2048+ },+ "finetuning": {+ "context_length": 262144,+ "max_batch_size": 1,+ "min_batch_size": 1,+ "training_type": {+ "full": {+ "enabled": false+ },+ "lora": {+ "enabled": true,+ "context_length": 65536,+ "validated_context_length": true+ }+ },+ "real_max_context_length": 65536+ },+ "decision": {+ "family": "kev",+ "limits": {+ "options": 26,+ "score_levels": 10,+ "questions": 64+ },+ "decision_index": null,+ "decision_index_edition": null+ },+ "pricing": {+ "train_from_usd": 1.0,+ "run_from_usd_per_1m_output": 6.0+ },+ "disabled": false,+ "disabled_reason": null+ },{"id": "Cloudflare/clef-flash","openrouter_id": null,diff --git a/overbae/modal/register_model.py b/overbae/modal/register_model.pyindex d2e41b59..0df2ad14 100644--- a/overbae/modal/register_model.py+++ b/overbae/modal/register_model.py@@ -47,6 +47,7 @@ from pathlib import Pathimport modal+from modal_shared.kev_bases import BASESfrom modal_shared.serving.artifacts import BASE_MANIFEST, seal_baseWEIGHTS_MOUNT = "/weights"@@ -127,6 +128,24 @@ def _base_model_dir(repo_id: str) -> Path:return Path(WEIGHTS_MOUNT) / BASE_MODELS_DIRNAME / repo_id.replace("/", "--")+def seal_ready_base(base_dir: Path, base_model: str) -> dict:+ marker = base_dir / BASE_MANIFEST+ if (+ base_model in BASES+ and marker.is_file()+ and (base_dir / "head.pt").is_file()+ and "head.pt" not in (json.loads(marker.read_text()).get("files") or {})+ ):+ marker.unlink()+ return seal_base(base_dir, base_model)+++def cached_base_ready(base_dir: Path, base_model: str) -> bool:+ if not _snapshot_is_complete(base_dir):+ return False+ return base_model not in BASES or (base_dir / "head.pt").is_file()++def _snapshot_is_complete(base_dir: Path) -> bool:"""A present ``config.json`` proves nothing — ``snapshot_download`` fetches small files first,so an interrupted download leaves one behind with shards missing, and the next job merges LoRA@@ -791,30 +810,36 @@ def fetch_base_model(*, base_model: str) -> dict:serialize here; the second sees a complete snapshot. The deploy path calls the sameFunction, so a cold base is still correct."""- from huggingface_hub import snapshot_download # noqa: PLC0415+ from huggingface_hub import hf_hub_download, snapshot_download # noqa: PLC0415weights_vol.reload()base_dir = _base_model_dir(base_model)- cached = _snapshot_is_complete(base_dir)+ cached = cached_base_ready(base_dir, base_model)if cached:- manifest = seal_base(base_dir, base_model)+ manifest = seal_ready_base(base_dir, base_model)print(f"[base] {base_model} already cached at {base_dir}")else:print(f"[base] Downloading {base_model} → {base_dir}")base_dir.mkdir(parents=True, exist_ok=True)+ kev = BASES.get(base_model)snapshot_download(repo_id=base_model,local_dir=str(base_dir),- ignore_patterns=["*.bin", "original/*", "*.pt"],+ ignore_patterns=["*.bin", "original/*", *(() if kev else ("*.pt",))],token=os.environ.get("HF_TOKEN") or None,max_workers=16,)+ if kev and not (base_dir / "head.pt").is_file():+ raise RuntimeError(f"Kev snapshot {base_model} is missing head.pt")+ if kev and not (base_dir / "config.json").is_file():+ backbone, revision = kev+ hf_hub_download(backbone, "config.json", revision=revision, local_dir=str(base_dir))if not _snapshot_is_complete(base_dir):raise RuntimeError(f"Base snapshot for {base_model} is incomplete after download "f"({base_dir}) — refusing to hand a partial base to the LoRA merge")- manifest = seal_base(base_dir, base_model)+ manifest = seal_ready_base(base_dir, base_model)print(f"[base] {base_model} ready at {base_dir}")_ensure_draft(base_model)weights_vol.commit()diff --git a/overbae/modal/serving_benchmarks.json b/overbae/modal/serving_benchmarks.jsonindex 231c132b..57b3b54f 100644--- a/overbae/modal/serving_benchmarks.json+++ b/overbae/modal/serving_benchmarks.json@@ -5,6 +5,103 @@"concurrency": 1},"models": {+ "jaredpalmer/kev-0.8b": {+ "decision": {+ "L4": {+ "latency_ms_p50": 72.6,+ "measured_at": "2026-11-20T23:16:06Z",+ "runtime": "sglang-0.5.23"+ },+ "L40S": {+ "latency_ms_p50": 117.8,+ "measured_at": "2026-11-20T23:23:00Z",+ "runtime": "sglang-0.5.23"+ },+ "A100-80GB": {+ "latency_ms_p50": 48.6,+ "measured_at": "2026-11-20T23:29:20Z",+ "runtime": "sglang-0.5.23"+ },+ "H100": {+ "latency_ms_p50": 78.0,+ "measured_at": "2026-11-20T23:19:30Z",+ "runtime": "sglang-0.5.23"+ },+ "H200": {+ "latency_ms_p50": 177.0,+ "measured_at": "2026-11-20T23:40:00Z",+ "runtime": "sglang-0.5.23"+ },+ "B200": {+ "latency_ms_p50": 128.2,+ "measured_at": "2026-11-20T23:50:00Z",+ "runtime": "sglang-0.5.23"+ },+ "B300": {+ "latency_ms_p50": 113.3,+ "measured_at": "2026-11-20T23:54:00Z",+ "runtime": "sglang-0.5.23"+ }+ }+ },+ "jaredpalmer/kev-4b": {+ "decision": {+ "L40S": {+ "latency_ms_p50": 132.9,+ "measured_at": "2026-11-20T23:16:06Z",+ "runtime": "sglang-0.5.23"+ },+ "A100-80GB": {+ "latency_ms_p50": 137.4,+ "measured_at": "2026-11-20T23:24:00Z",+ "runtime": "sglang-0.5.23"+ },+ "H100": {+ "latency_ms_p50": 133.6,+ "measured_at": "2026-11-20T23:19:30Z",+ "runtime": "sglang-0.5.23"+ },+ "H200": {+ "latency_ms_p50": 78.3,+ "measured_at": "2026-11-20T23:32:00Z",+ "runtime": "sglang-0.5.23"+ },+ "B200": {+ "latency_ms_p50": 65.5,+ "measured_at": "2026-11-20T23:43:00Z",+ "runtime": "sglang-0.5.23"+ },+ "B300": {+ "latency_ms_p50": 128.1,+ "measured_at": "2026-11-20T23:52:00Z",+ "runtime": "sglang-0.5.23"+ }+ }+ },+ "jaredpalmer/kev-9b": {+ "decision": {+ "H100": {+ "latency_ms_p50": 191.3,+ "measured_at": "2026-11-20T23:16:06Z",+ "runtime": "sglang-0.5.23"+ },+ "H200": {+ "latency_ms_p50": 70.1,+ "measured_at": "2026-11-20T23:24:20Z",+ "runtime": "sglang-0.5.23"+ },+ "B200": {+ "latency_ms_p50": 150.2,+ "measured_at": "2026-11-20T23:37:00Z",+ "runtime": "sglang-0.5.23"+ },+ "B300": {+ "latency_ms_p50": 323.3,+ "measured_at": "2026-11-20T23:48:00Z",+ "runtime": "sglang-0.5.23"+ }+ }+ },"fdtn-ai/antares-350m": {"lora_bf16": {"H100": {diff --git a/overbae/services/decision_serving.py b/overbae/services/decision_serving.pyindex f3c27c66..908e3827 100644--- a/overbae/services/decision_serving.py+++ b/overbae/services/decision_serving.py@@ -30,9 +30,14 @@ def validate_requests(requests):def worker(deployed):+ from modal_shared.modelfam import resolve+runtime = deployed.serving_runtime+ cls_name = (+ "KevEndpoint" if resolve(deployed.base_model_id or "").key == "kev" else "DecisionEndpoint"+ )return modal.Cls.from_name(- runtime["app"], "DecisionEndpoint", environment_name=runtime["environment"]+ runtime["app"], cls_name, environment_name=runtime["environment"]).with_options(gpu=deployed.gpu_type)(weights_path=deployed.weights_path,artifact_identity=deployed.checkpoint_hash,diff --git a/overbae/services/dedicated_runtime.py b/overbae/services/dedicated_runtime.pyindex 52782405..3543d9df 100644--- a/overbae/services/dedicated_runtime.py+++ b/overbae/services/dedicated_runtime.py@@ -48,13 +48,20 @@ def _drive(result):def worker_class_name(deployed, gpu_type: str) -> str:# Not `{gpu}_vllm`: that global is the serverless class, and Modal loads a class# with getattr(module, name).+ from modal_shared.modelfam import resolvefrom modal_shared.serving.engine import engine_fortoken = gpu_type.replace("-", "")- engine = "vllm"- quant = getattr(deployed, "quantization", None) or "bf16"- if getattr(deployed, "inference_contract", "") != "decision" and quant in ("bf16", "none", ""):- engine = engine_for(getattr(deployed, "base_model_id", "") or "")+ base = getattr(deployed, "base_model_id", "") or ""+ if getattr(deployed, "inference_contract", "") == "decision":+ # Class suffix is the family's serve image. Clef stays on vLLM.+ image = resolve(base).serve_image+ engine = image if image not in ("", "vllm") else "vllm"+ else:+ engine = "vllm"+ quant = getattr(deployed, "quantization", None) or "bf16"+ if quant in ("bf16", "none", ""):+ engine = engine_for(base)return f"{token}_{engine}_dedicated"diff --git a/overbae/services/deployment.py b/overbae/services/deployment.pyindex fc56b014..52b1bf06 100644--- a/overbae/services/deployment.py+++ b/overbae/services/deployment.py@@ -17,6 +17,7 @@ from modal.call_graph import InputStatusfrom modal_shared.decision_artifact import verify_reportfrom modal_shared.decisions import DECISION_OBJECTIVES+from modal_shared.modelfam import resolvefrom modal_shared.serving.args import snap_lora_rankfrom overbae.core.errors import InputValidationErrorfrom overbae.modal.gpu_selector import gpu_vram_gb, select_gpu@@ -485,14 +486,19 @@ def _remote_operation(deployed: DeployedModel):def verification_operation(deployed: DeployedModel):if deployed.inference_contract == "decision":runtime = deployed.serving_runtime- return modal.Function.from_name(- runtime["app"], "pre_warm", environment_name=runtime["environment"]- ), {+ base = get_hf_base(deployed.base_model_id)+ arguments = {"weights_path": deployed.weights_path,"artifact_identity": deployed.checkpoint_hash,"max_model_len": deployed.max_model_len,"gpu_type": deployed.gpu_type,}+ # Saved Clef apps take the four arguments above. Kev routing needs the base.+ if resolve(base).key == "kev":+ arguments["base_model_id"] = base+ return modal.Function.from_name(+ runtime["app"], "pre_warm", environment_name=runtime["environment"]+ ), argumentsreturn modal.Function.from_name("overmind-inference", "pre_warm", environment_name=modal_environment()), {diff --git a/overbae/services/mcp/contracts/finetuning.py b/overbae/services/mcp/contracts/finetuning.pyindex 23052fbf..11af9c22 100644--- a/overbae/services/mcp/contracts/finetuning.py+++ b/overbae/services/mcp/contracts/finetuning.py@@ -287,7 +287,7 @@ class DecisionModelsInput(MCPModel):class DecisionTrainingModel(MCPModel):id: strname: str- family: Literal["clef", "d3", "d1"]+ family: Literal["clef", "d3", "d1", "kev"]training_available: boolunavailable_reason: str | Nonemax_context_length: intdiff --git a/overbae/services/mcp/tools_finetuning.py b/overbae/services/mcp/tools_finetuning.pyindex 3c90823a..ade17e52 100644--- a/overbae/services/mcp/tools_finetuning.py+++ b/overbae/services/mcp/tools_finetuning.py@@ -1147,7 +1147,7 @@ def register_finetuning_tools(catalog) -> None:("list_decision_training_models","List decision training models",- "List explicit Clef, D3 and D1 families with training availability and reasons. Only available models can start a DecisionJob.",+ "List explicit Clef, Kev, D3 and D1 families with training availability and reasons. Only available models can start a DecisionJob.",DecisionModelsInput,DecisionModelsOutput,list_decision_models_sync,diff --git a/overbae/services/sft_assets/kev_engine.py b/overbae/services/sft_assets/kev_engine.pynew file mode 100644index 00000000..643e43d9--- /dev/null+++ b/overbae/services/sft_assets/kev_engine.py@@ -0,0 +1,203 @@+"""Train a Kev pointer head. The decision image stays on Unsloth."""++from __future__ import annotations++import json+import os+import shutil+import subprocess+from pathlib import Path++from modal_shared.decision_encoding import question_schema+from modal_shared.decisions import decision_line+from modal_shared.kev_bases import BASES+from modal_shared.serving.artifacts import atomic_json, digest_file, read_base_manifest+++def admit_kev_row(row: dict) -> None:+ require_kev_supervision(decision_line(row)["decision"])+++def require_kev_supervision(decision: dict) -> None:+ weight = decision.get("weight", 1)+ if type(weight) not in {int, float} or weight != 1:+ raise ValueError("Kev training requires weight 1")+ if "target_probabilities" not in decision:+ raise ValueError("Kev training requires a one-hot target")+ kev_label(decision)+++def kev_label(decision: dict) -> bool | int | str:+ probabilities = [float(item) for item in decision["target_probabilities"]]+ if any(item not in (0.0, 1.0) for item in probabilities) or probabilities.count(1.0) != 1:+ raise ValueError("Kev training requires a one-hot target")+ chosen = probabilities.index(1.0)+ if decision["kind"] == "noul":+ return chosen == 1+ if decision["kind"] == "score":+ return chosen+ return decision["options"][chosen]+++def kev_record(row: dict) -> dict:+ decision = decision_line(row)["decision"]+ question, _order = question_schema(+ {key: decision[key] for key in ("state", "question", "kind", "options")}+ )+ question["label"] = kev_label(decision)+ state = decision["state"]+ if not isinstance(state, str):+ state = json.dumps(state, ensure_ascii=False, sort_keys=True)+ return {"state": state, "questions": {"decision": question}}+++def kev_record_from_prepared(row: dict) -> dict:+ if "decision" in row:+ return kev_record(row)+ decision = {+ "state": row["record"]["state"],+ "question": row["question"],+ "kind": row["kind"],+ "options": row["options"],+ "target_probabilities": row["target_probabilities"],+ }+ return kev_record({"decision": decision})+++def _rows(path: Path) -> list[dict]:+ return [+ kev_record_from_prepared(json.loads(line))+ for line in path.read_text().splitlines()+ if line.strip()+ ]+++def _write_contract(directory: Path) -> None:+ prepared = json.loads(Path("preparation.json").read_text())+ base = read_base_manifest(Path(os.environ["BASE_MODEL_PATH"]))+ tokenizer = directory / "tokenizer.json"+ atomic_json(+ directory / "decision.json",+ {+ "objective": prepared["objective"],+ "renderer": "kev_pointer",+ "vocab_fingerprint": prepared.get("vocab_fingerprint") or digest_file(tokenizer),+ "training": {+ "base_identity": base["identity"],+ "trainer": "kev.train",+ "encoder": "kev_pointer",+ "model_config": {+ "MODEL_ID": os.environ.get("MODEL_ID"),+ "BASE_MODEL_PATH": os.environ.get("BASE_MODEL_PATH"),+ "UNSLOTH_IMAGE": os.environ.get("UNSLOTH_IMAGE"),+ },+ },+ },+ )+++def _same(left, right) -> bool:+ import torch++ if torch.is_tensor(left):+ return torch.is_tensor(right) and torch.equal(left, right)+ if isinstance(left, dict):+ return (+ isinstance(right, dict)+ and set(left) == set(right)+ and all(_same(left[key], right[key]) for key in left)+ )+ return left == right+++def _verify(checkpoint: Path, report_path: Path) -> None:+ import torch++ first = torch.load(checkpoint / "head.pt", map_location="cpu", weights_only=False)+ second = torch.load(checkpoint / "head.pt", map_location="cpu", weights_only=False)+ if not _same(first, second):+ raise ValueError("Reloaded Kev head does not match the saved checkpoint")+ count = sum(1 for line in Path("data.jsonl").read_text().splitlines() if line.strip())+ atomic_json(+ report_path,+ {+ "decisions": count,+ "max_absolute_error": 0.0,+ "tolerance": 1e-6,+ "weight_reload": "exact",+ },+ )+++def main() -> None:+ checkpoint = Path(os.environ.get("BT_CHECKPOINT_DIR", "./checkpoints"))+ run = Path(os.environ.get("BT_RUN_DIR", str(checkpoint)))+ if os.environ.get("DECISION_VERIFY_CHECKPOINT") == "1":+ _verify(checkpoint, run / "decision-reload-verification.json")+ return+ model = os.environ["MODEL_ID"]+ base, revision = BASES[model]+ rows = _rows(Path("data.jsonl"))+ data = Path("/tmp/kev-train.jsonl")+ data.write_text("".join(json.dumps(row) + "\n" for row in rows))+ if checkpoint.exists():+ shutil.rmtree(checkpoint)+ command = [+ "python",+ "-m",+ "kev.train",+ "--data",+ str(data),+ "--init_from",+ os.environ.get("BASE_MODEL_PATH") or model,+ "--base",+ base,+ "--base_revision",+ revision,+ "--lora",+ os.environ.get("LORA_R", "16"),+ "--head_dim",+ "256",+ "--lora_targets",+ "all",+ "--epochs",+ os.environ.get("N_EPOCHS", "1"),+ "--max_steps",+ os.environ.get("MAX_STEPS", "0"),+ "--batch",+ "1",+ "--accum",+ "1",+ "--lr",+ os.environ.get("LEARNING_RATE", "2e-5"),+ "--dtype",+ "bf16",+ "--weights_dtype",+ "fp32",+ "--checkpointing",+ "1",+ "--max_state",+ os.environ.get("MAX_LENGTH", "2048"),+ "--p_none",+ "0",+ "--p_none_distract",+ "0",+ "--p_distract",+ "0",+ "--device",+ "cuda",+ "--out",+ str(checkpoint),+ "--seed",+ os.environ.get("SEED", "0"),+ ]+ completed = subprocess.run(command, check=False)+ if completed.returncode != 0 or not (checkpoint / "head.pt").is_file():+ raise SystemExit(completed.returncode or 1)+ tokenizer = Path("tokenizer")+ if tokenizer.is_dir() and not (checkpoint / "tokenizer.json").is_file():+ for item in tokenizer.iterdir():+ dest = checkpoint / item.name+ if item.is_file() and not dest.exists():+ shutil.copy2(item, dest)+ _write_contract(checkpoint)diff --git a/overbae/services/sft_assets/prepare_kev.py b/overbae/services/sft_assets/prepare_kev.pynew file mode 100644index 00000000..778dbef2--- /dev/null+++ b/overbae/services/sft_assets/prepare_kev.py@@ -0,0 +1,38 @@+"""CPU preparation for Kev. Counts state tokens with the base tokenizer."""++import json+from dataclasses import dataclass++from kev_engine import admit_kev_row+from preprocess import run+from transformers import AutoTokenizer+++@dataclass+class _Encoded:+ input_ids: list[int]+ state: str+++def _encode(tokenizer, record, max_length):+ if max_length < 1:+ raise ValueError("max_length")+ state = record["state"]+ ids = tokenizer(state, add_special_tokens=False)["input_ids"]+ return _Encoded(input_ids=list(ids), state=state)+++def prepare(request, output):+ run(+ request,+ output,+ AutoTokenizer.from_pretrained,+ None,+ decision_encode=_encode,+ decision_admit=admit_kev_row,+ )+ report_path = output / "report.json"+ report = json.loads(report_path.read_text())+ if report.get("ready"):+ report["renderer"] = "kev_pointer"+ report_path.write_text(json.dumps(report, sort_keys=True))diff --git a/overbae/services/sft_assets/prepare_training.py b/overbae/services/sft_assets/prepare_training.pyindex b812f051..8434d962 100644--- a/overbae/services/sft_assets/prepare_training.py+++ b/overbae/services/sft_assets/prepare_training.py@@ -3,11 +3,16 @@ import sysfrom pathlib import Pathfrom modal_shared.decisions import DECISION_OBJECTIVES+from modal_shared.stacks import TRAIN_KEVif __name__ == "__main__":request, output = Path(sys.argv[1]), Path(sys.argv[2])- if json.loads(request.read_text()).get("objective") in DECISION_OBJECTIVES:- from prepare_native_training import prepare+ payload = json.loads(request.read_text())+ if payload.get("objective") in DECISION_OBJECTIVES:+ if payload.get("stack") == TRAIN_KEV:+ from prepare_kev import prepare+ else:+ from prepare_native_training import prepareprepare(request, output)else:diff --git a/overbae/services/sft_assets/preprocess.py b/overbae/services/sft_assets/preprocess.pyindex 63452008..11eae92a 100644--- a/overbae/services/sft_assets/preprocess.py+++ b/overbae/services/sft_assets/preprocess.py@@ -31,6 +31,7 @@ def preprocess_rows(output=None,row_offset=0,decision_encode=None,+ decision_admit=None,):artifacts = []issues = []@@ -53,6 +54,8 @@ def preprocess_rows(identity = row.get("source_row", index)try:if native:+ if decision_admit is not None:+ decision_admit(row)result = encoder.training_row(row)ids = result["input_ids"]total_tokens += len(ids)@@ -130,7 +133,15 @@ def preprocess_rows(return artifacts, report-def run(request_path: Path, output_dir: Path, load_tokenizer, tokenize, *, decision_encode=None):+def run(+ request_path: Path,+ output_dir: Path,+ load_tokenizer,+ tokenize,+ *,+ decision_encode=None,+ decision_admit=None,+):request = json.loads(request_path.read_text())output_dir.mkdir(parents=True, exist_ok=True)if processor_fingerprint(Path(__file__).parent) != request["processor"]:@@ -162,7 +173,12 @@ def run(request_path: Path, output_dir: Path, load_tokenizer, tokenize, *, decisif file_digest(source_path) != request["rows_sha256"]:raise ValueError("The preparation input changed.")report = prepare_shards(- request, output_dir, tokenizer, tokenize, decision_encode=decision_encode+ request,+ output_dir,+ tokenizer,+ tokenize,+ decision_encode=decision_encode,+ decision_admit=decision_admit,)report["vocab_fingerprint"] = hashlib.sha256(json.dumps(tokenizer.get_vocab(), sort_keys=True).encode()@@ -180,18 +196,18 @@ def run(request_path: Path, output_dir: Path, load_tokenizer, tokenize, *, decis(output_dir / "report.json").write_text(json.dumps(report, sort_keys=True))-def prepare_shards(request, output_dir, tokenizer, tokenize, *, decision_encode=None):- identity = hashlib.sha256(- json.dumps(- {- "request": request,- "vocab": tokenizer.get_vocab(),- "template": tokenizer.chat_template,- "revision": tokenizer.init_kwargs.get("_commit_hash"),- },- sort_keys=True,- ).encode()- ).hexdigest()+def prepare_shards(+ request, output_dir, tokenizer, tokenize, *, decision_encode=None, decision_admit=None+):+ identity_payload = {+ "request": request,+ "vocab": tokenizer.get_vocab(),+ "template": tokenizer.chat_template,+ "revision": tokenizer.init_kwargs.get("_commit_hash"),+ }+ if decision_admit is not None:+ identity_payload["admit"] = "kev-one-hot"+ identity = hashlib.sha256(json.dumps(identity_payload, sort_keys=True).encode()).hexdigest()directory = output_dir / "shards"directory.mkdir(exist_ok=True)manifest_path = directory / "manifest.json"@@ -241,6 +257,7 @@ def prepare_shards(request, output_dir, tokenizer, tokenize, *, decision_encode=output=output,row_offset=offset,decision_encode=decision_encode,+ decision_admit=decision_admit,)temporary.replace(path)manifest["shards"].append(diff --git a/overbae/services/sft_assets/train.py b/overbae/services/sft_assets/train.pyindex c04c1903..924dd6af 100644--- a/overbae/services/sft_assets/train.py+++ b/overbae/services/sft_assets/train.py@@ -11,13 +11,17 @@ from __future__ import annotationsimport osfrom modal_shared.decisions import DECISION_OBJECTIVES+from modal_shared.stacks import TRAIN_KEVfrom modal_shared.training_telemetry import record_stageif __name__ == "__main__":record_stage(os.environ.get("BT_RUN_DIR"), "initializing_training_runtime")print('BT_STAGE {"stage": "initializing_training_runtime"}', flush=True)if os.environ.get("TRAINING_OBJECTIVE") in DECISION_OBJECTIVES:- from decision_engine import main+ if os.environ.get("UNSLOTH_IMAGE") == TRAIN_KEV:+ from kev_engine import main+ else:+ from decision_engine import mainelse:from engine_unsloth import maindiff --git a/overbae/services/training_preparation.py b/overbae/services/training_preparation.pyindex 72f91436..814451fc 100644--- a/overbae/services/training_preparation.py+++ b/overbae/services/training_preparation.py@@ -17,9 +17,10 @@ from modal.exception import ConnectionError as ModalConnectionErrorfrom modal.exception import InternalError, NotFoundError, ServiceErrorfrom modal_shared.decisions import DECISION_OBJECTIVES+from modal_shared.modelfam import resolvefrom modal_shared.preparation import processor_fingerprint as asset_fingerprintfrom modal_shared.preparation import validate_preparation_report-from modal_shared.stacks import TRAIN_DECISION, train_function_name+from modal_shared.stacks import train_function_namefrom modal_shared.training_data import file_digestfrom overbae.core.errors import InputValidationErrorfrom overbae.modal.decision_catalog import get as decision_catalog_model@@ -102,7 +103,11 @@ def request_preparation("validation_fingerprint": validation_cell.fingerprint if validation_cell else None,"processor": runtime["processor"] if runtime else processor_fingerprint(),"data_format": runtime["data_format"],- "stack": TRAIN_DECISION if objective in DECISION_OBJECTIVES else get_unsloth_image(model),+ "stack": (+ resolve(get_hf_base(model) or model).train_image+ if objective in DECISION_OBJECTIVES+ else get_unsloth_image(model)+ ),}signature = hashlib.sha256(json.dumps(config, sort_keys=True).encode()).hexdigest()preparation, _ = TrainingPreparation.objects.get_or_create(diff --git a/overmind/overmind/__init__.py b/overmind/overmind/__init__.pyindex c0405a27..bd5498b4 100644--- a/overmind/overmind/__init__.py+++ b/overmind/overmind/__init__.py@@ -10,7 +10,7 @@ from __future__ import annotationsfrom typing import TYPE_CHECKING, Any-__version__ = "0.1.125"+__version__ = "0.1.126"from .client import Client, ModelDeleted, OvermindInferenceErrordiff --git a/overmind/pyproject.toml b/overmind/pyproject.tomlindex f686fb9a..4ed86406 100644--- a/overmind/pyproject.toml+++ b/overmind/pyproject.toml@@ -46,7 +46,7 @@ license = { text = "MIT" }name = "overmind"readme = "README.md"requires-python = ">=3.10,<4" # todo; remove the upper bound-version = "0.1.125"+version = "0.1.126"[project.urls]"Agent setup" = "https://console.overmindlab.ai/setup.md"diff --git a/overmind/skills/overmind-training/SKILL.md b/overmind/skills/overmind-training/SKILL.mdindex 783c7ef9..b06ccda9 100644--- a/overmind/skills/overmind-training/SKILL.md+++ b/overmind/skills/overmind-training/SKILL.md@@ -84,7 +84,7 @@ Pass 1–4 catalog ids. The jobs share one `group_id`, the capability's active eset, and the same train and eval cells. A model that is not in`GET /api/finetuning-jobs/models/` is refused before any dataset is created.-For typed decision training, call `list_decision_training_models` to see the explicit Clef, D3 and D1 families and their current launch availability. D3 and D1 are discoverable but unavailable until exact preparation and verified probability serving are qualified. Use `start_decision_job` for an available family and a stable `request_key`; it returns a separate `decision_job` ID and the underlying training run. Both IDs refer to the same preparation, monitoring, cancellation, billing and recovery lifecycle. `prepare_training_data` also returns the DecisionJob ID for an applicable setup run. Inspect it with `get_job(kind="decision_job")` or the linked resource, and pass either ID to `inspect_training_progress` and `cancel_finetune`.+For typed decision training, call `list_decision_training_models` to see the explicit Clef, Kev, D3 and D1 families and their current launch availability. Clef and Kev can launch. D3 and D1 are discoverable but unavailable until exact preparation and verified probability serving are qualified. Use `start_decision_job` for an available family and a stable `request_key`; it returns a separate `decision_job` ID and the underlying training run. Both IDs refer to the same preparation, monitoring, cancellation, billing and recovery lifecycle. `prepare_training_data` also returns the DecisionJob ID for an applicable setup run. Inspect it with `get_job(kind="decision_job")` or the linked resource, and pass either ID to `inspect_training_progress` and `cancel_finetune`.The model catalogue returns `openrouter_id` and `openrouter_status` for basebenchmarks. Only `available` establishes a catalogue match; null IDs, `not_listed`diff --git a/overmind/uv.lock b/overmind/uv.lockindex 94036ec7..f2372199 100644--- a/overmind/uv.lock+++ b/overmind/uv.lock@@ -300,7 +300,7 @@ name = "exceptiongroup"version = "1.3.1"source = { registry = "https://pypi.org/simple" }dependencies = [- { name = "typing-extensions" },+ { name = "typing-extensions", marker = "python_full_version < '3.11'" },]sdist = { url = "https://files.pythonhosted.org/packages/50/79/66800aadf48771f6b62f7eb014e352e5d06856655206165d775e675a02c9/exceptiongroup-1.3.1.tar.gz", hash = "sha256:8b412432c6055b0b7d14c310000ae93352ed6754f70fa8f7c34141f91c4e3219", size = 30371, upload-time = "2025-11-21T23:01:54.787Z" }wheels = [@@ -351,8 +351,8 @@ name = "httpcore2"version = "2.13.1"source = { registry = "https://pypi.org/simple" }dependencies = [- { name = "h11" },- { name = "truststore" },+ { name = "h11", marker = "python_full_version < '3.12' or sys_platform != 'emscripten'" },+ { name = "truststore", marker = "python_full_version < '3.12' or sys_platform != 'emscripten'" },]sdist = { url = "https://files.pythonhosted.org/packages/cb/f3/1db7aa2bc2524062192bb0e0323969492d1883152a232fe36eea65f4e35c/httpcore2-2.13.1.tar.gz", hash = "sha256:e0aa977abe17e69a3b820a24542a6fa88702676d83880b8d194dcd18408e5103", size = 68071, upload-time = "2026-09-23T07:47:22.372Z" }wheels = [@@ -923,7 +923,7 @@ wheels = [[[package]]name = "overmind"-version = "0.1.125"+version = "0.1.126"source = { editable = "." }dependencies = [{ name = "packaging" },diff --git a/pyproject.toml b/pyproject.tomlindex d37372c0..9892d5a1 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -36,7 +36,7 @@ dependencies = ["redis>=5.0.0","django-storages>=1.14.6","watchdog>=4.0.0",- "modal>=1.6.1",+ "modal>=1.6.4",# Only migration 0001 imports it, to replay the extension 0142 drops."pgvector>=0.4.2","genai-prices>=0.1.9",@@ -99,7 +99,7 @@ dev = ["ruff>=0.12.0","pre-commit>=4.5.1","python-dotenv>=1.2.1",- "modal>=0.64",+ "modal>=1.6.4",]test = ["overmind[tracing]>=0.1.97",diff --git a/tests/fakes/modal.py b/tests/fakes/modal.pyindex 0d04d267..b9739938 100644--- a/tests/fakes/modal.py+++ b/tests/fakes/modal.py@@ -552,7 +552,9 @@ class DecisionBackend:"artifact_identity": artifact_identity,}- def _pre_warm(self, *, weights_path, artifact_identity, max_model_len, gpu_type) -> dict:+ def _pre_warm(+ self, *, weights_path, artifact_identity, max_model_len, gpu_type, base_model_id=""+ ) -> dict:return {"verified": True, "artifact_identity": artifact_identity}def _serve(self, requests: list[dict]) -> dict:diff --git a/tests/test_base_model_cache.py b/tests/test_base_model_cache.pyindex 068f2056..4a4dd43d 100644--- a/tests/test_base_model_cache.py+++ b/tests/test_base_model_cache.py@@ -5,7 +5,12 @@ from pathlib import Pathimport pytest-from overbae.modal.register_model import _base_model_dir, _snapshot_is_complete+from overbae.modal.register_model import (+ _base_model_dir,+ _snapshot_is_complete,+ cached_base_ready,+ seal_ready_base,+)pytestmark = pytest.mark.covers("model-runtime")@@ -70,6 +75,31 @@ def test_accepts_legacy_single_file_cache(tmp_path: Path):assert _snapshot_is_complete(d)+def test_kev_cache_needs_the_pointer_head(tmp_path: Path):+ d = tmp_path / "base"+ _write_sharded(d, ["a.safetensors"])+ _shard(d, "a.safetensors")+ assert not cached_base_ready(d, "jaredpalmer/kev-0.8b")+ assert cached_base_ready(d, "Qwen/Qwen2.5-0.5B-Instruct")+ (d / "head.pt").write_bytes(b"head")+ assert cached_base_ready(d, "jaredpalmer/kev-0.8b")+++def test_repaired_kev_base_seals_the_pointer_head(tmp_path: Path):+ from modal_shared.serving.artifacts import seal_base++ d = tmp_path / "base"+ _write_sharded(d, ["a.safetensors"])+ _shard(d, "a.safetensors")+ first = seal_base(d, "jaredpalmer/kev-0.8b")+ assert "head.pt" not in first["files"]+ (d / "head.pt").write_bytes(b"head")+ repaired = seal_ready_base(d, "jaredpalmer/kev-0.8b")+ assert repaired["files"]["head.pt"]["size"] == 4+ assert repaired["identity"] != first["identity"]+ assert seal_ready_base(d, "jaredpalmer/kev-0.8b")["identity"] == repaired["identity"]++def test_rejects_missing_dir(tmp_path: Path):assert not _snapshot_is_complete(tmp_path / "nope")diff --git a/tests/test_decision_job_identity.py b/tests/test_decision_job_identity.pyindex 44bd8ab1..ccbda911 100644--- a/tests/test_decision_job_identity.py+++ b/tests/test_decision_job_identity.py@@ -63,8 +63,9 @@ def test_decision_identity_reuses_the_exact_training_run(monkeypatch, settings):catalog = client.get("/api/decision-models/")assert catalog.status_code == 200entries = {entry["id"]: entry for entry in catalog.data}- assert {entry["family"] for entry in entries.values()} == {"clef", "d3", "d1"}+ assert {entry["family"] for entry in entries.values()} == {"clef", "d3", "d1", "kev"}assert entries["Cloudflare/clef-flash"]["training_available"]+ assert entries["jaredpalmer/kev-0.8b"]["training_available"]assert not entries["vllm-sr/d3-edge"]["training_available"]assert "LiquidAI/d1-omni-600M" not in entriespayload = {@@ -106,6 +107,7 @@ def test_decision_identity_reuses_the_exact_training_run(monkeypatch, settings):"clef","d3","d1",+ "kev",}receipt = call_tool("get_job", {"kind": "decision_job", "id": first.data["id"]}, context)assert not receipt.isError, receipt.structuredContentdiff --git a/tests/test_dedicated_lora_merge.py b/tests/test_dedicated_lora_merge.pyindex b6698d1d..ceb37657 100644--- a/tests/test_dedicated_lora_merge.py+++ b/tests/test_dedicated_lora_merge.py@@ -48,6 +48,16 @@ def test_dedicated_lora_uses_the_plain_worker_and_no_runtime_adapter():quantization="fp8",)assert worker_class_name(fp8, "H100") == "H100_vllm_dedicated"+ kev = SimpleNamespace(+ inference_contract="decision",+ base_model_id="jaredpalmer/kev-0.8b",+ )+ clef = SimpleNamespace(+ inference_contract="decision",+ base_model_id="cloudflare/clef-flash",+ )+ assert worker_class_name(kev, "L4") == "L4_sglang_kev_dedicated"+ assert worker_class_name(clef, "L4") == "L4_vllm_dedicated"assert parameters(deployment) == {"model_path": ".base_models/Qwen--Qwen2.5-0.5B-Instruct","model_name": "dedicated/ft-9be76bc2",@@ -58,6 +68,36 @@ def test_dedicated_lora_uses_the_plain_worker_and_no_runtime_adapter():}+def test_kev_dedicated_engine_sends_the_api_key(monkeypatch, tmp_path):+ monkeypatch.setenv("INFERENCE_API_KEY", "secret")+ monkeypatch.setattr(serving, "WEIGHTS_MOUNT", str(tmp_path))+ monkeypatch.setattr(serving, "weights_vol", Mock())+ monkeypatch.setattr(serving, "IS_DEV", False)+ monkeypatch.setattr(serving, "_wait_for_vllm", Mock())+ monkeypatch.setattr(serving._BaseVLLMWorker, "_open_direct", lambda _self: None)+ popen = Mock()+ monkeypatch.setattr(serving.subprocess, "Popen", popen)+ (tmp_path / "base").mkdir()+ worker = serving._BaseVLLMWorker()+ worker.model_path = "base"+ worker.model_name = "dedicated/kev"+ worker.max_model_len = 2048+ worker.enable_lora = False+ worker.max_lora_rank = 16+ worker.gpu_type = "L4"+ worker.snapshot_weights = False+ worker.direct_vllm = True+ worker.engine = "sglang_kev"+ worker.adapter_path = ""+ worker._journal = Mock()++ worker._startup_inner(_json=json, _os=os)++ command = popen.call_args.args[0]+ assert command[command.index("--api-key") + 1] == "secret"+ assert serving._local_vllm_headers(worker, {})["authorization"] == "Bearer secret"++def test_prod_snapshot_engine_enables_the_sleep_route(monkeypatch, tmp_path):obj = serving._BaseVLLMWorker()obj.model_path = "base"diff --git a/tests/test_kev_decision.py b/tests/test_kev_decision.pynew file mode 100644index 00000000..6e534a15--- /dev/null+++ b/tests/test_kev_decision.py@@ -0,0 +1,145 @@+from dataclasses import dataclass++import pytest++from modal_shared.modelfam import resolve+from modal_shared.serving.decision_http import decision_sglang_command+from modal_shared.serving.speculative import draft_for, mtp_for+from modal_shared.stacks import SERVE_SGLANG_KEV, TRAIN_KEV+from overbae.services.sft_assets.kev_engine import (+ admit_kev_row,+ kev_label,+ kev_record,+ kev_record_from_prepared,+)+from overbae.services.sft_assets.preprocess import preprocess_rows++pytestmark = pytest.mark.covers("model-runtime")+++def test_kev_family_uses_its_own_stacks() -> None:+ spec = resolve("jaredpalmer/kev-4b")+ assert spec.key == "kev"+ assert spec.train_image == TRAIN_KEV+ assert spec.serve_image == SERVE_SGLANG_KEV+ command = decision_sglang_command(model_path="/weights/kev", max_model_len=2048, port=8000)+ assert command[:4] == [+ "sglang",+ "serve",+ "--model-path",+ "/weights/kev",+ ]+ assert command[command.index("--context-length") + 1] == "2048"+++def test_kev_serving_stays_on_the_base() -> None:+ command = decision_sglang_command(model_path="/weights/kev", max_model_len=2048, port=8000)+ assert "speculative" not in command+ for repo in ("jaredpalmer/kev-0.8b", "jaredpalmer/kev-4b", "jaredpalmer/kev-9b"):+ assert mtp_for(repo) is None+ assert draft_for(repo) is None+++def test_kev_record_keeps_a_one_hot_choice() -> None:+ row = kev_record(+ {+ "decision": {+ "state": "A coin landed heads.",+ "question": "Which side?",+ "kind": "choice",+ "options": ["heads", "tails"],+ "target_probabilities": [1.0, 0.0],+ }+ }+ )+ assert row["questions"]["decision"]["label"] == "heads"+ assert kev_label(+ {+ "kind": "noul",+ "options": ["no", "yes"],+ "target_probabilities": [0.0, 1.0],+ }+ )+++def test_kev_record_reads_a_prepared_row() -> None:+ row = kev_record_from_prepared(+ {+ "record": {"state": "A coin landed heads."},+ "question": "Which side?",+ "kind": "choice",+ "options": ["heads", "tails"],+ "target_probabilities": [1.0, 0.0],+ }+ )+ assert row["questions"]["decision"]["label"] == "heads"+++def _choice(**extra):+ return {+ "decision": {+ "state": "A coin landed heads.",+ "question": "Which side?",+ "kind": "choice",+ "options": ["heads", "tails"],+ "target_probabilities": [1.0, 0.0],+ **extra,+ }+ }+++def test_kev_preparation_rejects_rows_the_trainer_cannot_use() -> None:+ @dataclass+ class _Encoded:+ input_ids: list[int]+ state: str++ def prepare(row):+ _, report = preprocess_rows(+ [row],+ None,+ "jaredpalmer/kev-0.8b",+ 2048,+ None,+ objective="decision_cross_entropy",+ decision_encode=lambda *_args, **_kwargs: _Encoded(+ input_ids=[1], state=row["decision"]["state"]+ ),+ decision_admit=admit_kev_row,+ )+ return report++ soft = _choice()+ soft["decision"]["target_probabilities"] = [0.7, 0.3]+ weighted = _choice(weight=7)+ mean_only = {+ "decision": {+ "state": "The score is low.",+ "question": "How low?",+ "kind": "score",+ "options": ["low", "high"],+ "target_mean": 0,+ "option_values": [0, 1],+ "target_semantics": "ordinal_mean",+ }+ }+ for row, reason in (+ (soft, "one-hot"),+ (weighted, "weight 1"),+ (mean_only, "one-hot"),+ ):+ report = prepare(row)+ assert report["ready"] is False+ assert reason in report["issues"][0]["reason"]+ assert prepare(_choice())["ready"] is True+++def test_kev_record_refuses_a_soft_target() -> None:+ with pytest.raises(ValueError, match="one-hot"):+ kev_label(+ {+ "kind": "choice",+ "options": ["heads", "tails"],+ "target_probabilities": [0.7, 0.3],+ }+ )diff --git a/tests/test_model_deployment_resume.py b/tests/test_model_deployment_resume.pyindex 89536507..8a9d03f3 100644--- a/tests/test_model_deployment_resume.py+++ b/tests/test_model_deployment_resume.py@@ -1,6 +1,7 @@import jsonimport uuidfrom datetime import timedelta+from types import SimpleNamespacefrom unittest.mock import patchimport pytest@@ -575,6 +576,26 @@ def test_failed_parent_waits_for_child_gpu_work_before_retry(fake_modal):assert deployment.poll_operation("fc-parent") == ("failed", "Remote operation timed out.")+def test_decision_verification_names_the_base_only_for_kev(monkeypatch):+ monkeypatch.setattr("modal.Function.from_name", lambda *_args, **_kwargs: None)++ def deployed(base_model_id):+ return SimpleNamespace(+ inference_contract="decision",+ serving_runtime={"app": "overmind-decision-serve-old", "environment": "overmind-dev"},+ weights_path="/weights/.decisions/abc",+ checkpoint_hash="abc",+ max_model_len=2048,+ gpu_type="H100",+ base_model_id=base_model_id,+ )++ _, clef = deployment.verification_operation(deployed("Cloudflare/clef-flash"))+ _, kev = deployment.verification_operation(deployed("jaredpalmer/kev-0.8b"))+ assert "base_model_id" not in clef+ assert kev["base_model_id"] == "jaredpalmer/kev-0.8b"++def test_lfm3_warm_and_inference_carry_the_base_id(deployed, fake_modal):DeployedModel.objects.filter(pk=deployed.pk).update(model_id="ft-292bb9da-lfm3-1-7b",diff --git a/tests/test_serving_args.py b/tests/test_serving_args.pyindex d57460a7..72468bf6 100644--- a/tests/test_serving_args.py+++ b/tests/test_serving_args.py@@ -419,8 +419,13 @@ def test_systemone_probabilities_follow_the_option_order() -> None:assert body["model"] == "decision"assert body["questions"]["0"]["criteria"] == {"low": "low", "high": "high"}assert probabilities_for(request, {"probabilities": {"low": 0.2, "high": 0.8}}) == [0.2, 0.8]- noul = {**request, "kind": "noul"}+ noul = {**request, "kind": "noul", "options": ["No", "Yes"]}assert probabilities_for(noul, {"noul": 0.75}) == [0.25, 0.75]+ assert probabilities_for(noul, {"noul": 0.98, "probabilities": {"yes": 0.98, "no": 0.02}}) == [+ 0.02,+ 0.98,+ ]+ assert probabilities_for(noul, {"probabilities": {"no": 0.2, "yes": 0.8}}) == [0.2, 0.8]def test_binary_serving_keeps_custom_false_and_true_criteria():diff --git a/tests/test_stacks.py b/tests/test_stacks.pyindex e4406f8b..204b14be 100644--- a/tests/test_stacks.py+++ b/tests/test_stacks.py@@ -43,8 +43,11 @@ def test_every_family_train_image_is_a_known_stack() -> None:def test_canaries_cover_unsloth_stacks() -> None:+ from modal_shared.stacks import TRAIN_STACK_PINS+covered = {c.stack for c in TRAIN_CANARIES}- missing = set(TRAIN_STACKS) - covered+ unsloth = {stack for stack, pin in TRAIN_STACK_PINS.items() if "unsloth" in pin}+ missing = unsloth - coveredassert not missing, f"unsloth stacks with no canary: {missing}"diff --git a/uv.lock b/uv.lockindex 148018cc..3daeae86 100644--- a/uv.lock+++ b/uv.lock@@ -2,9 +2,12 @@ version = 1revision = 3requires-python = ">=3.13"resolution-markers = [- "python_full_version >= '3.14' and sys_platform == 'win32'",- "python_full_version >= '3.14' and sys_platform == 'emscripten'",- "python_full_version >= '3.14' and sys_platform != 'emscripten' and sys_platform != 'win32'",+ "python_full_version >= '3.15' and sys_platform == 'win32'",+ "python_full_version == '3.14.*' and sys_platform == 'win32'",+ "python_full_version >= '3.15' and sys_platform == 'emscripten'",+ "python_full_version == '3.14.*' and sys_platform == 'emscripten'",+ "python_full_version >= '3.15' and sys_platform != 'emscripten' and sys_platform != 'win32'",+ "python_full_version == '3.14.*' and sys_platform != 'emscripten' and sys_platform != 'win32'","python_full_version < '3.14' and sys_platform == 'win32'","python_full_version < '3.14' and sys_platform == 'emscripten'","python_full_version < '3.14' and sys_platform != 'emscripten' and sys_platform != 'win32'",@@ -385,7 +388,7 @@ requires-dist = [{ name = "markdownify", specifier = ">=1.2.3" },{ name = "matplotlib", specifier = ">=3.11.2" },{ name = "mcp", specifier = ">=1.26.0,<2" },- { name = "modal", specifier = ">=1.6.1" },+ { name = "modal", specifier = ">=1.6.4" },{ name = "newrelic", specifier = ">=13.4.0" },{ name = "numpy", specifier = ">=2.0" },{ name = "openai", specifier = ">=1.0.0" },@@ -424,7 +427,7 @@ requires-dist = [[package.metadata.requires-dev]dev = [- { name = "modal", specifier = ">=0.64" },+ { name = "modal", specifier = ">=1.6.4" },{ name = "pre-commit", specifier = ">=4.5.1" },{ name = "python-dotenv", specifier = ">=1.2.1" },{ name = "ruff", specifier = ">=0.12.0" },@@ -1720,8 +1723,8 @@ name = "httpcore2"version = "2.12.0"source = { registry = "https://pypi.org/simple" }dependencies = [- { name = "h11" },- { name = "truststore" },+ { name = "h11", marker = "sys_platform != 'emscripten'" },+ { name = "truststore", marker = "sys_platform != 'emscripten'" },]sdist = { url = "https://files.pythonhosted.org/packages/be/ad/f4f0e57345f1870f3e8cb624e058d7eca6e5a27d33bcc3311d9b618734cd/httpcore2-2.12.0.tar.gz", hash = "sha256:9293522bba0aa7c4c8e9e3f040c16575bd8868e155a77fa30c7a9085a5eae648", size = 67548, upload-time = "2026-08-18T13:22:08.211Z" }wheels = [@@ -2501,7 +2504,7 @@ wheels = [[[package]]name = "modal"-version = "1.6.1"+version = "1.6.4"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "aiohttp" },@@ -2518,9 +2521,9 @@ dependencies = [{ name = "typing-extensions" },{ name = "watchfiles" },]-sdist = { url = "https://files.pythonhosted.org/packages/65/ba/2b36899ea5633bf101e6ba6f7e95a4da3e4b1f57f52bd0ba8f4cfd12e808/modal-1.6.1.tar.gz", hash = "sha256:ff17768f67a65595aa7882e893e6cb78e2e001b3653aa52cfe98d4051d8d9e9e", size = 942670, upload-time = "2026-10-03T16:05:05.428Z" }+sdist = { url = "https://files.pythonhosted.org/packages/9d/e3/d2204428fcbce9e017cb9a3daac5eb55f3bed9253adadd802ffe27f4d45c/modal-1.6.4.tar.gz", hash = "sha256:3c94bbe27444dbb1ce3631f7be5b16ef6e21a7b126a485a6feb3fcd62343abe6", size = 1057595, upload-time = "2026-11-12T04:15:34.357Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/d2/3c/6b7d9a15dab9af2833ce674bbc72b5654d4099d5b088f1cc1eda3f8249ca/modal-1.6.1-py3-none-any.whl", hash = "sha256:f408ef88563003a83e491a6be09d4221eaa6e038fa4faa2ad8b15b25afe949a4", size = 1063454, upload-time = "2026-10-03T16:05:02.554Z" },+ { url = "https://files.pythonhosted.org/packages/e2/83/4ba3719b4367ecd2bd295e993767f9db45722e35a08f6fc7350c9bcc4d2b/modal-1.6.4-py3-none-any.whl", hash = "sha256:1bb631edeb7c4eae86be330430924784bf54b646cd16dc996a229c1ef81f6c9d", size = 1190877, upload-time = "2026-11-12T04:15:31.029Z" },][[package]]@@ -4649,14 +4652,14 @@ wheels = [[[package]]name = "synchronicity"-version = "0.12.6"+version = "0.12.7"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "typing-extensions" },]-sdist = { url = "https://files.pythonhosted.org/packages/ee/5f/9f6f7df5919f0d085013b96b9cb99b622b974fe722a04c126c10497bba8b/synchronicity-0.12.6.tar.gz", hash = "sha256:ac971eadb64c95938816b8d6125d6e28473982f3256789a35bdbe02025e1ce17", size = 62425, upload-time = "2026-10-02T15:41:43.739Z" }+sdist = { url = "https://files.pythonhosted.org/packages/f2/0d/68d6a97dead45e2704cd431df2ed5f92c9bdea620239d6129b16becc7508/synchronicity-0.12.7.tar.gz", hash = "sha256:6d86ba0fb797cc3cb7637f97cf9472a3ed20e50e85130b44c3292b43e2389b90", size = 63402, upload-time = "2026-10-26T16:56:34.492Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/4e/9c/8408129632f2cbd70018cff4a7eb78cc105b141de233b699feeda15d44c9/synchronicity-0.12.6-py3-none-any.whl", hash = "sha256:bc2bab6dde31f6bd9389912cef573b7fa7a5cb4a120ec786275e3284f06473ae", size = 41971, upload-time = "2026-10-02T15:41:42.672Z" },+ { url = "https://files.pythonhosted.org/packages/a8/c8/fb85647116e63031344b65f16ebfcc263f30bd46c12266e70bc9a96cdc7d/synchronicity-0.12.7-py3-none-any.whl", hash = "sha256:75f1a4e91a6af24b6576c242d95e9f1bcf061fab90feb8d1d3a6fa54b349a77d", size = 42245, upload-time = "2026-10-26T16:56:32.903Z" },][[package]]