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(api): report locally ready LoRA adapters

svonavac432d4c4df12
diff --git a/packages/sie_sdk/src/sie_sdk/types.py b/packages/sie_sdk/src/sie_sdk/types.py
index 939bdbc8e..23c8be4c5 100644
--- a/packages/sie_sdk/src/sie_sdk/types.py
+++ b/packages/sie_sdk/src/sie_sdk/types.py
@@ -431,6 +431,9 @@ class ModelInfo(TypedDict, total=False):
profiles: dict[str, ProfileInfo]
"""Servable profiles keyed by name; address one as ``"model@profile"``."""
+ lora_adapters: list[str]
+ """Single-server ready LoRA names; absent on gateways (not fleet residency)."""
+
capabilities: ModelCapabilities | None
"""``None`` for models that declare no ``generate`` task."""
diff --git a/packages/sie_server/README.md b/packages/sie_server/README.md
index 09bf6b86b..433f5c279 100644
--- a/packages/sie_server/README.md
+++ b/packages/sie_server/README.md
@@ -1157,8 +1157,71 @@ auto-retries; see `packages/sie_sdk/README.md` for client-side controls.
| `SIE_MAX_BATCH_WAIT_MS` | `15.0` | Initial value for the adaptive first-request batch timeout. At runtime the PI batching controller steers it between `SIE_ADAPTIVE_BATCHING__MIN_WAIT_MS` and `SIE_ADAPTIVE_BATCHING__MAX_WAIT_MS`, so it is a starting point rather than a fixed wait. |
| `SIE_MAX_CONCURRENT_REQUESTS` | `512` | Per-worker queue size; admission control returns `QUEUE_FULL` above this. |
| `SIE_MAX_LORAS_PER_MODEL` | `10` | Maximum concurrent LoRA adapters per base model. A request loads or selects only the adapters its selected profile declares. `options.lora` or `options.lora_id` naming any other is rejected with HTTP 400: `INVALID_INPUT` from this server, and `INVALID_REQUEST` from the gateway (code `unknown_lora_adapter` where it answers in the OpenAI error envelope). |
+
| `SIE_MAX_ITEM_TEXT_BYTES` | `2097152` (2 MiB) | Most bytes of UTF-8 one encode, score, or extract item may carry in its `text` and `metadata` together. A larger item is rejected with `INVALID_INPUT` (HTTP 400) before it is tokenized. Generation prompts are not items and are not affected. |
+SGLang generation and embedding profiles can defer declared LoRAs until a
+request selects them. Keep one source allowlist in `lora_paths` and use
+`preload_loras` to select startup adapters:
+
+```yaml
+adapter_options:
+ loadtime:
+ mem_fraction_static: 0.80
+ lora_paths:
+ support:
+ id: acme/support-lora
+ revision: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa # replace with the repository's immutable commit
+ legal: acme/legal-lora
+ preload_loras: []
+ max_lora_rank: 16
+ lora_target_modules: [q_proj, v_proj]
+ max_loras_per_batch: 2
+```
+
+Omitting `preload_loras` keeps the existing behavior: every declared source
+loads at startup and remains pinned in SIE. An empty list defers every source;
+a nonempty list preloads and pins only those served names. Names must be unique
+members of the selected profile's map. Profile `loadtime` blocks use full
+replacement when a child supplies one, so restate the source map and its other
+options when changing only a child's preload selection.
+
+Deferred adapters require the maximum rank and target modules at engine launch
+because SGLang allocates its LoRA buffers then. LoRA profiles require an explicit
+memory fraction. The resolved `max_loras_per_model` engine setting (normally
+`SIE_MAX_LORAS_PER_MODEL`) bounds resident adapters, including pinned preloads
+and in-flight loads; `max_loras_per_batch` and the preload count cannot exceed
+it. When full, SIE drains and evicts the least-recently-used unpinned adapter. An
+adapter being loaded or drained retains its slot, and all-pinned/full capacity
+returns a retry response. Unconfirmed attach rollback or unload retains the
+slot and requires a model reload rather than risking unbounded residency.
+
+Generation and chat requests select a selected-profile declared name with
+`lora_adapter` (a served alias or its declared source id);
+embedding requests use `options.lora` (or a declared source `options.lora_id`).
+The first request for a cold adapter returns HTTP 503 `LORA_LOADING` with
+`Retry-After`; retry after loading finishes. Source files are downloaded outside
+the inference mutation lock, while attachment may briefly pause SGLang's
+scheduler. Requests cannot supply a new repository or override its configured
+revision. Runtime adapters must contain ordinary LoRA A/B safetensors, without
+base-weight transforms, saved base modules, variable rank/alpha patterns,
+rsLoRA, or DoRA.
+
+Generation streams keep independent adapter leases and can run concurrently
+through SGLang's continuous batcher. Eviction refuses new leases and waits for
+active streams to finish. Embedding dispatch remains serialized by selected
+LoRA; this change does not introduce a mixed-adapter embedding forward. Deferred
+LoRA profiles require one tokenizer worker and one data-parallel worker;
+LoRA generation on those profiles supports `n=1` and `best_of=1` because pinned
+upstream versions have unsafe multi-candidate unload accounting. SGLang
+0.5.10.post1 uses SIE's scoped GPU-slot release compatibility hook; 0.5.20
+already implements that cleanup natively.
+
+The single-server `/v1/models` response includes top-level `lora_adapters` with
+ready served names, excluding adapters being loaded or evicted. Gateways omit
+this worker-local snapshot. Their `capabilities.lora_adapters` continues to
+advertise the declared allowlist, including cold adapters.
+
### Compute & precision
| Env var | Default | Effect |
diff --git a/packages/sie_server/src/sie_server/api/models.py b/packages/sie_server/src/sie_server/api/models.py
index d6f70f6ec..a9def41ea 100644
--- a/packages/sie_server/src/sie_server/api/models.py
+++ b/packages/sie_server/src/sie_server/api/models.py
@@ -110,6 +110,8 @@ class ModelInfo(BaseModel):
max_sequence_length: int | None = None
profiles: dict[str, ProfileInfo] = {}
+ lora_adapters: list[str] = Field(default_factory=list)
+ """LoRA served names currently ready on this worker, excluding loading/evicting adapters."""
revision: str | None = None
"""Pinned HF commit SHA for the model's weights (design §6.6).
@@ -250,6 +252,7 @@ async def list_models(http_request: Request) -> ModelsListResponse:
outputs=config.outputs,
dims=config.dims,
loaded=registry.is_loaded(name),
+ lora_adapters=registry.loaded_lora_names(name),
state=state,
last_error=last_error,
max_sequence_length=config.max_sequence_length,
@@ -300,6 +303,7 @@ async def get_model(model: str, http_request: Request) -> ModelInfo:
outputs=config.outputs,
dims=config.dims,
loaded=registry.is_loaded(model),
+ lora_adapters=registry.loaded_lora_names(model),
state=state,
last_error=last_error,
max_sequence_length=config.max_sequence_length,
diff --git a/packages/sie_ts_sdk/src/types.ts b/packages/sie_ts_sdk/src/types.ts
index f2fee5cf1..572979c73 100644
--- a/packages/sie_ts_sdk/src/types.ts
+++ b/packages/sie_ts_sdk/src/types.ts
@@ -369,6 +369,8 @@ export interface ModelInfo {
revision?: string | null;
/** Servable profiles keyed by name; address one as "model@profile" */
profiles?: Record<string, ProfileInfo>;
+ /** Single-server ready LoRA names; absent on gateways (not fleet residency). */
+ lora_adapters?: string[];
/** Advertised model capabilities; null for models with no `generate` task */
capabilities?: ModelCapabilities | null;
/** Gateway-only queue snapshot; absent when talking to a single server */
@@ -407,6 +409,7 @@ export interface WireModelInfo {
max_sequence_length?: number | null;
revision?: string | null;
profiles?: Record<string, ProfileInfo>;
+ lora_adapters?: string[];
capabilities?: ModelCapabilities | null;
pending_generation?: PendingGeneration;
routing?: ModelRouting;
@@ -427,6 +430,7 @@ const MODEL_INFO_WIRE_FIELD_SET: Record<keyof WireModelInfo, true> = {
inputs: true,
last_error: true,
loaded: true,
+ lora_adapters: true,
max_sequence_length: true,
name: true,
outputs: true,
diff --git a/packages/sie_ts_sdk/tests/wireContract.test.ts b/packages/sie_ts_sdk/tests/wireContract.test.ts
index 44d4b4865..3c968562e 100644
--- a/packages/sie_ts_sdk/tests/wireContract.test.ts
+++ b/packages/sie_ts_sdk/tests/wireContract.test.ts
@@ -64,6 +64,7 @@ function expectEveryTypedFieldPresent(model: ModelInfo | undefined): void {
const FULL_WIRE_ENTRY = {
name: "BAAI/bge-m3",
loaded: true,
+ lora_adapters: ["support"],
state: "loaded",
last_error: null,
inputs: ["text"],
diff --git a/packages/wire-fixtures/model_info.json b/packages/wire-fixtures/model_info.json
index 182a8b422..af79197e1 100644
--- a/packages/wire-fixtures/model_info.json
+++ b/packages/wire-fixtures/model_info.json
@@ -10,7 +10,7 @@
"packages/sie_gateway/src/handlers/models.rs; schema of record is",
"packages/sie_gateway/src/openapi.rs::ModelInfoWire. The single-server",
"emitter is packages/sie_server/src/sie_server/api/models.py::ModelInfo,",
- "which is a subset (no pending_generation)."
+ "which omits pending_generation and adds local ready lora_adapters."
],
"typed": [
"aliases",
@@ -19,6 +19,7 @@
"inputs",
"last_error",
"loaded",
+ "lora_adapters",
"max_sequence_length",
"name",
"outputs",
@@ -39,6 +40,7 @@
"optionality": "Python marks every typed key optional (`total=False`). TypeScript requires `name`, `loaded`, `inputs` and `outputs` on both `ModelInfo` and `WireModelInfo`; its remaining keys are optional. `pending_generation` is gateway-only. `last_error`/`max_sequence_length`/`revision`/`capabilities` are the four the emitters can send as an explicit null, so the SDK types admit null on each. The fixture pins which keys are declarable, not which are always present.",
"ts_renames": "The TS SDK camelCases three top-level keys \u2014 max_sequence_length -> maxSequenceLength, last_error -> lastError, pending_generation -> pendingGeneration \u2014 and leaves nested objects wire-shaped. Its consumer test checks the wire-side names listed here.",
"aliases": "Short task-tier names resolving to this model. Always emitted, empty when the model has none, so callers can distinguish 'no aliases' from an older gateway. Only catalog- or operator-declared names appear; the gateway's compiled-in routing defaults are not public API and are never listed.",
- "routing": "How the bare model name is served: `policy` (`remote_only`, `fallback`, `threshold`, or null for local only) and `upstream_kind` (`sie`, `openai`, or null). The single server and the gateway emit it on every entry."
+ "routing": "How the bare model name is served: `policy` (`remote_only`, `fallback`, `threshold`, or null for local only) and `upstream_kind` (`sie`, `openai`, or null). The single server and the gateway emit it on every entry.",
+ "lora_adapters": "Single-server only: ready served LoRA names, excluding loading or evicting adapters. Gateways omit this field because they do not aggregate worker residency; capabilities.lora_adapters remains the declared allowlist."
}
}