The platform for continuously improving AI agents.
Add LFM3-1.7B LoRA training and dedicated SGLang serving (#296)
Rohit Gupta3a6fecb1fe4a
diff --git a/.agents/skills/finetuning-model-onboarding/SKILL.md b/.agents/skills/finetuning-model-onboarding/SKILL.mdindex 28c29b9a..617ccbf2 100644--- a/.agents/skills/finetuning-model-onboarding/SKILL.md+++ b/.agents/skills/finetuning-model-onboarding/SKILL.md@@ -1,6 +1,6 @@---name: finetuning-model-onboarding-description: Rules for adding a new model or model family to the finetuning pipeline, or changing finetuning behavior for an existing one — engine-agnostic customization via family hooks instead of if/else in the shared script, TRL-compatible chat templates ({% generation %} / pretok_trl), H100-before-H200 GPU probing, populating real_max_context_length/validated_context_length in models.json, and setting finetuning cost/pricing for a new model. Use when onboarding a model to Modal+Unsloth finetuning, adding a ModelFamily, pretok_trl falls back with a training-compatible chat template error, a model fails on its assigned GPU/context length, or pricing a new model's training cost.+description: Rules for adding a new model or model family to the finetuning pipeline, or changing finetuning behavior for an existing one — engine-agnostic customization via family hooks instead of if/else in the shared script, TRL-compatible chat templates ({% generation %} / pretok_trl), H100-before-H200 GPU probing, populating real_max_context_length/validated_context_length in models.json, setting finetuning cost/pricing, and measuring dedicated inference (thinking off, vLLM vs SGLang, MTP/DFlash, GPU tokens/s). Use when onboarding a model to Modal+Unsloth finetuning, adding a ModelFamily, pretok_trl falls back with a training-compatible chat template error, a model fails on its assigned GPU/context length, pricing a new model's training cost, or choosing a dedicated serving engine.---# Finetuning model onboarding@@ -91,6 +91,16 @@ If the family has no existing icon mapping, it falls through to a generic simple1. If a dedicated icon should render (not the CDN fallback), import the `@lobehub/icons` component and add it to `PROVIDER_ICONS` in `frontend/src/components/model-provider-chip.tsx`.1. Extend `inferProviderFromModelId()` if the model id doesn't carry an explicit provider prefix.+## 8. Dedicated inference is part of onboarding++A catalog row that only trains is unfinished. Serving is measured on Modal `--env overmind-dev`. Independent GPU jobs run at the same time.++1. **Thinking has to turn off.** `is_always_on_thinking_template` must be false for the live `hf_model_id` chat template. Then one completion with `chat_template_kwargs.enable_thinking=false` (dedicated serving sets this on every request). `content` has to be the answer. An open `<think>`, or an empty `content` whose answer sits only in `reasoning_content`, is the LFM2.5-2.6B failure: leave the row `disabled` and do not train it.+1. **Engine.** First boot the pinned dedicated vLLM image and the pinned SGLang image on L4. If both refuse the architecture, try the vendor image and record which image actually loaded. A new serve stack is a new image key (`modal_shared/stacks.py`), not a pin edit on an existing key. `engine_for` gets the winner from measured tokens/s, not from the vendor's preference.+1. **Speculative decoding.** Native MTP only when the checkpoint config has the MTP head (`mtp_for`). DFlash or DFlash2 only when a draft repo exists (`draft_for`). EAGLE with no draft is a refusal. No draft means the server stays on the base.+1. **GPUs.** After one engine loads, repeat on every dedicated GPU that fits: L4, L40S, A100-80GB, H100, H200. Record tokens/s. A missing cell in `serving_benchmarks.json` stays unmeasured in the Console.+1. **Order.** Catalog row first. Then a `MAX_STEPS=2` LoRA through Docker Compose (the Training API, not a side Modal app), which also checks pretok Path A. Then serverless completions of the base and of that adapter. Then dedicated speed on that same adapter (`lora_bf16`, and `merged_fp8` only when `fp8_supported` is true), including H100 when the weights fit in 80 GB. A longer training run can overlap the serving sweep. Context-length probes still follow §4 and are what flips `validated_context_length`.+## Checklist for onboarding a new model- [ ] Family resolves correctly (`modal_shared/modelfam/registry.py` pattern order) — add a `FamilySpec` only if genuinely new, otherwise reuse@@ -105,4 +115,8 @@ If the family has no existing icon mapping, it falls through to a generic simple- [ ] `pricing.train_from_usd` + `pricing.run_from_usd_per_1m_output` set for the model library display- [ ] Frontend icon mapped if the family is new- [ ] Benchmark artifact (`overbae/services/benchmarks/data/benchmark_results.json`) refreshed by a maintainer once the model is in `models.json`, so its benchmark results feed model recommendations; the sync runs outside this repo+- [ ] Thinking can be disabled: template gate plus one live completion whose `content` is the answer with `enable_thinking=false`+- [ ] Dedicated engine chosen from a pinned-image bake-off (vLLM, SGLang, then a vendor image only if both refuse). `engine_for` matches the measured winner+- [ ] Speculative decoding recorded: native MTP, DFlash, or DFlash2 when a head or draft exists; otherwise left off- [ ] `overbae/modal/serving_benchmarks.json` has a row per eligible GPU and serving shape (`lora_bf16`, `merged_fp8`, and `decision` where that contract exists), including H100 when the model fits in 80 GB. Leave a GPU out and the Console shows that speed as unmeasured. Nothing benches from the API process+- [ ] Quick LoRA (`MAX_STEPS=2`) and a longer run went through Docker Compose, then serverless base and LoRA completions, then dedicated tokens/s on that adapterdiff --git a/modal_shared/images/serve.py b/modal_shared/images/serve.pyindex 534a9c8d..de198562 100644--- a/modal_shared/images/serve.py+++ b/modal_shared/images/serve.py@@ -68,6 +68,14 @@ dedicated_sglang_image = attach_serving_args(setup_dockerfile_commands=["RUN ln -sf $(command -v python3) /usr/local/bin/python"],).entrypoint([]))+# 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(+ modal.Image.from_registry(+ "lmsysorg/sglang:dev-lfm3",+ setup_dockerfile_commands=["RUN ln -sf $(command -v python3) /usr/local/bin/python"],+ ).entrypoint([])+)SERVE_IMAGES: dict[str, modal.Image] = {SERVE_VLLM: vllm_image,diff --git a/modal_shared/modelfam/families.py b/modal_shared/modelfam/families.pyindex 38a57841..7a8fe011 100644--- a/modal_shared/modelfam/families.py+++ b/modal_shared/modelfam/families.py@@ -120,6 +120,21 @@ MUSE_GLIMMER = FamilySpec(hooks_module="families.muse_glimmer",)+LFM3 = FamilySpec(+ key="lfm3",+ patterns=("lfm3",),+ train_image=TRAIN_U2026_10_7,+ trust_remote_code=True,+ # Attention out-proj is o_proj; conv out-proj stays out_proj. gate_proj is optional.+ lora_target_modules="q_proj,k_proj,v_proj,o_proj,in_proj,out_proj,w1,w2,w3",+ pretok_headers=(r"<\|im_start\|>(\w+)\n",),+ tool_call_parser="qwen3_coder",+ reasoning_parser="qwen3",+ dtype_override="bfloat16",+ notes="Tri-hybrid conv + sliding + full attention. Custom code. Thinking closes when enable_thinking is false.",+ hooks_module="families.lfm3",+)+LFM2 = FamilySpec(key="lfm2",patterns=("lfm2", "liquidai/", "/lfm"),diff --git a/modal_shared/modelfam/registry.py b/modal_shared/modelfam/registry.pyindex 17120586..0970755a 100644--- a/modal_shared/modelfam/registry.py+++ b/modal_shared/modelfam/registry.py@@ -13,6 +13,7 @@ from modal_shared.modelfam.families import (GEMMA4,GPT_OSS,LFM2,+ LFM3,LLAMA,MINISTRAL,MUSE_GLIMMER,@@ -38,6 +39,7 @@ _FAMILIES: tuple[FamilySpec, ...] = (PHI4,GEMMA4,MUSE_GLIMMER,+ LFM3,LFM2,MINISTRAL,ANTARES,@@ -173,7 +175,7 @@ def fixups_for_model_type(model_type: str) -> tuple[str, ...]:mtype = (model_type or "").lower()if mtype == "qwen3_5_text":return ("nest_qwen3_5_text",)- if mtype in ("lfm2", "lfm2_moe") or mtype.startswith("lfm"):+ if mtype == "lfm2" or mtype.startswith("lfm2"):return ("lfm_layer_types",)if mtype == "nemotron_h":return ("nemotron_h",)diff --git a/modal_shared/serving/engine.py b/modal_shared/serving/engine.pyindex c4663216..425246e5 100644--- a/modal_shared/serving/engine.py+++ b/modal_shared/serving/engine.py@@ -30,7 +30,14 @@ _SGLANG = frozenset()+# Pinned vLLM and SGLang both refuse this architecture. The class suffix selects+# dedicated_sglang_lfm3_image.+_SGLANG_LFM3 = frozenset({"LiquidAI/LFM3-1.7B"})++def engine_for(repo: str) -> str:+ if repo in _SGLANG_LFM3:+ return "sglang_lfm3"if repo in _SGLANG:return "sglang"return "vllm"diff --git a/modal_shared/serving/sglang.py b/modal_shared/serving/sglang.pyindex 6b7de34f..238ea36f 100644--- a/modal_shared/serving/sglang.py+++ b/modal_shared/serving/sglang.py@@ -25,6 +25,9 @@ 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():+ # The LFM3 server picks flashinfer itself. fa3 mismatches the conv blocks.+ return ""hopper = gpu_type in {"H100", "H200"} or not gpu_typeif "gpt-oss" in model:# This architecture rejects flashinfer. Triton runs on the other GPUs.@@ -57,8 +60,11 @@ def build_sglang_args(served_name,"--tp-size","1",- "--attention-backend",- attention_backend(gpu_type, model=model),+ ]+ backend = attention_backend(gpu_type, model=model)+ if backend:+ cmd += ["--attention-backend", backend]+ cmd += ["--mem-fraction-static","0.75","--dtype",diff --git a/overbae/modal/modal_vllm_worker.py b/overbae/modal/modal_vllm_worker.pyindex ffd2548c..7d5077a5 100644--- a/overbae/modal/modal_vllm_worker.py+++ b/overbae/modal/modal_vllm_worker.py@@ -99,6 +99,7 @@ from modal_shared.images.serve import ( # noqa: E402SERVE_IMAGES,api_server_image,dedicated_sglang_image,+ dedicated_sglang_lfm3_image,dedicated_vllm_image,)from modal_shared.stacks import GPU_TIER, WORKER_CLS, WORKER_MEMORY_MIB # noqa: E402@@ -393,7 +394,7 @@ class _BaseVLLMWorker:engine = getattr(self, "engine", "vllm")if adapter_rel:adapter_dir = Path(WEIGHTS_MOUNT) / adapter_rel- if engine == "sglang":+ if engine.startswith("sglang"):from modal_shared.serving.merge import write_folded_checkpointfolded = Path("/tmp/overmind-folded")@@ -466,7 +467,7 @@ 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 == "sglang":+ if 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.@@ -1192,6 +1193,21 @@ def register_dedicated_classes(target_app, owner) -> None:image_override=dedicated_sglang_image,)owner[sglang_name] = sglang_slot[sglang_name]+ lfm3_name = f"{token}_sglang_lfm3_dedicated"+ lfm3_slot = {}+ _register_worker(+ lfm3_name,+ gpu_type,+ "vllm",+ target_app=target_app,+ pin_resources=True,+ snapshot=False,+ engine="sglang_lfm3",+ max_containers=8,+ owner=lfm3_slot,+ image_override=dedicated_sglang_lfm3_image,+ )+ owner[lfm3_name] = lfm3_slot[lfm3_name]for (_gpu, _serve_image), _cls_name in WORKER_CLS.items():diff --git a/overbae/modal/models.json b/overbae/modal/models.jsonindex 2645c20c..833e840f 100644--- a/overbae/modal/models.json+++ b/overbae/modal/models.json@@ -1,5 +1,5 @@{- "comment": "Single source of truth for all models supported by the Overmind platform. Each entry carries a 'backend' field (baseten | together | decision). Models available on multiple backends appear as separate entries with their own inference/finetuning sub-configs. inference.gpu_type is the default for base-model inference (BF16 serving, single GPU). inference.lora_supported declares verified shared-base LoRA support for MoE models; dense models support it by default. inference.min_vram_gb is a measured minimum GPU capacity enforced for automatic inference selection, including short contexts. num_attn_layers/num_kv_heads/head_dim are used by gpu_selector.py to derive the optimal GPU + concurrency for a model at its serving max_model_len, including input and reserved output. For hybrid models (Qwen3.5), num_attn_layers counts only full-attention layers. Use model_registry.py helpers to filter by backend. To add/remove models, edit only this file. Baseten models train LoRA or Full on H100s/H200s via our TRL train.py; finetuning.context_length is the model's max trainable context = HF config max_position_embeddings (Qwen2.5 32768, Qwen3 dense 40960, Qwen3.5/3.6/3.8/Coder 262144, Llama 3.x / GPT-OSS / Antares-1B 131072, Antares-350M 32768, LFM2.5-230M/350M/1.2B 32768 per Liquid's documented window, LFM2.5-8B-A1B 128000, LFM2.5-2.6B 131072; train.py applies no RoPE scaling). context_length (top-level) is the published inference window (YaRN-extended where the vendor documents it: Qwen2.5\u22657B and Qwen3 dense \u2192 131072; Qwen2.5-0.5B stays 32768). Baseten itself imposes no per-model training context limit (max_seq_len up to 1048576, docs.baseten.co/engines/engine-builder-llm/engine-builder-config; training is arbitrary code, docs.baseten.co/training/getting-started). The runner snaps the actual training MAX_LENGTH up from dataset stats using finetuning_providers.<backend> policy below. pricing.train_from_usd is a marketing 'from' floor for a typical small LoRA run (Baseten H100 $0.10833/GPU-min = $6.50/h, baseten.co/pricing): \u226414B anchored on Jul 2026 Baseten-invoiced job averages; larger sizes estimated from typical GPU-minutes \u00d7 rate on 1\u00d7H100 (\u226472B). pricing.run_from_usd_per_1m_output is serving per 1M output tokens (Modal L4/L40S self-hosted vLLM floors; MoE uses active-param band). group is the marketing library tab label (Group on /models specs); provider comes from providers.display_names. model.marketing holds buyer-facing copy per model (pitch, description, overview, good_for) for the marketing site detail pages. group is only the library tab/filter label. library_filters defines the marketing /models multi-select filters (use_case, tier, context); each model.use_cases lists which use-case filter ids apply. tier/context filters match model.tier and model.context_length against library_filters entries. The order of the models array is the catalog display order within a tier (newest generation first); recommendation ranking is decided by benchmark grades, not by this order.",+ "comment": "Single source of truth for all models supported by the Overmind platform. Each entry carries a 'backend' field (baseten | together | decision). Models available on multiple backends appear as separate entries with their own inference/finetuning sub-configs. inference.gpu_type is the default for base-model inference (BF16 serving, single GPU). inference.lora_supported declares verified shared-base LoRA support for MoE models; dense models support it by default. inference.min_vram_gb is a measured minimum GPU capacity enforced for automatic inference selection, including short contexts. num_attn_layers/num_kv_heads/head_dim are used by gpu_selector.py to derive the optimal GPU + concurrency for a model at its serving max_model_len, including input and reserved output. For hybrid models (Qwen3.5), num_attn_layers counts only full-attention layers. Use model_registry.py helpers to filter by backend. To add/remove models, edit only this file. Baseten models train LoRA or Full on H100s/H200s via our TRL train.py; finetuning.context_length is the model's max trainable context = HF config max_position_embeddings (Qwen2.5 32768, Qwen3 dense 40960, Qwen3.5/3.6/3.8/Coder 262144, Llama 3.x / GPT-OSS / Antares-1B 131072, Antares-350M 32768, LFM3-1.7B 262144, LFM2.5-230M/350M/1.2B 32768 per Liquid's documented window, LFM2.5-8B-A1B 128000, LFM2.5-2.6B 131072; train.py applies no RoPE scaling). context_length (top-level) is the published inference window (YaRN-extended where the vendor documents it: Qwen2.5\u22657B and Qwen3 dense \u2192 131072; Qwen2.5-0.5B stays 32768). Baseten itself imposes no per-model training context limit (max_seq_len up to 1048576, docs.baseten.co/engines/engine-builder-llm/engine-builder-config; training is arbitrary code, docs.baseten.co/training/getting-started). The runner snaps the actual training MAX_LENGTH up from dataset stats using finetuning_providers.<backend> policy below. pricing.train_from_usd is a marketing 'from' floor for a typical small LoRA run (Baseten H100 $0.10833/GPU-min = $6.50/h, baseten.co/pricing): \u226414B anchored on Jul 2026 Baseten-invoiced job averages; larger sizes estimated from typical GPU-minutes \u00d7 rate on 1\u00d7H100 (\u226472B). pricing.run_from_usd_per_1m_output is serving per 1M output tokens (Modal L4/L40S self-hosted vLLM floors; MoE uses active-param band). group is the marketing library tab label (Group on /models specs); provider comes from providers.display_names. model.marketing holds buyer-facing copy per model (pitch, description, overview, good_for) for the marketing site detail pages. group is only the library tab/filter label. library_filters defines the marketing /models multi-select filters (use_case, tier, context); each model.use_cases lists which use-case filter ids apply. tier/context filters match model.tier and model.context_length against library_filters entries. The order of the models array is the catalog display order within a tier (newest generation first); recommendation ranking is decided by benchmark grades, not by this order.","providers": {"comment": "Friendly display name per model-id prefix (the part before the first '/'), keyed lowercase, under display_names. Used by overbae.services.model_library to label each model's family/provider on the public /library pages. Unknown prefixes fall back to a title-cased version of the raw prefix \u2014 add an entry here instead of hardcoding it in Python.","display_names": {@@ -1288,6 +1288,69 @@"meta-llama/Llama-3.2-1B-Instruct"]},+ {+ "id": "LiquidAI/LFM3-1.7B",+ "openrouter_id": null,+ "backend": "baseten",+ "display": "LFM3 1.7B",+ "hf_model_id": "LiquidAI/LFM3-1.7B",+ "tier": "compact",+ "params": "1.7B",+ "total_params_b": 1.73,+ "context_length": 262144,+ "supports_tool_calling": true,+ "type": "chat",+ "hidden_size": 2048,+ "fp8_supported": false,+ "inference": {+ "gpu_type": "L4",+ "max_model_len": 8192+ },+ "finetuning": {+ "context_length": 262144,+ "max_batch_size": 16,+ "min_batch_size": 1,+ "training_type": {+ "full": {+ "enabled": true,+ "context_length": 8192,+ "validated_context_length": false+ },+ "lora": {+ "enabled": true,+ "context_length": 131072,+ "validated_context_length": true+ }+ },+ "real_max_context_length": 131072+ },+ "disabled": false,+ "disabled_reason": null,+ "num_attn_layers": 6,+ "num_kv_heads": 4,+ "head_dim": 128,+ "group": "LFM3",+ "pricing": {+ "train_from_usd": 0.55,+ "run_from_usd_per_1m_output": 2.5+ },+ "marketing": {+ "pitch": "1.7B agent model with a 256K window and tool calling.",+ "description": "Liquid AI hybrid models for on-device and edge deployment. Fast decode, low memory, and agentic post-training across the ladder.",+ "overview": "LFM3-1.7B is Liquid's text instruct checkpoint: 24 tri-hybrid layers, tool calling, and a 256K window. Thinking is off when enable_thinking is false.",+ "good_for": [+ "Tool-calling and agent loops at compact size",+ "Instruction following on a 256K window",+ "Domain LoRA on a single GPU"+ ]+ },+ "use_cases": [+ "tool-calling"+ ],+ "benchmark_hf_model_ids": [+ "LiquidAI/LFM3-1.7B"+ ]+ },{"id": "LiquidAI/LFM2.5-2.6B","openrouter_id": "liquid/lfm-2.5-2.6b:free",diff --git a/overbae/modal/serving_benchmarks.json b/overbae/modal/serving_benchmarks.jsonindex ffeb2cf2..37f8ebd1 100644--- a/overbae/modal/serving_benchmarks.json+++ b/overbae/modal/serving_benchmarks.json@@ -521,6 +521,40 @@}}},+ "LiquidAI/LFM3-1.7B": {+ "lora_bf16": {+ "L4": {+ "ttft_ms_p50": null,+ "tokens_per_second_p50": 67.4,+ "measured_at": "2026-11-05T01:05:00Z",+ "runtime": "sglang-dev-lfm3"+ },+ "L40S": {+ "ttft_ms_p50": null,+ "tokens_per_second_p50": 177.5,+ "measured_at": "2026-11-05T01:05:00Z",+ "runtime": "sglang-dev-lfm3"+ },+ "A100-80GB": {+ "ttft_ms_p50": null,+ "tokens_per_second_p50": 250.1,+ "measured_at": "2026-11-05T01:05:00Z",+ "runtime": "sglang-dev-lfm3"+ },+ "H100": {+ "ttft_ms_p50": null,+ "tokens_per_second_p50": 442.2,+ "measured_at": "2026-11-05T01:05:00Z",+ "runtime": "sglang-dev-lfm3"+ },+ "H200": {+ "ttft_ms_p50": null,+ "tokens_per_second_p50": 393.0,+ "measured_at": "2026-11-05T01:05:00Z",+ "runtime": "sglang-dev-lfm3"+ }+ }+ },"LiquidAI/LFM2.5-1.2B-Instruct": {"merged_fp8": {"H200": {diff --git a/overbae/services/sft_assets/families/lfm3.py b/overbae/services/sft_assets/families/lfm3.pynew file mode 100644index 00000000..49fa1ffd--- /dev/null+++ b/overbae/services/sft_assets/families/lfm3.py@@ -0,0 +1,67 @@+"""LFM3 hooks — full-FT attention dtype split, and conv layers have no RoPE entry."""++from __future__ import annotations++from typing import Any++from families import DefaultHooks+++def _skip_conv_rope() -> None:+ # transformers 5.17 indexes rope_parameters by every layer_types entry, then+ # validates each value as a dict. LFM3 conv layers have no entry, and the+ # rewrite leaves a float where a dict is required. The checkpoint already+ # carries per-layer rope_parameters, so both steps are skipped for lfm3.+ from transformers.configuration_utils import PreTrainedConfig++ original = PreTrainedConfig.standardize_rope_params+ if getattr(original, "_lfm3_conv", False):+ return+ validate = PreTrainedConfig.validate_rope++ def wrapped(self):+ if getattr(self, "model_type", None) == "lfm3":+ return None+ return original(self)++ def wrapped_validate(self):+ if getattr(self, "model_type", None) == "lfm3":+ return None+ return validate(self)++ wrapped._lfm3_conv = True+ PreTrainedConfig.standardize_rope_params = wrapped+ PreTrainedConfig.validate_rope = wrapped_validate+++class Lfm3Hooks(DefaultHooks):+ def env_overrides(self, *, use_lora: bool) -> dict[str, str]:+ _skip_conv_rope()+ # Unsloth's Lfm3 block compile rewrites conv layers to linear_attention,+ # which the model's causal mask map does not contain.+ out = {"UNSLOTH_COMPILE_DISABLE": "1", "UNSLOTH_BLOCK_COMPILE": "0"}+ if not use_lora:+ out["UNSLOTH_ENABLE_FLEX_ATTENTION"] = "0"+ return out++ def load_kwargs(self, *, use_lora: bool) -> dict[str, Any]:+ if use_lora:+ return {}+ return {"attn_implementation": "sdpa"}++ def post_load(self, model: Any, tokenizer: Any, *, use_lora: bool) -> None:+ # Unsloth's Lfm3 patch renames conv to linear_attention. The remote+ # mask builder only knows conv, so the first step raises KeyError.+ base = model.get_base_model() if hasattr(model, "get_base_model") else model+ config = base.config+ types = getattr(config, "layer_types", None)+ if isinstance(types, list) and "linear_attention" in types:+ config.layer_types = [+ "conv" if layer == "linear_attention" else layer for layer in types+ ]+ for module in base.modules():+ if getattr(module, "layer_type", None) == "linear_attention":+ module.layer_type = "conv"+++hooks = Lfm3Hooks()diff --git a/overbae/services/sft_assets/preprocess.py b/overbae/services/sft_assets/preprocess.pyindex a88116c1..63452008 100644--- a/overbae/services/sft_assets/preprocess.py+++ b/overbae/services/sft_assets/preprocess.py@@ -6,6 +6,7 @@ import gzipimport hashlibimport jsonimport shutil+import sysimport timefrom itertools import islicefrom pathlib import Path@@ -136,6 +137,16 @@ def run(request_path: Path, output_dir: Path, load_tokenizer, tokenize, *, decisreport = preparation_failure("worker_out_of_date")(output_dir / "report.json").write_text(json.dumps(report, sort_keys=True))return+ # Family hooks install load-time patches (LFM3's RoPE lookup) before config init.+ assets = Path(__file__).resolve().parent+ if str(assets) not in sys.path:+ sys.path.insert(0, str(assets))+ from catalog import resolve as resolve_family+ from families import load_hooks++ load_hooks(resolve_family(request["model"]).hooks_module).env_overrides(+ use_lora=request.get("training_type") != "full"+ )tokenizer = load_tokenizer(request["tokenizer_model"], trust_remote_code=True)if not tokenizer.eos_token or tokenizer.eos_token == "<EOS_TOKEN>":for token in ("<|im_end|>", "<|eot_id|>", "</s>", "<|endoftext|>", "<|return|>"):diff --git a/tests/test_modelfam.py b/tests/test_modelfam.pyindex d4386572..f57a337a 100644--- a/tests/test_modelfam.py+++ b/tests/test_modelfam.py@@ -43,6 +43,7 @@ _ORDERING = [("microsoft/Phi-4-mini-instruct", "phi4"),("google/gemma-4-E4B-it", "gemma4"),("unsloth/Muse-Glimmer-30B", "muse_glimmer"),+ ("LiquidAI/LFM3-1.7B", "lfm3"),("LiquidAI/LFM2.5-1.2B-Instruct", "lfm2"),("mistralai/Ministral-3-3B-Instruct-2512", "ministral"),("fdtn-ai/antares-1b", "antares"),@@ -241,6 +242,7 @@ def test_muse_pretok_headers_match_tool_turns() -> None:def test_fixups_for_model_type() -> None:assert "nest_qwen3_5_text" in fixups_for_model_type("qwen3_5_text")assert "lfm_layer_types" in fixups_for_model_type("lfm2")+ assert fixups_for_model_type("lfm3") == ()assert "nemotron_h" in fixups_for_model_type("nemotron_h")assert "granite_layer_types" in fixups_for_model_type("granite")assert "granite_layer_types" in fixups_for_model_type("granitemoehybrid")@@ -395,6 +397,12 @@ def test_serve_strips_training_chat_template(tmp_path) -> None:def test_lfm_lora_targets() -> None:assert resolve("LiquidAI/LFM2.5-1.2B").lora_target_modules is not Noneassert "out_proj" in resolve("LiquidAI/LFM2.5-1.2B").lora_target_modules+ lfm3 = resolve("LiquidAI/LFM3-1.7B")+ assert lfm3.key == "lfm3"+ assert lfm3.trust_remote_code is True+ assert lfm3.train_image == TRAIN_U2026_10_7+ assert "o_proj" in (lfm3.lora_target_modules or "")+ assert lfm3.tool_call_parser == "qwen3_coder"_LFM_ALWAYS_ON = """@@ -421,10 +429,23 @@ _QWEN_OPTIONAL = """"""+_LFM3_OPTIONAL = """+{%- if add_generation_prompt -%}+ {{- "<|im_start|>assistant\\n" -}}+ {%- if enable_thinking -%}+ {{- "<think>" -}}+ {%- else -%}+ {{- "<think></think>" -}}+ {%- endif -%}+{%- endif -%}+"""++def test_is_always_on_thinking_template() -> None:assert is_always_on_thinking_template(_LFM_ALWAYS_ON)assert not is_always_on_thinking_template(_LFM_INSTRUCT)assert not is_always_on_thinking_template(_QWEN_OPTIONAL)+ assert not is_always_on_thinking_template(_LFM3_OPTIONAL)assert not is_always_on_thinking_template("")diff --git a/tests/test_serving_args.py b/tests/test_serving_args.pyindex 855d549c..1619da0f 100644--- a/tests/test_serving_args.py+++ b/tests/test_serving_args.py@@ -179,6 +179,15 @@ def test_sglang_dflash_argv_and_engine_choice() -> None:assert engine_for("Qwen/Qwen3-Coder-30B-A3B-Instruct") == "vllm"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"+ lfm3 = build_sglang_args(+ model_path="/tmp/folded",+ served_name="dedicated/lfm3",+ port=8000,+ gpu_type="H100",+ model="LiquidAI/LFM3-1.7B",+ )+ assert "--attention-backend" not in lfm3def test_dflash_argv_for_the_three_bases(tmp_path: Path) -> None: