Open-source inference server and production cluster for all the models your agent needs.
Python bgecolbertdata-pipelinedeep-learningembeddingsinferenceinference-serverinformation-retrievalllmmlmlopsnatural-language-processingnlppythonrerankingretrievalretrieval-augmented-generationsemantic-searchspladevector-search
feat(models): add lightonai/LightOnOCR-3-1B (SGLang default + markdown) (#1009)
Shai Shmueld7be537f75a0
diff --git a/packages/sie_server/models/lightonai__LightOnOCR-3-1B.yaml b/packages/sie_server/models/lightonai__LightOnOCR-3-1B.yamlnew file mode 100644index 000000000..2722fd71b--- /dev/null+++ b/packages/sie_server/models/lightonai__LightOnOCR-3-1B.yaml@@ -0,0 +1,101 @@+sie_id: lightonai/LightOnOCR-3-1B+hf_id: lightonai/LightOnOCR-3-1B+hf_revision: 23d544085c886bbdace647bcfab91203299417e2+inputs:+ text: false+ image: true+ audio: false+ video: false+tasks:+ encode: null+ score: null+ extract: {}+# Settings follow github.com/lightonai/LightOnOCR at 36755d461be079737860a5f03ae0c803501269e9+# (README, lightonocr/models.py, benchmarks/ocr_bench/config.py) and the model card.+#+# Architecture: unlike LightOnOCR-3-0.8B and -4B (Qwen3.5), the 1B keeps the LightOnOCR-2-1B+# architecture (Mistral3: Pixtral vision encoder + Qwen3 decoder, 16,384-token context) and the same+# chat template, so it is served the way LightOnOCR-2-1B is, with the LightOnOCR-3 prompt contract.+# There is no `transformers` profile: LightOnOCRAdapter always sends LightOnOCR-2's system prompt and+# decodes greedily, and LightOnOCR3Adapter loads only the Qwen3.5 checkpoints.+#+# Mode: omit `instruction` for plain Markdown transcription. Send exactly `grounding` to get a+# `` block marker, in 0-1000 page coordinates, before each layout block.+# These are the only two trained prompts. The adapter rejects any other prompt. No system prompt:+# the chat template then adds the empty system turn the model was trained with.+#+# Page image: the Pixtral processor downscales every page to at most 1,540 px on the longest edge+# (about 3,100 image tokens), and upstream renders the 1B's pages at that size.+#+# Sampling: temperature 0.1, top_p 1.0, one beam, as the upstream client and benchmarks use for+# LightOnOCR-3 ("use temperature 0.1, not greedy decoding"). The model card examples use 0.2/0.9.+#+# Output cap: 4,096 new tokens, the max_tokens of the model card's vLLM example. A page plus its+# output must fit the 16,384-token context. On the SGLang profiles a request's max_new_tokens+# replaces the default in either direction.+#+# Normalization: none beyond trimming leading and trailing whitespace; grounding markers are kept.+# The upstream client repairs escaped math dollars by default. The explicit `markdown` profile+# defaults to `grounding` and applies upstream's published olmOCR-bench conversion: omit+# margin/aside blocks and leading unmarked text, repair escaped math dollars, then PP3. This is a+# lossy output policy; footnotes remain and all-margin pages can return empty text.+#+# Serving: SGLang (sglang-vision-extract bundle) with continuous batching and the+# SIE_SGLANG_LIGHTON_OCR_COMPAT hook that LightOnOCR-2-1B uses for the Transformers 5 vision rope+# config. The radix cache is off: every page is a new image, so it saves nothing.+#+# Throughput: up to 256 pages are dispatched to the engine at once. SIE's HTTP client to SGLang+# allows 256 connections (max_connections=256 in+# SGLangGenerationAdapter._get_or_create_http_client), so 256 is the highest value that cannot+# exhaust that pool; past it, requests wait for a connection and fail with a PoolTimeout after 10 s+# unless SIE_SGLANG_GENERATE_POOL_TIMEOUT_S is raised. How many dispatched pages decode at once is+# decided by SGLang's own running-request limit and KV pool.+#+# Memory: mem_fraction_static 0.70, as the other LightOnOCR-3 descriptors use; on a 1B checkpoint+# (about 2 GB of bf16 weights) most of the static share becomes KV cache, at 112 KiB per token.+max_sequence_length: 16384+profiles:+ default:+ max_batch_tokens: 16384+ compute_precision: bfloat16+ adapter_path: sie_server.adapters.sglang_vision_extract.adapter:SGLangVisionExtractAdapter+ adapter_options:+ loadtime:+ mem_fraction_static: 0.70+ served_model_name: lightonai/LightOnOCR-3-1B+ trust_remote_code: false+ max_concurrent_requests: 256+ meter_pages: true+ max_new_tokens: 4096+ temperature: 0.1+ top_p: 1.0+ allowed_instructions:+ - grounding+ extra_env:+ SIE_SGLANG_LIGHTON_OCR_COMPAT: "1"+ extra_launch_args:+ - --disable-radix-cache+ runtime:+ max_new_tokens: 4096+ num_beams: 1+ markdown:+ extends: default+ adapter_options:+ # Profile inheritance replaces loadtime, so retain every engine/sampling option.+ loadtime:+ mem_fraction_static: 0.70+ served_model_name: lightonai/LightOnOCR-3-1B+ trust_remote_code: false+ max_concurrent_requests: 256+ meter_pages: true+ max_new_tokens: 4096+ temperature: 0.1+ top_p: 1.0+ allowed_instructions:+ - grounding+ extra_env:+ SIE_SGLANG_LIGHTON_OCR_COMPAT: "1"+ extra_launch_args:+ - --disable-radix-cache+ default_prompt: grounding+ output_postprocess: lightonocr3_markdowndiff --git a/packages/sie_server/src/sie_server/adapters/sglang_vision_extract/_compat/sie_mistral_regex_compat.py b/packages/sie_server/src/sie_server/adapters/sglang_vision_extract/_compat/sie_mistral_regex_compat.pynew file mode 100644index 000000000..094f1f51f--- /dev/null+++ b/packages/sie_server/src/sie_server/adapters/sglang_vision_extract/_compat/sie_mistral_regex_compat.py@@ -0,0 +1,144 @@+"""Backport Transformers' load fix for tokenizer configs that set ``fix_mistral_regex``.++Transformers 5.3 (the SGLang bundles' version) passes ``fix_mistral_regex`` to+``TokenizersBackend._patch_mistral_regex`` both by name and inside ``**kwargs``, so a+``tokenizer_config.json`` that sets the flag (LightOnOCR-3-1B does) fails to load with+"got multiple values for keyword argument 'fix_mistral_regex'". Upstream pops the key+at that call (Transformers 5.16.1 has the fix). This patch pops it before the+constructor runs and hands it back to ``_patch_mistral_regex`` with the same value and+``init_kwargs`` the fixed release passes, so the flag keeps its meaning.++It installs only on a ``TokenizersBackend`` whose constructor still contains the+duplicated argument, so it is a no-op on fixed releases. This module imports nothing+from SIE: the SGLang child's ``sitecustomize`` arms it with ``install_when_imported`` (no+early Transformers import), and the SIE worker calls ``install`` before building the processor.+"""++from __future__ import annotations++import functools+import importlib.abc+import inspect+import sys+import threading+from typing import Any++_MODULE = "transformers.tokenization_utils_tokenizers"+_KEY = "fix_mistral_regex"+_MARKER = "_sie_fix_mistral_regex_compat"+_DUPLICATED_ARGUMENT = 'fix_mistral_regex=kwargs.get("fix_mistral_regex"),'+_pending = threading.local()+++def needs_patch(backend_cls: type) -> bool:+ """Whether ``backend_cls.__init__`` still passes the flag twice."""+ init = backend_cls.__init__+ if getattr(init, _MARKER, False):+ return False+ try:+ source = inspect.getsource(init)+ except (OSError, TypeError):+ return False+ return _DUPLICATED_ARGUMENT in source+++def install_on(backend_cls: type) -> bool:+ """Patch ``backend_cls`` in place; return whether this call installed the patch."""+ if not needs_patch(backend_cls):+ return False+ original_init = backend_cls.__init__+ original_patch = backend_cls.__dict__["_patch_mistral_regex"].__func__++ @functools.wraps(original_init)+ def compat_init(self: Any, *args: Any, **kwargs: Any) -> None:+ if _KEY not in kwargs:+ original_init(self, *args, **kwargs)+ return+ value = kwargs.pop(_KEY)+ stack = getattr(_pending, "values", None)+ if stack is None:+ stack = _pending.values = []+ stack.append(value)+ try:+ original_init(self, *args, **kwargs)+ finally:+ stack.pop()+ self.init_kwargs[_KEY] = value++ def compat_patch(+ cls: Any,+ tokenizer: Any,+ pretrained_model_name_or_path: Any,+ *args: Any,+ init_kwargs: dict[str, Any] | None = None,+ fix_mistral_regex: Any = None,+ **kwargs: Any,+ ) -> Any:+ stack = getattr(_pending, "values", None)+ if stack:+ fix_mistral_regex = stack[-1]+ init_kwargs = {**(init_kwargs or {}), _KEY: fix_mistral_regex}+ return original_patch(+ cls,+ tokenizer,+ pretrained_model_name_or_path,+ *args,+ init_kwargs=init_kwargs,+ fix_mistral_regex=fix_mistral_regex,+ **kwargs,+ )++ setattr(compat_init, _MARKER, True)+ backend_cls.__init__ = compat_init # ty: ignore[invalid-assignment]+ backend_cls._patch_mistral_regex = classmethod(compat_patch) # ty: ignore[unresolved-attribute]+ return True+++def install() -> bool:+ """Patch the installed Transformers ``TokenizersBackend`` when it needs it."""+ try:+ from transformers.tokenization_utils_tokenizers import TokenizersBackend # ty: ignore[unresolved-import]+ except ImportError:+ return False+ return install_on(TokenizersBackend)+++class _PatchOnImport(importlib.abc.MetaPathFinder):+ """Patch ``TokenizersBackend`` right after its module executes, without importing it early."""++ def find_spec(self, fullname: str, path: Any = None, target: Any = None) -> Any:+ if fullname != _MODULE:+ return None+ for finder in sys.meta_path:+ if finder is self or not hasattr(finder, "find_spec"):+ continue+ spec = finder.find_spec(fullname, path, target)+ if spec is not None:+ break+ else:+ return None+ loader = spec.loader+ if loader is None or not hasattr(loader, "exec_module"):+ return spec+ original_exec = loader.exec_module++ def exec_module(module: Any) -> None:+ original_exec(module)+ backend = getattr(module, "TokenizersBackend", None)+ if isinstance(backend, type):+ install_on(backend)++ loader.exec_module = exec_module # ty: ignore[invalid-assignment]+ return spec+++def install_when_imported() -> None:+ """Patch now if Transformers' tokenizer module is loaded, else as soon as it loads."""+ module = sys.modules.get(_MODULE)+ if module is not None:+ backend = getattr(module, "TokenizersBackend", None)+ if isinstance(backend, type):+ install_on(backend)+ return+ if not any(isinstance(finder, _PatchOnImport) for finder in sys.meta_path):+ sys.meta_path.insert(0, _PatchOnImport())diff --git a/packages/sie_server/src/sie_server/adapters/sglang_vision_extract/_compat/sitecustomize.py b/packages/sie_server/src/sie_server/adapters/sglang_vision_extract/_compat/sitecustomize.pyindex 26b83cfbb..c43c204bd 100644--- a/packages/sie_server/src/sie_server/adapters/sglang_vision_extract/_compat/sitecustomize.py+++ b/packages/sie_server/src/sie_server/adapters/sglang_vision_extract/_compat/sitecustomize.py@@ -3,7 +3,11 @@SGLang 0.5.10 reads ``vision_config.rope_theta`` while Transformers 5 storesthe same value in ``vision_config.rope_parameters``. Upstream SGLang fixed thisin #28292. This site hook runs only in the OCR engine subprocess and can be-removed when the shared bundle advances to a release containing that fix.+removed when the shared bundle advances to a release containing that fix. It+also renames LightOnOCR-3-1B's legacy ``language_model.model.*`` weights to the+LightOnOCR-2-1B layout that SGLang 0.5.10 loads. The+same flag installs the ``fix_mistral_regex`` tokenizer backport+(``sie_mistral_regex_compat``), which Transformers 5.16.1 no longer needs.The SGLang model registry discovers implementations by importing every modelmodule. Importing LightOnOCR eagerly from ``sitecustomize`` races that registry@@ -31,6 +35,23 @@ _CLASS_PATCH_MARKER = "_sie_rope_parameters_compat"_IMPORT_HOOK_MARKER = "_sie_lightonocr_deferred_compat"+# LightOnOCR-3-1B ships the older Mistral3 checkpoint layout (``language_model.model.*``);+# SGLang 0.5.10's loader only maps LightOnOCR-2-1B's (``model.language_model.*``).+_LEGACY_WEIGHT_PREFIXES = (+ ("language_model.model.", "model.language_model."),+ ("language_model.lm_head.", "lm_head."),+)+++def _normalize_weight_names(weights: Any) -> Any:+ for name, tensor in weights:+ for legacy, current in _LEGACY_WEIGHT_PREFIXES:+ if name.startswith(legacy):+ name = current + name[len(legacy) :]+ break+ yield name, tensor++def _patch_lightonocr_module(module: ModuleType) -> None:model_class = getattr(module, "LightOnOCRForConditionalGeneration", None)if model_class is None:@@ -51,7 +72,14 @@ def _patch_lightonocr_module(module: ModuleType) -> None:vision_config.rope_theta = rope_thetaoriginal_init(self, config=config, prefix=prefix, **kwargs)+ original_load_weights = model_class.load_weights++ @wraps(original_load_weights)+ def compat_load_weights(self: Any, weights: Any) -> Any:+ return original_load_weights(self, _normalize_weight_names(weights))+model_class.__init__ = compat_init+ model_class.load_weights = compat_load_weightssetattr(model_class, _CLASS_PATCH_MARKER, True)@@ -97,6 +125,19 @@ def _run_next_sitecustomize() -> None:return+def _install_tokenizer_compat() -> None:+ """Load the sibling fix_mistral_regex backport (LightOnOCR-3-1B's tokenizer sets it)."""+ spec = importlib.util.spec_from_file_location(+ "_sie_mistral_regex_compat", Path(__file__).resolve().with_name("sie_mistral_regex_compat.py")+ )+ if spec is None or spec.loader is None:+ return+ module = importlib.util.module_from_spec(spec)+ spec.loader.exec_module(module)+ module.install_when_imported()++if os.environ.get("SIE_SGLANG_LIGHTON_OCR_COMPAT") == "1":_install_lightonocr_compat()+ _install_tokenizer_compat()_run_next_sitecustomize()diff --git a/packages/sie_server/src/sie_server/adapters/sglang_vision_extract/adapter.py b/packages/sie_server/src/sie_server/adapters/sglang_vision_extract/adapter.pyindex 8e77371d0..5370a90cd 100644--- a/packages/sie_server/src/sie_server/adapters/sglang_vision_extract/adapter.py+++ b/packages/sie_server/src/sie_server/adapters/sglang_vision_extract/adapter.py@@ -25,6 +25,9 @@ from sie_server.adapters.base import ModelCapabilities, ModelDimsfrom sie_server.adapters.lighton_ocr._markdown import lightonocr3_markdownfrom sie_server.adapters.sglang._window import SGLangInputTooLongErrorfrom sie_server.adapters.sglang.generation import SGLangGenerationAdapter+from sie_server.adapters.sglang_vision_extract._compat.sie_mistral_regex_compat import (+ install as install_fix_mistral_regex_compat,+)from sie_server.core.inference_output import ExtractOutputfrom sie_server.types.inputs import InvalidMediaErrorfrom sie_server.types.responses import Entity@@ -178,6 +181,7 @@ class SGLangVisionExtractAdapter(SGLangGenerationAdapter):if self._processor_use_fast is not None:processor_kwargs["use_fast"] = self._processor_use_fastinstall_transformers_security_fixes()+ install_fix_mistral_regex_compat()self._processor = AutoProcessor.from_pretrained(processor_dir, **processor_kwargs)try:diff --git a/packages/sie_server/tests/adapters/test_sglang_vision_extract.py b/packages/sie_server/tests/adapters/test_sglang_vision_extract.pyindex 5b511618d..f3a37241a 100644--- a/packages/sie_server/tests/adapters/test_sglang_vision_extract.py+++ b/packages/sie_server/tests/adapters/test_sglang_vision_extract.py@@ -504,6 +504,9 @@ class LightOnOCRForConditionalGeneration:def __init__(self, *, config, prefix="", **kwargs):self.rope_theta = config.vision_config.rope_theta+ def load_weights(self, weights):+ return [name for name, _ in weights]+EntryClass = LightOnOCRForConditionalGeneration""",encoding="utf-8",@@ -540,7 +543,22 @@ class VisionConfig:class Config:vision_config = VisionConfig()-assert registry.MODEL(config=Config()).rope_theta == 10000.0+model = registry.MODEL(config=Config())+assert model.rope_theta == 10000.0+# LightOnOCR-3-1B's legacy layout maps onto LightOnOCR-2-1B's; the 2-1B layout is unchanged.+assert model.load_weights(+ [+ ("language_model.model.layers.0.mlp.up_proj.weight", None),+ ("language_model.lm_head.weight", None),+ ("model.language_model.norm.weight", None),+ ("model.vision_encoder.ln_pre.weight", None),+ ]+) == [+ "model.language_model.layers.0.mlp.up_proj.weight",+ "lm_head.weight",+ "model.language_model.norm.weight",+ "model.vision_encoder.ln_pre.weight",+]print("native-lighton-ready")"""env = dict(os.environ)diff --git a/packages/sie_server/tests/adapters/test_sie_mistral_regex_compat.py b/packages/sie_server/tests/adapters/test_sie_mistral_regex_compat.pynew file mode 100644index 000000000..e2c19731b--- /dev/null+++ b/packages/sie_server/tests/adapters/test_sie_mistral_regex_compat.py@@ -0,0 +1,79 @@+"""The fix_mistral_regex tokenizer backport for Transformers 5.3 (SGLang bundles)."""++from typing import Any++import pytest+from sie_server.adapters.sglang_vision_extract._compat import sie_mistral_regex_compat as compat+++def _backend() -> type:+ calls: list[dict[str, Any]] = []++ class Backend:+ """Mirrors Transformers 5.3's TokenizersBackend: the flag is passed twice."""++ seen = calls++ def __init__(self, *args: Any, **kwargs: Any) -> None:+ self.init_kwargs = dict(kwargs)+ self._tokenizer = object()+ self._tokenizer = self._patch_mistral_regex(+ self._tokenizer,+ self.init_kwargs.get("name_or_path", None),+ init_kwargs=self.init_kwargs,+ fix_mistral_regex=kwargs.get("fix_mistral_regex"),+ **kwargs,+ )++ @classmethod+ def _patch_mistral_regex(+ cls,+ tokenizer: Any,+ pretrained_model_name_or_path: Any,+ init_kwargs: dict[str, Any] | None = None,+ fix_mistral_regex: Any = None,+ **kwargs: Any,+ ) -> Any:+ cls.seen.append({"init_kwargs": dict(init_kwargs or {}), "fix_mistral_regex": fix_mistral_regex, **kwargs})+ return tokenizer++ return Backend+++def test_unpatched_backend_rejects_the_flag() -> None:+ with pytest.raises(TypeError, match="multiple values for keyword argument 'fix_mistral_regex'"):+ _backend()(name_or_path="m", fix_mistral_regex=True)+++def test_patch_passes_the_flag_once_with_the_fixed_release_arguments() -> None:+ backend = _backend()+ assert compat.install_on(backend) is True+ assert compat.install_on(backend) is False+ tokenizer = backend(name_or_path="m", fix_mistral_regex=True)+ assert tokenizer.init_kwargs == {"name_or_path": "m", "fix_mistral_regex": True}+ (call,) = backend.seen+ assert call["fix_mistral_regex"] is True+ assert call["init_kwargs"] == {"name_or_path": "m", "fix_mistral_regex": True}+ assert call["name_or_path"] == "m"+++def test_patch_leaves_configs_without_the_flag_unchanged() -> None:+ backend = _backend()+ compat.install_on(backend)+ tokenizer = backend(name_or_path="m")+ assert tokenizer.init_kwargs == {"name_or_path": "m"}+ assert backend.seen == [{"init_kwargs": {"name_or_path": "m"}, "fix_mistral_regex": None, "name_or_path": "m"}]+++def test_fixed_backend_is_not_patched() -> None:+ class Fixed:+ def __init__(self, **kwargs: Any) -> None:+ self.flag = kwargs.pop("fix_mistral_regex", None)++ @classmethod+ def _patch_mistral_regex(cls, tokenizer: Any, *args: Any, **kwargs: Any) -> Any:+ return tokenizer++ init = Fixed.__init__+ assert compat.install_on(Fixed) is False+ assert Fixed.__init__ is initdiff --git a/packages/sie_server/tests/config/test_lightonocr3_1b_profiles.py b/packages/sie_server/tests/config/test_lightonocr3_1b_profiles.pynew file mode 100644index 000000000..917f90d54--- /dev/null+++ b/packages/sie_server/tests/config/test_lightonocr3_1b_profiles.py@@ -0,0 +1,120 @@+"""LightOnOCR-3-1B catalog pin, generation contract and bundle routing.++The 1B keeps LightOnOCR-2-1B's Mistral3/Pixtral architecture, so it is served like+LightOnOCR-2-1B with the LightOnOCR-3 prompt and sampling contract.+"""++from pathlib import Path+from unittest.mock import Mock++import pytest+import yaml+from sie_sdk.bundle_utils import match_bundle_models+from sie_server.adapters.sglang_vision_extract.adapter import SGLangVisionExtractAdapter+from sie_server.core.loader import expand_profile_variants, load_adapter, load_model_config, validate_pinned_revision++_SERVER = Path(__file__).resolve().parents[2]+_MODELS = _SERVER / "models"+_BUNDLES = _SERVER / "bundles"+_MODEL = "lightonai/LightOnOCR-3-1B"+_REVISION = "23d544085c886bbdace647bcfab91203299417e2"+_CONFIG = _MODELS / "lightonai__LightOnOCR-3-1B.yaml"+_SGLANG_ADAPTER = "sie_server.adapters.sglang_vision_extract.adapter:SGLangVisionExtractAdapter"+# Model-card output cap, and the SIE->SGLang httpx pool ceiling (sglang/generation.py).+_MAX_NEW_TOKENS = 4096+_CONCURRENCY = 256+_CONTEXT = 16384+_LOADTIME = {+ "mem_fraction_static": 0.70,+ "served_model_name": _MODEL,+ "trust_remote_code": False,+ "max_concurrent_requests": _CONCURRENCY,+ "meter_pages": True,+ "max_new_tokens": _MAX_NEW_TOKENS,+ "temperature": 0.1,+ "top_p": 1.0,+ "allowed_instructions": ["grounding"],+ "extra_env": {"SIE_SGLANG_LIGHTON_OCR_COMPAT": "1"},+ "extra_launch_args": ["--disable-radix-cache"],+}+++def test_catalog_pins_checkpoint_and_upstream_generation() -> None:+ config = yaml.safe_load(_CONFIG.read_text())+ assert config["sie_id"] == config["hf_id"] == _MODEL+ assert config["hf_revision"] == _REVISION+ assert config["inputs"] == {"text": False, "image": True, "audio": False, "video": False}+ assert config["tasks"] == {"encode": None, "score": None, "extract": {}}+ assert config["max_sequence_length"] == _CONTEXT+ assert list(config["profiles"]) == ["default", "markdown"]+ default = config["profiles"]["default"]+ assert default["adapter_path"] == _SGLANG_ADAPTER+ assert default["compute_precision"] == "bfloat16"+ assert default["max_batch_tokens"] == 16384+ assert default["adapter_options"]["loadtime"] == _LOADTIME+ assert default["adapter_options"]["runtime"] == {"max_new_tokens": _MAX_NEW_TOKENS, "num_beams": 1}+ markdown = config["profiles"]["markdown"]+ assert markdown["extends"] == "default"+ assert markdown["adapter_options"]["loadtime"] == {+ **_LOADTIME,+ "default_prompt": "grounding",+ "output_postprocess": "lightonocr3_markdown",+ }+++def test_loader_builds_pinned_sglang_default(monkeypatch: pytest.MonkeyPatch) -> None:+ engine_load = Mock()+ monkeypatch.setattr(SGLangVisionExtractAdapter, "load", engine_load)+ config = load_model_config(_CONFIG)+ validate_pinned_revision(config)+ adapter = load_adapter(config, _MODELS, device="cuda:0")+ assert isinstance(adapter, SGLangVisionExtractAdapter)+ assert adapter._revision == _REVISION+ assert adapter._max_seq_length == _CONTEXT+ assert adapter._max_new_tokens == _MAX_NEW_TOKENS+ assert adapter._max_new_tokens < _CONTEXT+ assert (adapter._temperature, adapter._top_p) == (0.1, 1.0)+ assert adapter._system_prompt is None+ assert adapter._chat_template_kwargs == {}+ assert adapter._trust_remote_code is False+ assert adapter._allowed_instructions == frozenset({"grounding"})+ assert adapter._output_postprocess is None+ assert adapter._resolve_prompt_and_label(None, {}) == (None, "markdown")+ assert adapter._meter_pages is True+ assert adapter.max_concurrent_dispatch() == _CONCURRENCY+ assert adapter._extra_env == {"SIE_SGLANG_LIGHTON_OCR_COMPAT": "1"}+ assert adapter._extra_launch_args == ["--disable-radix-cache"]+ engine_load.assert_not_called()+++def test_markdown_profile_retains_default_engine_options(monkeypatch: pytest.MonkeyPatch) -> None:+ monkeypatch.setattr(SGLangVisionExtractAdapter, "load", Mock())+ config = load_model_config(_CONFIG)+ default = config.resolve_profile("default")+ markdown = config.resolve_profile("markdown")+ assert markdown.adapter_path == default.adapter_path == _SGLANG_ADAPTER+ assert dict(markdown.runtime) == dict(default.runtime) == {"max_new_tokens": _MAX_NEW_TOKENS, "num_beams": 1}+ assert dict(markdown.loadtime) == {+ **default.loadtime,+ "default_prompt": "grounding",+ "output_postprocess": "lightonocr3_markdown",+ }+ variant = expand_profile_variants([config])[f"{_MODEL}:markdown"]+ validate_pinned_revision(variant)+ adapter = load_adapter(variant, _MODELS, device="cuda:0")+ assert isinstance(adapter, SGLangVisionExtractAdapter)+ assert adapter._revision == _REVISION+ assert adapter._output_postprocess == "lightonocr3_markdown"+ assert adapter._resolve_prompt_and_label(None, {}) == ("grounding", "markdown")+ assert (adapter._temperature, adapter._top_p) == (0.1, 1.0)+ assert adapter._system_prompt is None+ assert adapter.max_concurrent_dispatch() == _CONCURRENCY+++def test_routes_to_sglang_vision_extract_bundle_only() -> None:+ for bundle in sorted(_BUNDLES.glob("*.yaml")):+ expected = bundle.name == "sglang-vision-extract.yaml"+ matches = match_bundle_models(bundle, _MODELS)+ assert (_MODEL in matches) == expected, bundle.name+ assert (f"{_MODEL}:markdown" in matches) == expected, bundle.name+ assert f"{_MODEL}:transformers" not in matches, bundle.name