The platform for continuously improving AI agents.
Route shared-pool winners to SGLang and move serverless vLLM to 0.33.0 (#314)
Rohit Gupta1a6ee5c6eb1c
diff --git a/.agents/skills/backend-architecture/references/serving.md b/.agents/skills/backend-architecture/references/serving.mdindex 17189848..7689a6ba 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. Bases where SGLang won the sentence bench use `{gpu}_sglang_dedicated` (`lmsysorg/sglang:v0.5.22`) and fold the LoRA into a local checkpoint before launch. Gemma 4, Muse, Qwen3-Coder, and Llama stay on `{gpu}_vllm_dedicated` (`vllm/vllm-openai:v0.33.0`), which still snapshots the slept engine. SGLang containers do not; they open the port forward once the server is healthy. The shared inference pool stays on v0.30.0. Engine choice is internal; MCP start, stop, and `run_inference` are unchanged. 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 deployments use the same `{gpu}_vllm_dedicated` class and `POST /v1/systemone`. They report latency only. Serverless decision calls stay on `DecisionEndpoint` in the model's decision-serving app, which boots vLLM 0.33.0 and posts `/v1/systemone` in the container. One artifact still owns that container. A catalog base with no artifact is the same class with `base_repo` set and no LoRA. 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 vLLM LoRA is applied while `{gpu}_vllm_dedicated` reads the base shards. Those shards are symlinked into the serve directory, not copied. An SGLang LoRA is written out as a folded checkpoint on container disk, with the same delta, and the server reads that directory. Dedicated chat turns thinking off on every request. Auto tool choice leaves parallel calls on unless the request disables them. A required or named tool choice is one call unless the request sets parallel_tool_calls. Gemma 4 and Muse constrain that choice to their native tool-call syntax, because their parsers skip JSON guided decoding. gpt-oss stops a required or named choice after one call. A harmony call left in the message text is returned as that tool call. tool_choice none omits the tool list. SGLang launch passes that family's tool parser, mapping openai to gpt-oss, llama3_json to llama3, and muse_glimmer to muse. 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. Dedicated chat looks up the worker once, then posts to the port forward on that container. A parametrized web endpoint cannot accept POST. Shared inference still uses the `infer` RPC. Chat completions with `stream: true` 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. Bases where SGLang won the sentence bench use `{gpu}_sglang_dedicated` (`lmsysorg/sglang:v0.5.22`) and fold the LoRA into a local checkpoint before launch. Gemma 4, Muse, Qwen3-Coder, and Llama stay on `{gpu}_vllm_dedicated` (`vllm/vllm-openai:v0.33.0`), which still snapshots the slept engine. SGLang containers do not; they open the port forward once the server is healthy. The shared inference pool runs vLLM 0.33.0. Bases where the adapter bake-off measured a higher SGLang tok/s use `{gpu}_sglang_lora` (`lmsysorg/sglang:v0.5.22`) with runtime LoRA and no GPU snapshot. LFM3 uses `{gpu}_sglang_lfm3_lora` (`lmsysorg/sglang:dev-lfm3`). A snapshot captured on v0.30.0 does not restore onto v0.33.0; the next boot captures a new one. Engine choice is internal; MCP start, stop, and `run_inference` are unchanged. 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 deployments use the same `{gpu}_vllm_dedicated` class and `POST /v1/systemone`. They report latency only. Serverless decision calls stay on `DecisionEndpoint` in the model's decision-serving app, which boots vLLM 0.33.0 and posts `/v1/systemone` in the container. One artifact still owns that container. A catalog base with no artifact is the same class with `base_repo` set and no LoRA. 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 vLLM LoRA is applied while `{gpu}_vllm_dedicated` reads the base shards. Those shards are symlinked into the serve directory, not copied. An SGLang LoRA is written out as a folded checkpoint on container disk, with the same delta, and the server reads that directory. Dedicated chat turns thinking off on every request. Auto tool choice leaves parallel calls on unless the request disables them. A required or named tool choice is one call unless the request sets parallel_tool_calls. Gemma 4 and Muse constrain that choice to their native tool-call syntax, because their parsers skip JSON guided decoding. gpt-oss stops a required or named choice after one call. A harmony call left in the message text is returned as that tool call. tool_choice none omits the tool list. SGLang launch passes that family's tool parser, mapping openai to gpt-oss, llama3_json to llama3, and muse_glimmer to muse. 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. Dedicated chat looks up the worker once, then posts to the port forward on that container. A parametrized web endpoint cannot accept POST. Shared inference still uses the `infer` RPC. Chat completions with `stream: true` 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.## Workersdiff --git a/modal_shared/images/serve.py b/modal_shared/images/serve.pyindex de198562..664c923f 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_VLLM+from modal_shared.stacks import SERVE_SGLANG, SERVE_SGLANG_LFM3, SERVE_VLLM_SERVE_ENV = {# Container-local. Serving resolves every model by path — a merged checkpoint, or an adapter@@ -52,13 +52,11 @@ def _from_vllm_openai(tag: str, *extra_pip: str, snapshot: bool = False) -> moda)-# CUDA 13.0. Modal's host driver is 580 / CUDA 13.0. Do not pip-downgrade-# transformers: 0.30.0 ships 5.16.1, and Gemma 4 head_dim (#49797) plus Muse-# LoRA get_mm_mapping (#53513) both need this release.-_VLLM_TAG = "v0.30.0"+# Modal's host driver is 580 / CUDA 13.0. Shared and dedicated pools use this tag.+# A snapshot captured on 0.30.0 does not restore here; the next boot captures a new one.+_VLLM_TAG = "v0.33.0"vllm_image = _from_vllm_openai(_VLLM_TAG)-# Dedicated pools only. The shared inference app stays on _VLLM_TAG.-_DEDICATED_VLLM_TAG = "v0.33.0"+_DEDICATED_VLLM_TAG = _VLLM_TAGdedicated_vllm_image = _from_vllm_openai(_DEDICATED_VLLM_TAG)# v0.5.23-cu130 lowered Qwen3.5-4B from 443 to 347 tok/s on H100._DEDICATED_SGLANG_TAG = "v0.5.22"@@ -79,6 +77,8 @@ dedicated_sglang_lfm3_image = attach_serving_args(SERVE_IMAGES: dict[str, modal.Image] = {SERVE_VLLM: vllm_image,+ SERVE_SGLANG: dedicated_sglang_image,+ SERVE_SGLANG_LFM3: dedicated_sglang_lfm3_image,}# The snapshot reader uses a version-specific pinned-buffer allocation site.diff --git a/modal_shared/modelfam/families.py b/modal_shared/modelfam/families.pyindex 7a8fe011..b1d88f90 100644--- a/modal_shared/modelfam/families.py+++ b/modal_shared/modelfam/families.py@@ -114,7 +114,7 @@ MUSE_GLIMMER = FamilySpec(multimodal_id_tokens=("muse-glimmer", "muse_glimmer"),notes=("Meta Muse Glimmer multimodal agentic; FastModel; LoRA-only; dedicated u2026_8_tf515 "- "train image. Serves on the shared vLLM image — v0.30.0 has the LoRA "+ "train image. Serves on the shared vLLM image — v0.33.0 has the LoRA ""multimodal-mapping fix (vLLM #53513)."),hooks_module="families.muse_glimmer",diff --git a/modal_shared/modelfam/registry.py b/modal_shared/modelfam/registry.pyindex 0970755a..95b2caf7 100644--- a/modal_shared/modelfam/registry.py+++ b/modal_shared/modelfam/registry.py@@ -70,10 +70,19 @@ def resolve(model_id: str) -> FamilySpec:def serve_image_key(*blobs: str) -> str:- """First non-default FamilySpec.serve_image across id fragments, else ``vllm``."""+ """Shared-pool image for these ids.++ A bake-off winner is matched by model id before the family default, because+ one family contains both SGLang and vLLM winners.+ """+ from modal_shared.serving.engine import serverless_engine+for blob in blobs:if not blob:continue+ engine = serverless_engine(blob)+ if engine != "vllm":+ return enginekey = resolve(blob).serve_imageif key != "vllm":return keydiff --git a/modal_shared/modelfam/spec.py b/modal_shared/modelfam/spec.pyindex e6dad984..9f528bff 100644--- a/modal_shared/modelfam/spec.py+++ b/modal_shared/modelfam/spec.py@@ -19,7 +19,7 @@ class FamilySpec:patterns: tuple[str, ...]# Modal/Baseten Unsloth image key — frozen stack id in modal_shared.stacks.train_image: str = "u2026_8_18"- # Serve image key. Every family uses "vllm" (vllm/vllm-openai:v0.30.0).+ # Family default. Per-model shared-pool overrides live in serverless_engine.serve_image: str = "vllm"trust_remote_code: bool = False# Antares/Granite MoE hybrid — skip Unsloth for_inference / use_cache.diff --git a/modal_shared/serving/args.py b/modal_shared/serving/args.pyindex 5a35c956..3e7e3ea0 100644--- a/modal_shared/serving/args.py+++ b/modal_shared/serving/args.py@@ -60,13 +60,33 @@ def snap_lora_rank(rank: int) -> int:def lora_load_request(name: str, path: str) -> dict:config = json.loads((Path(path) / "adapter_config.json").read_text())parameters = config.get("target_parameters") or []+ modules = config.get("target_modules") or ""+ expert = any("experts" in str(item) for item in (*parameters, modules))return {"lora_name": name,"lora_path": path,- "is_3d_lora_weight": any(p.endswith("experts.gate_up_proj") for p in parameters),+ "is_3d_lora_weight": expert,}+def kv_cache_dtype(gpu_type: str, spec: FamilySpec) -> str:+ """FP8 KV, except where vLLM 0.33's Triton attention rejects it.++ Triton on Ampere (A100, SM80) raises unless the cache is bf16. These two+ families select Triton; FlashInfer families on the same GPU keep FP8.+ """+ if gpu_type.startswith("A100") and spec.key in {"gpt_oss", "gemma4"}:+ return "bfloat16"+ return "fp8"+++def mixed_moe_lora(spec: FamilySpec, base_model: str) -> bool:+ """Gemma 4 26B-A4B is the only Gemma 4 whose expert LoRA is the fused 3D layout."""+ if spec.mixed_moe_lora_format:+ return True+ return spec.key == "gemma4" and "a4b" in base_model.lower()++@dataclass(frozen=True)class VllmServeContext:model_path: str@@ -91,6 +111,10 @@ class VllmServeContext:# DFlash draft directory on the weights volume. Empty leaves speculative decoding off.draft_model: str = ""draft_tokens: int = 0+ # In-checkpoint MTP. Qwen3.5's hybrid cache accepts one token on this method.+ mtp_tokens: int = 0+ # Empty keeps FP8 KV. A100 is SM80; see kv_cache_dtype.+ gpu_type: str = ""def _serve_chat_template_path(model_path: str) -> str | None:@@ -134,7 +158,7 @@ def build_vllm_args(ctx: VllmServeContext, spec: FamilySpec | None = None) -> li"--max-num-seqs",str(ctx.max_num_seqs),"--kv-cache-dtype",- "fp8",+ kv_cache_dtype(ctx.gpu_type, spec),"--enable-force-include-usage","--enable-auto-tool-choice","--tool-call-parser",@@ -164,7 +188,7 @@ def build_vllm_args(ctx: VllmServeContext, spec: FamilySpec | None = None) -> licmd += ["--dtype", spec.dtype_override or "bfloat16"]if ctx.lora_adapters or ctx.enable_lora:- if spec.mixed_moe_lora_format:+ if mixed_moe_lora(spec, ctx.base_model or ctx.model_name):cmd.append("--enable-mixed-moe-lora-format")# A pool that loads adapters at runtime has none to count, so it takes the full# slot allowance.@@ -193,7 +217,7 @@ def build_vllm_args(ctx: VllmServeContext, spec: FamilySpec | None = None) -> li]# The short capture list drops DFlash acceptance to about 5%, and the draft# overhead then makes the server slower than the base. vLLM's own list does not.- if not ctx.draft_model:+ if not ctx.draft_model and not ctx.mtp_tokens:cmd += ["--cudagraph-capture-sizes",*([str(s) for s in CUDAGRAPH_CAPTURE_SIZES if s <= ctx.max_num_seqs] or ["1"]),@@ -202,7 +226,15 @@ def build_vllm_args(ctx: VllmServeContext, spec: FamilySpec | None = None) -> lichat_tmpl = _serve_chat_template_path(ctx.chat_template_dir or ctx.model_path)if chat_tmpl:cmd += ["--chat-template", chat_tmpl]- if ctx.draft_model:+ if ctx.mtp_tokens:+ cmd += [+ "--speculative-config",+ json.dumps(+ {"method": "mtp", "num_speculative_tokens": ctx.mtp_tokens},+ separators=(",", ":"),+ ),+ ]+ elif ctx.draft_model:cmd += ["--speculative-config",json.dumps(diff --git a/modal_shared/serving/engine.py b/modal_shared/serving/engine.pyindex 425246e5..6d014815 100644--- a/modal_shared/serving/engine.py+++ b/modal_shared/serving/engine.py@@ -41,3 +41,52 @@ def engine_for(repo: str) -> str:if repo in _SGLANG:return "sglang"return "vllm"+++# Adapter bake-off, both engines serving the same LoRA, higher decode tok/s.+# This is not the dedicated sentence map: Qwen3-14B and the small Qwen2.5 and+# Llama rows won here and lost there, and the reverse is true for gpt-oss.+_SERVERLESS_SGLANG = frozenset(+ {+ "Qwen/Qwen3.5-0.8B",+ "unsloth/Qwen3.5-0.8B",+ "Qwen/Qwen3.5-2B",+ "unsloth/Qwen3.5-2B",+ "Qwen/Qwen3.5-4B",+ "unsloth/Qwen3.5-4B",+ "Qwen/Qwen3.5-9B",+ "unsloth/Qwen3.5-9B",+ "Qwen/Qwen3.5-35B-A3B",+ "unsloth/Qwen3.5-35B-A3B",+ "Qwen/Qwen3-0.6B",+ "unsloth/Qwen3-0.6B",+ "Qwen/Qwen3-1.7B",+ "unsloth/Qwen3-1.7B",+ "Qwen/Qwen3-4B",+ "unsloth/Qwen3-4B",+ "Qwen/Qwen3-8B",+ "unsloth/Qwen3-8B",+ "Qwen/Qwen3-14B",+ "unsloth/Qwen3-14B",+ "Qwen/Qwen2.5-0.5B-Instruct",+ "unsloth/Qwen2.5-0.5B-Instruct",+ "Qwen/Qwen2.5-7B-Instruct",+ "unsloth/Qwen2.5-7B-Instruct",+ "Qwen/Qwen2.5-14B-Instruct",+ "unsloth/Qwen2.5-14B-Instruct",+ "meta-llama/Llama-3.2-1B-Instruct",+ "unsloth/Llama-3.2-1B-Instruct",+ "meta-llama/Llama-3.2-3B-Instruct",+ "unsloth/Llama-3.2-3B-Instruct",+ "fdtn-ai/antares-350m",+ }+)+++def serverless_engine(repo: str) -> str:+ """Shared-pool engine. vLLM except where an adapter bake-off picked SGLang."""+ if repo in _SGLANG_LFM3:+ return "sglang_lfm3"+ if repo in _SERVERLESS_SGLANG:+ return "sglang"+ return "vllm"diff --git a/modal_shared/serving/lfm3_lora.py b/modal_shared/serving/lfm3_lora.pynew file mode 100644index 00000000..e690c86e--- /dev/null+++ b/modal_shared/serving/lfm3_lora.py@@ -0,0 +1,81 @@+"""Hidden sizes the LFM3 SGLang image does not know.++The conv and MLP leaves are Linear modules with names SGLang's loader has no+case for. Shapes are the LFM3 modeling file: in_proj is hidden to 3*hidden,+out_proj is square, w1 and w3 expand, w2 contracts.+"""++from __future__ import annotations++import os+import sys+from pathlib import Path++# This image sizes q/k/v/o, the conv projections, and out_proj.+# w1, w2, and w3 have no LoRA buffer here.+SGLANG_TARGETS = "q_proj,k_proj,v_proj,o_proj,in_proj,out_proj"+++def stacked_multiply(module_name: str) -> int | None:+ # SGLang's default map packs every in_proj into two slices. This conv is three.+ if module_name == "in_proj":+ return 3+ return None+++def hidden_dim(module_name: str, hidden: int, intermediate: int) -> tuple[int, int] | None:+ if module_name == "in_proj":+ return hidden, 3 * hidden+ if module_name == "out_proj":+ return hidden, hidden+ if module_name in {"w1", "w3"}:+ return hidden, intermediate+ if module_name == "w2":+ return intermediate, hidden+ return None+++def install() -> None:+ try:+ from sglang.srt.lora import utils as lora_utils+ except ImportError:+ return+ original = lora_utils.get_default_hidden_dim+ original_stack = lora_utils.get_stacked_multiply++ def get_default_hidden_dim(module_name, config, layer_idx=0, lora_added_vocab_size=0):+ known = hidden_dim(+ module_name,+ int(config.hidden_size),+ int(getattr(config, "intermediate_size", 0) or 0),+ )+ if known is not None:+ return known+ return original(module_name, config, layer_idx, lora_added_vocab_size)++ def get_stacked_multiply(module_name, base_model=None):+ # The default map treats every in_proj as Mamba's 2-way pack.+ # LFM3's conv projection is B, C, and x.+ known = stacked_multiply(module_name)+ if known is not None:+ return known+ return original_stack(module_name, base_model)++ lora_utils.get_default_hidden_dim = get_default_hidden_dim+ lora_utils.get_stacked_multiply = get_stacked_multiply+ for module in list(sys.modules.values()):+ if getattr(module, "get_default_hidden_dim", None) is original:+ module.get_default_hidden_dim = get_default_hidden_dim+ if getattr(module, "get_stacked_multiply", None) is original_stack:+ module.get_stacked_multiply = get_stacked_multiply+++def process_env() -> dict[str, str]:+ site = Path("/tmp/overmind-lfm3")+ site.mkdir(parents=True, exist_ok=True)+ (site / "sitecustomize.py").write_text(+ "import modal_shared.serving.lfm3_lora as lfm3\nlfm3.install()\n"+ )+ env = os.environ.copy()+ env["PYTHONPATH"] = str(site) + os.pathsep + env.get("PYTHONPATH", "")+ return envdiff --git a/modal_shared/serving/nemotron_lora.py b/modal_shared/serving/nemotron_lora.pynew file mode 100644index 00000000..974ca170--- /dev/null+++ b/modal_shared/serving/nemotron_lora.py@@ -0,0 +1,33 @@+"""Nemotron-H expert LoRA is the stacked 3D layout.++vLLM 0.33 leaves ``is_3d_moe_weight`` unset, so the 2D MoE wrapper receives one+tensor and asserts. Attention-only adapters never reach that wrapper.+"""++from __future__ import annotations++import os+from pathlib import Path+++def mark(cls: type) -> None:+ cls.is_3d_moe_weight = True+++def install() -> None:+ try:+ from vllm.model_executor.models.nemotron_h import NemotronHForCausalLM+ except ImportError:+ return+ mark(NemotronHForCausalLM)+++def process_env() -> dict[str, str]:+ site = Path("/tmp/overmind-nemotron")+ site.mkdir(parents=True, exist_ok=True)+ (site / "sitecustomize.py").write_text(+ "import modal_shared.serving.nemotron_lora as nemotron\nnemotron.install()\n"+ )+ env = os.environ.copy()+ env["PYTHONPATH"] = str(site) + os.pathsep + env.get("PYTHONPATH", "")+ return envdiff --git a/modal_shared/serving/sglang.py b/modal_shared/serving/sglang.pyindex 238ea36f..5b3df398 100644--- a/modal_shared/serving/sglang.py+++ b/modal_shared/serving/sglang.py@@ -12,6 +12,8 @@ _TOOL_PARSER_NAMES = {_REASONING_PARSER_NAMES = {"openai_gptoss": "gpt-oss","muse_glimmer": "muse",+ # vLLM calls this nemotron_v3. SGLang 0.5.22's choice is nemotron_3.+ "nemotron_v3": "nemotron_3",}@@ -25,11 +27,15 @@ def sglang_reasoning_parser(name: str) -> str:def attention_backend(gpu_type: str, *, model: str = "") -> str:# fa3 is the Hopper kernel. On Ada and Ampere it dies during graph capture.- if "lfm3" in model.lower():+ lowered = model.lower()+ if "lfm3" in lowered:# The LFM3 server picks flashinfer itself. fa3 mismatches the conv blocks.return ""+ # Gemma 4 rejects flashinfer. The accepted backends are triton, trtllm_mha, fa4, aiter.+ if "gemma" in lowered:+ return "triton"hopper = gpu_type in {"H100", "H200"} or not gpu_type- if "gpt-oss" in model:+ if "gpt-oss" in lowered:# This architecture rejects flashinfer. Triton runs on the other GPUs.return "fa3" if hopper else "triton"if hopper:@@ -49,6 +55,10 @@ def build_sglang_args(reasoning_parser: str = "",gpu_type: str = "",model: str = "",+ enable_lora: bool = False,+ max_lora_rank: int = 16,+ lora_target_modules: str = "",+ mem_fraction: str = "0.75",) -> list[str]:cmd = ["python3",@@ -66,7 +76,7 @@ def build_sglang_args(cmd += ["--attention-backend", backend]cmd += ["--mem-fraction-static",- "0.75",+ mem_fraction,"--dtype","bfloat16","--trust-remote-code",@@ -96,8 +106,75 @@ def build_sglang_args("--speculative-num-draft-tokens",str(draft_tokens),]+ if enable_lora:+ # One comma-separated string is rejected unless it is all or all-linear.+ modules = [+ part.strip() for part in (lora_target_modules or "all").split(",") if part.strip()+ ]+ cmd += [+ "--enable-lora",+ "--max-lora-rank",+ str(max_lora_rank),+ "--lora-target-modules",+ *modules,+ ]if tool_call_parser:cmd += ["--tool-call-parser", sglang_tool_parser(tool_call_parser)]if reasoning_parser:cmd += ["--reasoning-parser", sglang_reasoning_parser(reasoning_parser)]return cmd+++def normalize_sglang_adapter(adapter_dir, *, keep_targets: str = "") -> None:+ """SGLang accepts ``all``, ``all-linear``, or a list of module names.++ Unsloth writes a regex. A family with an explicit target list replaces that+ regex with the list; every other family becomes ``all-linear``.+ """+ import json+ from pathlib import Path++ path = Path(adapter_dir) / "adapter_config.json"+ if not path.is_file():+ return+ cfg = json.loads(path.read_text())+ targets = cfg.get("target_modules")+ if keep_targets:+ wanted = [part.strip() for part in keep_targets.split(",") if part.strip()]+ cfg["target_modules"] = wanted+ path.write_text(json.dumps(cfg))+ _keep_lora_leaves(Path(adapter_dir), set(wanted))+ return+ if not isinstance(targets, str) or targets in {"all", "all-linear"}:+ return+ cfg["target_modules"] = "all-linear"+ path.write_text(json.dumps(cfg))+++def _keep_lora_leaves(adapter_dir, leaves: set[str]) -> None:+ from pathlib import Path++ weight_path = Path(adapter_dir) / "adapter_model.safetensors"+ if not weight_path.is_file():+ return+ from safetensors import safe_open+ from safetensors.torch import save_file++ suffixes = (+ ".lora_A.weight",+ ".lora_B.weight",+ ".lora_A.default.weight",+ ".lora_B.default.weight",+ )+ kept = {}+ with safe_open(weight_path, framework="pt") as handle:+ for key in handle.keys(): # noqa: SIM118+ name = key+ for suffix in suffixes:+ if name.endswith(suffix):+ name = name[: -len(suffix)]+ break+ if name.split(".")[-1] in leaves:+ kept[key] = handle.get_tensor(key)+ if kept:+ save_file(kept, weight_path)diff --git a/modal_shared/serving/speculative.py b/modal_shared/serving/speculative.pyindex 7faa0e24..a531ba0d 100644--- a/modal_shared/serving/speculative.py+++ b/modal_shared/serving/speculative.py@@ -49,8 +49,22 @@ def mtp_for(repo: str) -> tuple[int, int, int] | None:return _MTP.get(repo)-def draft_for(repo: str) -> tuple[str, int] | None:- return _DRAFTS.get(repo)+# 15-token DFlash on this hybrid leaves 2.9 GiB of KV on an 80GB GPU, and the+# configured 16384 context needs 3.35. H200 (141) and larger still take the draft.+_DRAFT_MIN_VRAM_GB = {+ "Qwen/Qwen3.5-27B": 141,+ "unsloth/Qwen3.5-27B": 141,+}+++def draft_for(repo: str, *, vram_gb: float | None = None) -> tuple[str, int] | None:+ found = _DRAFTS.get(repo)+ if found is None:+ return None+ floor = _DRAFT_MIN_VRAM_GB.get(repo)+ if floor is not None and vram_gb is not None and vram_gb < floor:+ return None+ return founddef draft_volume_path(mount: str, draft_repo: str) -> str:diff --git a/modal_shared/stacks.py b/modal_shared/stacks.pyindex 9323539f..652fd605 100644--- a/modal_shared/stacks.py+++ b/modal_shared/stacks.py@@ -86,28 +86,26 @@ def train_function_name(stack_or_alias: str | None) -> str:# --- serve stacks (FamilySpec.serve_image / routing headers) ----------------# One image. v0.30.0 has Muse Glimmer (#51655) and the LoRA mapping fix-# (#53513), so Muse no longer needs its own tag.+# vLLM 0.33.0 is the shared pool and the dedicated pool. SGLang is the shared+# pool for the adapter bake-off winners only. LFM3 has its own image.SERVE_VLLM = "vllm"+SERVE_SGLANG = "sglang"+SERVE_SGLANG_LFM3 = "sglang_lfm3"-SERVE_STACKS: tuple[str, ...] = (SERVE_VLLM,)+SERVE_STACKS: tuple[str, ...] = (SERVE_VLLM, SERVE_SGLANG, SERVE_SGLANG_LFM3)SERVE_STACK_PINS: dict[str, str] = {- SERVE_VLLM: "vllm/vllm-openai:v0.30.0 + runai-model-streamer>=0.15.7",+ 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",}# (gpu_type, serve_image) pairs we deploy. Cls name is ``{gpu}_{serve_image}``# with hyphens stripped from gpu (A100-80GB → A10080GB_vllm).+_SERVERLESS_GPUS = ("L4", "L40S", "A100-80GB", "H200", "B200", "B300")WORKER_ALLOWED: frozenset[tuple[str, str]] = frozenset(- {- ("L4", SERVE_VLLM),- ("L40S", SERVE_VLLM),- ("A100-80GB", SERVE_VLLM),- ("H200", SERVE_VLLM),- ("B200", SERVE_VLLM),- ("B300", SERVE_VLLM),- }+ (gpu, image) for image in SERVE_STACKS for gpu in _SERVERLESS_GPUS)diff --git a/overbae/modal/modal_vllm_worker.py b/overbae/modal/modal_vllm_worker.pyindex 7d5077a5..fa38fcdf 100644--- a/overbae/modal/modal_vllm_worker.py+++ b/overbae/modal/modal_vllm_worker.py@@ -445,9 +445,10 @@ class _BaseVLLMWorker:draft_model = ""draft_tokens = 0bf16 = (quantization or "bf16") in ("bf16", "none", "")+ vram_gb = GPU_VRAM_GB.get(getattr(self, "gpu_type", ""), 0)# An FP8 merged checkpoint stays on the base; the head and the drafts are BF16.mtp = mtp_for(base_model) if bf16 else None- found = None if mtp or not bf16 else draft_for(base_model)+ found = None if mtp or not bf16 else draft_for(base_model, vram_gb=vram_gb or None)if found:repo, draft_tokens = founddraft_model = draft_volume_path(WEIGHTS_MOUNT, repo)@@ -455,7 +456,6 @@ class _BaseVLLMWorker:raise RuntimeError(f"DFlash draft {repo} is not on the weights volume ({draft_model})")- vram_gb = GPU_VRAM_GB.get(getattr(self, "gpu_type", ""), 0)cap = sequence_cap_for_checkpoint(Path(full_path), vram_gb=vram_gb, max_model_len=self.max_model_len)@@ -471,6 +471,9 @@ class _BaseVLLMWorker:from modal_shared.serving.sglang import build_sglang_args# gpt-oss has no thinking-off switch. The parser keeps analysis out of content.+ # The LFM3 image's --lora-target-modules allowlist has no conv or MLP+ # names. "all" admits them; the hidden-dim patch supplies their shapes.+ lora_targets = "all" if engine == "sglang_lfm3" else (spec.lora_target_modules or "")cmd = build_sglang_args(model_path=full_path,served_name=self.model_name,@@ -482,6 +485,9 @@ class _BaseVLLMWorker:reasoning_parser=spec.reasoning_parser or "",gpu_type=getattr(self, "gpu_type", ""),model=base_model,+ enable_lora=self.enable_lora,+ max_lora_rank=self.max_lora_rank,+ lora_target_modules=lora_targets,)else:cmd = (@@ -498,6 +504,7 @@ class _BaseVLLMWorker:base_model=base_model,enable_lora=self.enable_lora,max_lora_rank=self.max_lora_rank,+ gpu_type=getattr(self, "gpu_type", ""),draft_model=draft_model,draft_tokens=draft_tokens,),@@ -539,7 +546,16 @@ class _BaseVLLMWorker:# List form (no shell) so JSON kwargs like --default-chat-template-kwargs# are not mangled by the shell.self._journal.emit("starting_engine_process")- self._proc = subprocess.Popen(cmd) # noqa: S603+ launch_env = None+ if engine == "sglang_lfm3":+ from modal_shared.serving.lfm3_lora import process_env++ launch_env = process_env()+ elif spec.key == "nemotron35" and engine == "vllm":+ from modal_shared.serving.nemotron_lora import process_env as nemotron_env++ launch_env = nemotron_env()+ self._proc = subprocess.Popen(cmd, env=launch_env) # noqa: S603_wait_for_vllm(proc=self._proc, journal=self._journal)if getattr(self, "snapshot_engine", False):# Level 1 copies weights into CPU memory so the snapshot keeps them.@@ -617,11 +633,26 @@ class _BaseVLLMWorker:shutil.rmtree(staged)staged.parent.mkdir(parents=True, exist_ok=True)shutil.copytree(source, staged)+ engine = str(getattr(self, "engine", "vllm"))+ if engine.startswith("sglang"):+ from modal_shared.modelfam import resolve+ from modal_shared.serving.sglang import normalize_sglang_adapter++ spec = resolve(getattr(self, "base_identity", "") or "")+ if engine == "sglang_lfm3":+ from modal_shared.serving.lfm3_lora import SGLANG_TARGETS++ keep_targets = SGLANG_TARGETS+ else:+ keep_targets = spec.lora_target_modules or ""+ normalize_sglang_adapter(staged, keep_targets=keep_targets)+ load_url = f"http://localhost:{VLLM_PORT}/load_lora_adapter"+ payload = {"lora_name": name, "lora_path": str(staged)}+ else:+ load_url = f"http://localhost:{VLLM_PORT}/v1/load_lora_adapter"+ payload = lora_load_request(name, str(staged))async with httpx.AsyncClient(timeout=300) as client:- resp = await client.post(- f"http://localhost:{VLLM_PORT}/v1/load_lora_adapter",- json=lora_load_request(name, str(staged)),- )+ resp = await client.post(load_url, json=payload)text = resp.text or ""# vLLM answers 400 "has already been loaded" when another container in this pool# got there first, which is success as far as the caller is concerned.@@ -1068,6 +1099,7 @@ def _register_worker(image_override=None,snapshot=True,engine="vllm",+ runtime_lora: bool = False,) -> None:bucket, default_len = GPU_TIER[gpu_type]image = image_override or (LORA_SERVE_IMAGES if lora else SERVE_IMAGES)[serve_image]@@ -1082,10 +1114,13 @@ def _register_worker("model_path": modal.parameter(),"model_name": modal.parameter(),"max_model_len": modal.parameter(default=default_len),- "enable_lora": modal.parameter(default=lora),+ "enable_lora": modal.parameter(default=runtime_lora or lora),"max_lora_rank": modal.parameter(default=16),"gpu_type": gpu_type,}+ if runtime_lora:+ parameters["__annotations__"]["base_identity"] = str+ parameters["base_identity"] = modal.parameter(default="")if lora:parameters["__annotations__"]["base_identity"] = strparameters["base_identity"] = modal.parameter(default="")@@ -1211,9 +1246,20 @@ def register_dedicated_classes(target_app, owner) -> None:for (_gpu, _serve_image), _cls_name in WORKER_CLS.items():- _register_worker(_cls_name, _gpu, _serve_image)+ if _serve_image == "vllm":+ _register_worker(_cls_name, _gpu, _serve_image)+ _register_worker(+ worker_cls_name(_gpu, _serve_image, enable_lora=True), _gpu, _serve_image, lora=True+ )+ continue+ # SGLang shared pools load the adapter at request time. They do not snapshot.+ _register_worker(_cls_name, _gpu, _serve_image, engine=_serve_image)_register_worker(- worker_cls_name(_gpu, _serve_image, enable_lora=True), _gpu, _serve_image, lora=True+ worker_cls_name(_gpu, _serve_image, enable_lora=True),+ _gpu,+ _serve_image,+ engine=_serve_image,+ runtime_lora=True,)dedicated_app = modal.App("overmind-dedicated")diff --git a/overbae/services/deployment.py b/overbae/services/deployment.pyindex b95a68fb..ad393a86 100644--- a/overbae/services/deployment.py+++ b/overbae/services/deployment.py@@ -379,6 +379,7 @@ def start_serving_snapshot(job, *, base: dict, rank: int) -> None:if not serves_as_adapter(job) or not isinstance(base, dict):returntry:+ from modal_shared.modelfam import serve_image_keyfrom modal_shared.shared import base_pool_namefrom modal_shared.stacks import worker_cls_name@@ -389,11 +390,12 @@ def start_serving_snapshot(job, *, base: dict, rank: int) -> None:gpu, _ = select_gpu(cfg, length)rel = str(base.get("base_model_path") or "").removeprefix("/weights/").lstrip("/")identity = str(base.get("base_identity") or "")- if not rel or not identity:+ image = serve_image_key(job.base_model)+ if not rel or not identity or image != "vllm":returnmodal.Cls.from_name("overmind-inference",- worker_cls_name(gpu, "vllm", enable_lora=True),+ worker_cls_name(gpu, image, enable_lora=True),environment_name=modal_environment(),)(model_path=rel,diff --git a/tests/test_modelfam.py b/tests/test_modelfam.pyindex f57a337a..263079c0 100644--- a/tests/test_modelfam.py+++ b/tests/test_modelfam.py@@ -84,7 +84,11 @@ def test_models_json_all_resolve() -> None:def test_serve_image_key_from_base_model() -> None:assert serve_image_key("ft-abc", "unsloth/Muse-Glimmer-30B") == "vllm"assert serve_image_key("ft-abc") == "vllm"- assert serve_image_key("Qwen/Qwen3-8B") == "vllm"+ assert serve_image_key("ft-abc", "Qwen/Qwen3-8B") == "sglang"+ assert serve_image_key("Qwen/Qwen3-8B") == "sglang"+ assert serve_image_key("unsloth/Qwen3-14B") == "sglang"+ assert serve_image_key("Qwen/Qwen3-Coder-30B-A3B-Instruct") == "vllm"+ assert serve_image_key("LiquidAI/LFM3-1.7B") == "sglang_lfm3"def test_serve_image_from_checkpoint_finetune_ids() -> None:@@ -111,7 +115,7 @@ def test_serve_image_from_checkpoint_finetune_ids() -> None:base_model="Qwen/Qwen3-0.6B",model_type="qwen3",)- == "vllm"+ == "sglang")assert serve_image_from_checkpoint(model_name="ft-4ff3114a-muse-glimmer-30b") == "vllm"diff --git a/tests/test_moe_adapter_format.py b/tests/test_moe_adapter_format.pyindex 706f02c2..505eb023 100644--- a/tests/test_moe_adapter_format.py+++ b/tests/test_moe_adapter_format.py@@ -9,7 +9,10 @@ pytestmark = pytest.mark.covers("model-runtime")@pytest.mark.parametrize("fused", [False, True])def test_adapter_request_declares_expert_format(tmp_path, fused):- config = {"target_parameters": ["mlp.experts.gate_up_proj", "mlp.experts.down_proj"]}+ config = {+ "target_parameters": ["mlp.experts.gate_up_proj", "mlp.experts.down_proj"],+ "target_modules": ["q_proj"],+ }(tmp_path / "adapter_config.json").write_text(json.dumps(config if fused else {}))request = lora_load_request("adapter", str(tmp_path))assert request == {@@ -24,6 +27,8 @@ def test_adapter_request_declares_expert_format(tmp_path, fused):[("Qwen/Qwen3-Coder-30B-A3B-Instruct", True, True),("Qwen/Qwen3-Coder-30B-A3B-Instruct", False, False),+ ("google/gemma-4-26B-A4B-it", True, True),+ ("google/gemma-4-E4B-it", True, False),("Qwen/Qwen3-8B", True, False),],)diff --git a/tests/test_serving_args.py b/tests/test_serving_args.pyindex 1619da0f..342d0ab9 100644--- a/tests/test_serving_args.py+++ b/tests/test_serving_args.py@@ -45,6 +45,16 @@ def test_kv_cache_is_fp8(tmp_path: Path) -> None:assert cmd[cmd.index("--kv-cache-dtype") + 1] == "fp8"+def test_ampere_triton_families_keep_bf16_kv(tmp_path: Path) -> None:+ for base in ("openai/gpt-oss-20b", "google/gemma-4-26B-A4B-it", "google/gemma-4-E4B-it"):+ cmd = _args(_checkpoint(tmp_path), base_model=base, gpu_type="A100-80GB")+ assert cmd[cmd.index("--kv-cache-dtype") + 1] == "bfloat16"+ kept = _args(_checkpoint(tmp_path), base_model="Qwen/Qwen3-32B", gpu_type="A100-80GB")+ assert kept[kept.index("--kv-cache-dtype") + 1] == "fp8"+ hopper = _args(_checkpoint(tmp_path), base_model="openai/gpt-oss-20b", gpu_type="H200")+ assert hopper[hopper.index("--kv-cache-dtype") + 1] == "fp8"++def test_capture_sizes_stay_within_the_sequence_cap(tmp_path: Path) -> None:cmd = _args(_checkpoint(tmp_path), max_num_seqs=4)start = cmd.index("--cudagraph-capture-sizes") + 1@@ -122,7 +132,7 @@ def test_base_keeps_its_name_without_adapters(tmp_path: Path) -> None:def test_sglang_dflash_argv_and_engine_choice() -> None:- from modal_shared.serving.engine import engine_for+ from modal_shared.serving.engine import engine_for, serverless_enginefrom modal_shared.serving.sglang import build_sglang_args, sglang_tool_parsercmd = build_sglang_args(@@ -152,6 +162,13 @@ def test_sglang_dflash_argv_and_engine_choice() -> None:assert oss[oss.index("--attention-backend") + 1] == "triton"assert cmd[cmd.index("--tool-call-parser") + 1] == "qwen3_coder"assert cmd[cmd.index("--reasoning-parser") + 1] == "gpt-oss"+ nemotron = build_sglang_args(+ model_path="/tmp/folded",+ served_name="dedicated/ft",+ port=8000,+ reasoning_parser="nemotron_v3",+ )+ assert nemotron[nemotron.index("--reasoning-parser") + 1] == "nemotron_3"assert sglang_tool_parser("openai") == "gpt-oss"assert sglang_tool_parser("llama3_json") == "llama3"assert sglang_tool_parser("muse_glimmer") == "muse"@@ -180,6 +197,42 @@ def test_sglang_dflash_argv_and_engine_choice() -> None:assert engine_for("meta-llama/Llama-3.1-8B-Instruct") == "vllm"assert engine_for("Qwen/Qwen3-14B") == "vllm"assert engine_for("LiquidAI/LFM3-1.7B") == "sglang_lfm3"+ assert serverless_engine("Qwen/Qwen3-14B") == "sglang"+ assert serverless_engine("unsloth/Llama-3.2-1B-Instruct") == "sglang"+ assert serverless_engine("Qwen/Qwen3-Coder-30B-A3B-Instruct") == "vllm"+ assert serverless_engine("LiquidAI/LFM3-1.7B") == "sglang_lfm3"+ assert serverless_engine("openai/gpt-oss-20b") == "vllm"+ gemma = build_sglang_args(+ model_path="/tmp/folded",+ served_name="dedicated/ft",+ port=8000,+ gpu_type="L40S",+ model="google/gemma-4-E2B-it",+ )+ assert gemma[gemma.index("--attention-backend") + 1] == "triton"+ lora_cmd = build_sglang_args(+ model_path="/tmp/base",+ served_name="base",+ port=8000,+ gpu_type="L4",+ enable_lora=True,+ max_lora_rank=16,+ )+ assert lora_cmd[lora_cmd.index("--max-lora-rank") + 1] == "16"+ assert lora_cmd[lora_cmd.index("--lora-target-modules") + 1] == "all"+ named = build_sglang_args(+ model_path="/tmp/base",+ served_name="base",+ port=8000,+ gpu_type="L4",+ enable_lora=True,+ lora_target_modules="q_proj,k_proj",+ mem_fraction="0.92",+ )+ start = named.index("--lora-target-modules")+ assert named[start + 1 : start + 3] == ["q_proj", "k_proj"]+ assert named[named.index("--mem-fraction-static") + 1] == "0.92"+ assert "--enable-lora" not in cmdlfm3 = build_sglang_args(model_path="/tmp/folded",served_name="dedicated/lfm3",@@ -206,6 +259,10 @@ def test_dflash_argv_for_the_three_bases(tmp_path: Path) -> None:"num_speculative_tokens": 15,}assert "--cudagraph-capture-sizes" not in cmd+ mtp = _args(_checkpoint(tmp_path), base_model="Qwen/Qwen3.5-4B", mtp_tokens=1)+ mtp_payload = json.loads(mtp[mtp.index("--speculative-config") + 1])+ assert mtp_payload == {"method": "mtp", "num_speculative_tokens": 1}+ assert "--cudagraph-capture-sizes" not in mtpfor repo in ("Qwen/Qwen3.5-4B","unsloth/Qwen3.5-4B",@@ -234,6 +291,9 @@ def test_dflash_argv_for_the_three_bases(tmp_path: Path) -> None:assert draft_for("unsloth/gemma-4-26B-A4B-it") == ("z-lab/gemma-4-26B-A4B-it-DFlash", 15)assert draft_for("unsloth/gemma-4-31B-it") == ("z-lab/gemma-4-31B-it-DFlash", 15)assert draft_for("unsloth/Qwen3.5-27B") == ("z-lab/Qwen3.5-27B-DFlash", 15)+ assert draft_for("unsloth/Qwen3.5-27B", vram_gb=80) is None+ assert draft_for("Qwen/Qwen3.5-27B", vram_gb=80) is None+ assert draft_for("unsloth/Qwen3.5-27B", vram_gb=141) == ("z-lab/Qwen3.5-27B-DFlash", 15)assert draft_for("unsloth/Qwen3.5-35B-A3B") == ("z-lab/Qwen3.5-35B-A3B-DFlash", 15)assert draft_for("Qwen/Qwen3-14B") is Noneassert "--speculative-config" not in _args(_checkpoint(tmp_path), base_model="Qwen/Qwen3-14B")@@ -306,3 +366,37 @@ def test_systemone_probabilities_follow_the_option_order() -> None:assert probabilities_for(request, {"probabilities": {"low": 0.2, "high": 0.8}}) == [0.2, 0.8]noul = {**request, "kind": "noul"}assert probabilities_for(noul, {"noul": 0.75}) == [0.25, 0.75]+++def test_nemotron_expert_lora_is_marked_3d() -> None:+ from modal_shared.serving.nemotron_lora import mark++ class NemotronHForCausalLM:+ is_non_gated_moe = True++ mark(NemotronHForCausalLM)+ assert NemotronHForCausalLM.is_3d_moe_weight is True+++def test_lfm3_hidden_dims_and_unsloth_target_rewrite(tmp_path: Path) -> None:+ from modal_shared.serving.lfm3_lora import hidden_dim, stacked_multiply+ from modal_shared.serving.sglang import normalize_sglang_adapter++ assert hidden_dim("in_proj", 2048, 7680) == (2048, 6144)+ assert hidden_dim("out_proj", 2048, 7680) == (2048, 2048)+ assert hidden_dim("w1", 2048, 7680) == (2048, 7680)+ assert hidden_dim("w3", 2048, 7680) == (2048, 7680)+ assert hidden_dim("w2", 2048, 7680) == (7680, 2048)+ assert hidden_dim("q_proj", 2048, 7680) is None+ assert stacked_multiply("in_proj") == 3+ assert stacked_multiply("w1") is None++ adapter = tmp_path / "adapter"+ adapter.mkdir()+ config = adapter / "adapter_config.json"+ config.write_text(json.dumps({"target_modules": "model\\.layers.*"}))+ normalize_sglang_adapter(adapter, keep_targets="q_proj,in_proj")+ assert json.loads(config.read_text())["target_modules"] == ["q_proj", "in_proj"]+ config.write_text(json.dumps({"target_modules": "model\\.layers.*"}))+ normalize_sglang_adapter(adapter)+ assert json.loads(config.read_text())["target_modules"] == "all-linear"diff --git a/tests/test_shared_base_serving.py b/tests/test_shared_base_serving.pyindex 8102c6c1..c802d887 100644--- a/tests/test_shared_base_serving.py+++ b/tests/test_shared_base_serving.py@@ -43,7 +43,35 @@ def test_shared_worker_resolves_family_from_sealed_base(monkeypatch, tmp_path):assert obj._serve_command[obj._serve_command.index("--tool-call-parser") + 1] == "qwen3_coder"[email protected]("gpu,image", sorted(WORKER_ALLOWED))+def test_lfm3_starts_on_its_image_with_conv_targets(monkeypatch, tmp_path):+ obj = serving._BaseVLLMWorker()+ obj.engine = "sglang_lfm3"+ obj.model_path = "base"+ obj._journal = Mock()+ obj.model_name = "opaque-deployment-id"+ obj.max_model_len = 512+ obj.enable_lora = True+ obj.max_lora_rank = 16+ (tmp_path / "base").mkdir()+ monkeypatch.setattr(serving, "WEIGHTS_MOUNT", str(tmp_path))+ monkeypatch.setattr(serving, "weights_vol", Mock())+ monkeypatch.setattr(+ serving,+ "read_base_manifest",+ Mock(return_value={"repo": "LiquidAI/LFM3-1.7B"}),+ )+ popen = Mock()+ monkeypatch.setattr(serving.subprocess, "Popen", popen)+ monkeypatch.setattr(serving, "_wait_for_vllm", Mock())+ obj._startup_inner(_json=json, _os=os)+ cmd = obj._serve_command+ assert "--enable-lora" in cmd+ assert cmd[cmd.index("--lora-target-modules") + 1] == "all"+ env = popen.call_args.kwargs["env"]+ assert "overmind-lfm3" in env["PYTHONPATH"]++[email protected]("gpu,image", sorted(pair for pair in WORKER_ALLOWED if pair[1] == "vllm"))def test_every_gpu_image_has_a_separate_shared_base_worker(gpu, image):regular = getattr(serving, worker_cls_name(gpu, image))._get_user_cls()shared = getattr(serving, worker_cls_name(gpu, image, enable_lora=True))._get_user_cls()@@ -54,7 +82,22 @@ def test_every_gpu_image_has_a_separate_shared_base_worker(gpu, image):assert set(regular.__annotations__) < set(shared.__annotations__)[email protected]("gpu,image", sorted(WORKER_ALLOWED))+def test_sglang_shared_pool_is_not_a_gpu_snapshot(gpu="L4", image="sglang"):+ regular = getattr(serving, worker_cls_name(gpu, image))._get_user_cls()+ shared = getattr(serving, worker_cls_name(gpu, image, enable_lora=True))._get_user_cls()+ assert not issubclass(shared, serving._SharedBaseVLLMWorker)+ assert regular.engine == "sglang"+ assert shared.engine == "sglang"+ assert not shared.snapshot_weights+ assert shared.__annotations__["base_identity"] is str+ discovery = importlib.import_module("modal._partial_function")+ flags = discovery._PartialFunctionFlags+ find = discovery._find_partial_methods_for_user_cls+ assert set(find(shared, flags.ENTER_POST_SNAPSHOT)) == {"startup"}+ assert find(shared, flags.ENTER_PRE_SNAPSHOT) == {}++[email protected]("gpu,image", sorted(pair for pair in WORKER_ALLOWED if pair[1] == "vllm"))def test_modal_discovers_only_the_intended_lifecycle_hooks(gpu, image):discovery = importlib.import_module("modal._partial_function")flags = discovery._PartialFunctionFlagsdiff --git a/tests/test_stacks.py b/tests/test_stacks.pyindex d7d9076a..e4406f8b 100644--- a/tests/test_stacks.py+++ b/tests/test_stacks.py@@ -64,7 +64,9 @@ def test_catalog_unsloth_image_matches_family() -> None:def test_worker_cls_table() -> None:assert GPU_CLASS_MAP["L4"] == "L4_vllm"- assert SERVE_CLASS_MAP == {}+ assert SERVE_CLASS_MAP[("L4", "sglang")] == "L4_sglang"+ assert SERVE_CLASS_MAP[("L4", "sglang_lfm3")] == "L4_sglang_lfm3"+ assert ("L4", "vllm") not in SERVE_CLASS_MAPassert worker_cls_name("H200") == "H200_vllm"shared = {gpu for gpu, image in WORKER_CLS if image == "vllm"}assert set(GPU_TIER) - shared == {"H100"}