Skip to content

armgit / sie

Public Imported from GitHub
0

Open-source inference server and production cluster for all the models your agent needs.

feat(server): identify the BERT, cross-encoder and Nomic flash adapters (#581)

Krisztian Gajdarcd3cb9119438
diff --git a/packages/sie_server/MIGRATING_TO_SELF_HOSTED.md b/packages/sie_server/MIGRATING_TO_SELF_HOSTED.md
index ba0e6db90..026b29861 100644
--- a/packages/sie_server/MIGRATING_TO_SELF_HOSTED.md
+++ b/packages/sie_server/MIGRATING_TO_SELF_HOSTED.md
@@ -40,7 +40,8 @@ ordering. For extraction, compare schemas and extracted results. A shared
model name or matching vector dimension alone does not prove equivalence.
Single-node hybrid embedding and score routing has narrowly scoped admission:
-revision-pinned BGE-M3 profiles on the native or the flash adapter can use a
+revision-pinned profiles that have a local identity (see
+[Local profile identity](REMOTE_BACKENDS.md#local-profile-identity)) can use a
fresh SIE identity comparison or a measured OpenAI equivalence record for their
local execution identity.
Follow the [admission instructions](REMOTE_BACKENDS.md#admitting-sie-identity-fallback)
diff --git a/packages/sie_server/REMOTE_BACKENDS.md b/packages/sie_server/REMOTE_BACKENDS.md
index 8b080c9b2..2b006ee88 100644
--- a/packages/sie_server/REMOTE_BACKENDS.md
+++ b/packages/sie_server/REMOTE_BACKENDS.md
@@ -233,7 +233,11 @@ that keeps the application model name stable.
The single-node model detail and catalog responses include
`profiles.<name>.identity`, a versioned digest or `null`. Version 2 conservatively
-identifies revision-pinned BGE-M3 profiles on the native and the flash adapter. It
+identifies revision-pinned BGE-M3 profiles on the native and the flash adapter,
+and profiles on the BERT, BERT cross-encoder, Qwen2 cross-encoder and Nomic
+flash adapters. Those four fall back to adapters that have no identity when
+flash attention is unavailable, so they are identified only on a CUDA device
+with compute capability 8.0 or newer and an installed flash-attn. It
includes model/tokenizer pins, resolved profile settings, engine configuration,
device/platform, serving Python sources, the exact builds of installed inference
libraries (each library's version and installed-file record, including
@@ -260,8 +264,11 @@ flash BGE-M3 adapter, which applies LoRA per request and disables the adapter
layers for base requests; on other adapters any declared LoRA reports `null`.
SentenceTransformers and CrossEncoder require verified checkpoint module metadata:
disabling `trust_remote_code` alone does not identify installed checkpoint-selected
-code. FlagEmbedding BGE-M3 cannot identify its effective revision; other engines
-need additional runtime evidence. An identity is a descriptor, not a numerical
+code. FlagEmbedding BGE-M3 cannot identify its effective revision. The other
+flash adapters have inputs the identity does not bind: CUDA graphs that replay
+or not depending on free memory and timing, side files fetched on a best-effort
+basis, model code from the Hub that cannot be pinned, or LoRA support. Other
+engines need additional runtime evidence. An identity is a descriptor, not a numerical
measurement. This field alone does not activate hybrid routing: OpenAI profiles
need passing numerical evidence; SIE profiles require the fresh comparison below.
@@ -278,7 +285,7 @@ its installed endpoint, model serving configuration, credential reference and re
transforms to the operator files supplied to the probe. The remote execution
digest identifies the serving code and inference libraries that run the remote
profile. Credential values are never included. Version 2 local identities
-support BGE-M3 on the native and the flash adapter.
+cover the adapters listed under [Local profile identity](#local-profile-identity).
From the locked public workspace, run:
@@ -350,8 +357,9 @@ report the same immutable weights revision and non-null local execution identity
The remote profile must name an explicit upstream profile, for example
`upstream_model: BAAI/bge-m3:default`, so the upstream's bare-model routing policy
cannot change where the request runs. Both deployments must use the same pinned
-BGE-M3 execution contract on the same adapter, including hardware, libraries and
-resolved profile settings. Unknown identities remain refused.
+execution contract on the same identified adapter (see
+[Local profile identity](#local-profile-identity)), including hardware, libraries
+and resolved profile settings. Unknown identities remain refused.
Configuration load and each bridge compare bounded metadata obtained through
`SIEClient` with the deployment's configured credential, TLS and proxy policy.
@@ -416,8 +424,8 @@ name is served locally. The valid policies are `remote_only`, `fallback` and
direct worker, writing to the declared evidence path, then add
`routing: {policy: fallback, fallback_profile: remote}` to the model YAML.
Model-config hot reload admits the change in the same process. All profile
-settings must stay unchanged between measurement and activation. An immutable
-BGE-M3 local profile on the native or the flash adapter is currently required;
+settings must stay unchanged between measurement and activation. The local
+profile must have an identity (see [Local profile identity](#local-profile-identity));
unidentified engines remain closed.
Every bridge rechecks the record and its age before loading or calling the remote
diff --git a/packages/sie_server/src/sie_server/core/profile_identity.py b/packages/sie_server/src/sie_server/core/profile_identity.py
index 1becd66d2..9f814268b 100644
--- a/packages/sie_server/src/sie_server/core/profile_identity.py
+++ b/packages/sie_server/src/sie_server/core/profile_identity.py
@@ -30,6 +30,7 @@ from threadpoolctl import threadpool_info
import sie_server
from sie_server.config.engine import EngineConfig
from sie_server.config.model import ModelConfig, ResolvedProfile, is_immutable_revision, is_remote_adapter_path
+from sie_server.core.inference import is_flash_attention_available
_INFERENCE_DISTRIBUTIONS = (
"torch",
@@ -64,6 +65,23 @@ _PINNED_PROCESS_ADAPTERS = frozenset(
{
"sie_server.adapters.bge_m3:BGEM3Adapter",
"sie_server.adapters.bge_m3_flash:BGEM3FlashAdapter",
+ "sie_server.adapters.bert_flash:BertFlashAdapter",
+ "sie_server.adapters.bert_flash_cross_encoder:BertFlashCrossEncoderAdapter",
+ "sie_server.adapters.qwen2_flash_cross_encoder.adapter:Qwen2FlashCrossEncoderAdapter",
+ "sie_server.adapters.nomic_flash:NomicFlashAdapter",
+ }
+)
+
+# These adapters fall back to an adapter that has no identity when flash
+# attention is unavailable, so they are identified only where the flash path is
+# certain. The identity binds the device, its compute capability and the
+# installed flash-attn build that decide that path.
+_FLASH_ONLY_ADAPTERS = frozenset(
+ {
+ "sie_server.adapters.bert_flash:BertFlashAdapter",
+ "sie_server.adapters.bert_flash_cross_encoder:BertFlashCrossEncoderAdapter",
+ "sie_server.adapters.qwen2_flash_cross_encoder.adapter:Qwen2FlashCrossEncoderAdapter",
+ "sie_server.adapters.nomic_flash:NomicFlashAdapter",
}
)
@@ -415,6 +433,10 @@ def local_profile_identity(
or not _adapter_source_available(profile.adapter_path)
):
return None
+ if profile.adapter_path in _FLASH_ONLY_ADAPTERS and not (
+ device.startswith("cuda") and is_flash_attention_available(device)
+ ):
+ return None
if _profile_uses_lora(profile) or (
config.lora_revisions() and profile.adapter_path not in _UNMERGED_LORA_ADAPTERS
):
diff --git a/packages/sie_server/tests/core/test_profile_identity.py b/packages/sie_server/tests/core/test_profile_identity.py
index 586a0a80a..1afc2dc89 100644
--- a/packages/sie_server/tests/core/test_profile_identity.py
+++ b/packages/sie_server/tests/core/test_profile_identity.py
@@ -8,6 +8,7 @@ from types import SimpleNamespace
import numpy as np
import pytest
+import yaml
from sie_server.config.engine import EngineConfig
from sie_server.config.model import ModelConfig
from sie_server.core import profile_identity
@@ -606,3 +607,74 @@ def test_attention_backend_selection_changes_identity(monkeypatch: pytest.Monkey
enabled = profile_identity.torch.backends.cuda.flash_sdp_enabled()
monkeypatch.setattr(profile_identity.torch.backends.cuda, "flash_sdp_enabled", lambda: not enabled)
assert identity(config()) != first
+
+
+_CATALOG = Path(profile_identity.__file__).resolve().parents[3] / "models"
+_FLASH_ONLY_CATALOG = sorted(
+ path.name
+ for path in _CATALOG.glob("*.yaml")
+ if ((yaml.safe_load(path.read_text()).get("profiles") or {}).get("default") or {}).get("adapter_path")
+ in profile_identity._FLASH_ONLY_ADAPTERS
+)
+
+
+def flash_device(monkeypatch: pytest.MonkeyPatch, *, available: bool) -> None:
+ monkeypatch.setattr(profile_identity, "_execution_hardware", lambda device: {"cuda": {"capability": [8, 9]}})
+ monkeypatch.setattr(profile_identity, "is_flash_attention_available", lambda device: available)
+
+
+def test_flash_only_families_cover_catalog_models() -> None:
+ assert len(_FLASH_ONLY_CATALOG) >= 4
+
+
[email protected]("name", _FLASH_ONLY_CATALOG)
+def test_catalog_flash_models_are_identified_only_on_the_flash_path(monkeypatch: pytest.MonkeyPatch, name: str) -> None:
+ model = ModelConfig.model_validate(yaml.safe_load((_CATALOG / name).read_text()))
+ engine = EngineConfig()
+ flash_device(monkeypatch, available=True)
+ value = profile_identity.local_profile_identity(model, "default", device="cuda:0", engine_config=engine)
+ assert value is not None
+ assert value.startswith("v2:sha256:")
+ flash_device(monkeypatch, available=False)
+ assert profile_identity.local_profile_identity(model, "default", device="cuda:0", engine_config=engine) is None
+ assert profile_identity.local_profile_identity(model, "default", device="cpu", engine_config=engine) is None
+
+
+ "adapter",
+ [
+ "sie_server.adapters.xlm_roberta_flash:XLMRobertaFlashAdapter",
+ "sie_server.adapters.modernbert_flash:ModernBERTFlashAdapter",
+ "sie_server.adapters.splade_flash.adapter:SPLADEFlashAdapter",
+ "sie_server.adapters.qwen2_flash:Qwen2FlashAdapter",
+ "sie_server.adapters.modernbert_flash_cross_encoder:ModernBertFlashCrossEncoderAdapter",
+ "sie_server.adapters.jina_flash_cross_encoder:JinaFlashCrossEncoderAdapter",
+ "sie_server.adapters.colbert_modernbert_flash.adapter:ColBERTModernBERTFlashAdapter",
+ "sie_server.adapters.colbert_rotary_flash:ColBERTRotaryFlashAdapter",
+ "sie_server.adapters.gte_sparse_flash:GTESparseFlashAdapter",
+ "sie_server.adapters.rope_flash:RoPEFlashAdapter",
+ ],
+)
+def test_flash_families_with_unbound_inputs_have_no_identity(monkeypatch: pytest.MonkeyPatch, adapter: str) -> None:
+ flash_device(monkeypatch, available=True)
+ data = config().model_dump()
+ data["profiles"]["default"]["adapter_path"] = adapter
+ assert profile_identity._adapter_source_available(adapter)
+ assert identity(ModelConfig.model_validate(data), device="cuda:0") is None
+
+
[email protected]("trust", [True, "true"])
+def test_flash_only_families_still_refuse_remote_code(monkeypatch: pytest.MonkeyPatch, trust: object) -> None:
+ flash_device(monkeypatch, available=True)
+ data = config().model_dump()
+ data["profiles"]["default"]["adapter_path"] = (
+ "sie_server.adapters.bert_flash_cross_encoder:BertFlashCrossEncoderAdapter"
+ )
+ assert identity(ModelConfig.model_validate(data), device="cuda:0") is not None
+ data["profiles"]["default"]["adapter_options"]["loadtime"]["trust_remote_code"] = trust
+ assert identity(ModelConfig.model_validate(data), device="cuda:0") is None
+
+
+def test_an_identified_fallback_needs_no_flash_path(monkeypatch: pytest.MonkeyPatch) -> None:
+ flash_device(monkeypatch, available=False)
+ assert identity(flash_config(), device="cuda:0") is not None