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(remote): expose diagnostic numerical process snapshots (#557)

Krisztian Gajdar6113be1a631c
diff --git a/packages/sie_server/src/sie_server/ipc_server.py b/packages/sie_server/src/sie_server/ipc_server.py
index 2b8e648e3..58c7818e7 100644
--- a/packages/sie_server/src/sie_server/ipc_server.py
+++ b/packages/sie_server/src/sie_server/ipc_server.py
@@ -18,14 +18,18 @@ import msgpack
import msgspec
from sie_server.adapter_call_loop import handle_run_batch
+from sie_server.config.equivalence import model_contract_digest
+from sie_server.config.model import ModelConfig
from sie_server.core.gpu_health import gpu_is_healthy_async
from sie_server.core.grammar_routing import resolve_grammar_serving_model
+from sie_server.core.profile_identity import local_profile_identity, runtime_instance_id
from sie_server.core.readiness import is_ready
from sie_server.ipc_types import (
IPC_VERSION,
METHOD_APPLY_MODEL_CONFIG,
METHOD_DRAIN,
METHOD_ENSURE_MODEL_READY,
+ METHOD_NUMERICAL_PROFILE_SNAPSHOT,
METHOD_PING,
METHOD_PROCESS_ENCODE_BATCH,
METHOD_PROCESS_EXTRACT_BATCH,
@@ -47,6 +51,9 @@ from sie_server.ipc_types import (
GenerateEvent,
IpcResponseChunkV1,
ItemOutcome,
+ NumericalProfileObservation,
+ NumericalProfileSnapshotRequest,
+ NumericalProfileSnapshotResponse,
PingRequest,
PingResponse,
ProcessEncodeBatchRequest,
@@ -79,6 +86,8 @@ _LEN_BYTES = _LEN_STRUCT.size
# any decoded WorkItem batch we would send in-band — large payloads arrive
# via the payload store, not via IPC.
_MAX_FRAME_BYTES = 32 * 1024 * 1024
+_MAX_NUMERICAL_PROFILES = 1024
+_MAX_NUMERICAL_MODEL_ID_BYTES = 1024
# A negotiated response may exceed one legacy IPC frame, but remains tightly
# bounded so a malformed or unexpectedly large backend output cannot grow the
@@ -506,6 +515,10 @@ class IpcServer:
resp_body = await self._handle_ensure_ready(msgspec.convert(body, EnsureModelReadyRequest))
elif method == METHOD_WORKER_CAPABILITIES:
resp_body = self._handle_worker_capabilities(msgspec.convert(body, WorkerCapabilitiesRequest))
+ elif method == METHOD_NUMERICAL_PROFILE_SNAPSHOT:
+ resp_body = await self._handle_numerical_profile_snapshot(
+ msgspec.convert(body, NumericalProfileSnapshotRequest)
+ )
elif method == METHOD_PROCESS_ENCODE_BATCH:
resp_body = await self._handle_process_encode(msgspec.convert(body, ProcessEncodeBatchRequest))
elif method == METHOD_PROCESS_SCORE_BATCH:
@@ -755,6 +768,48 @@ class IpcServer:
async def _handle_set_pinned_models(self, req: SetPinnedModelsRequest) -> SetPinnedModelsResponse:
return await self._executor.set_pinned_models(req)
+ async def _handle_numerical_profile_snapshot(
+ self, _req: NumericalProfileSnapshotRequest
+ ) -> NumericalProfileSnapshotResponse:
+ try:
+ async with self._executor.registry.execution_lease():
+ return await asyncio.to_thread(self._numerical_profile_snapshot)
+ except Exception as exc: # noqa: BLE001
+ error_class = (
+ "io"
+ if isinstance(exc, OSError)
+ else "invalid"
+ if isinstance(exc, TypeError | ValueError)
+ else "internal"
+ )
+ logger.debug("Could not collect numerical profile snapshot (error_class=%s)", error_class)
+ return NumericalProfileSnapshotResponse(runtime_instance_id=runtime_instance_id())
+
+ def _numerical_profile_snapshot(self) -> NumericalProfileSnapshotResponse:
+ registry = self._executor.registry
+ configs = registry.get_configs_snapshot()
+ complete = len(configs) <= _MAX_NUMERICAL_PROFILES
+ observations = []
+ for name in sorted(configs)[:_MAX_NUMERICAL_PROFILES]:
+ if not name or len(name.encode()) > _MAX_NUMERICAL_MODEL_ID_BYTES:
+ complete = False
+ continue
+ config = configs[name]
+ identity = None
+ contract = None
+ if isinstance(config, ModelConfig):
+ identity = local_profile_identity(
+ config,
+ "default",
+ device=registry.profile_execution_device(name) or "",
+ engine_config=registry.engine_config,
+ )
+ contract = model_contract_digest(config)
+ else:
+ complete = False
+ observations.append(NumericalProfileObservation(name, identity, contract))
+ return NumericalProfileSnapshotResponse(runtime_instance_id(), observations, complete)
+
def _handle_worker_capabilities(self, _req: WorkerCapabilitiesRequest) -> WorkerCapabilitiesResponse:
generation_models: list[str] = []
supported_models: list[str] = []
diff --git a/packages/sie_server/src/sie_server/ipc_types.py b/packages/sie_server/src/sie_server/ipc_types.py
index ade99e0ab..fdce5143a 100644
--- a/packages/sie_server/src/sie_server/ipc_types.py
+++ b/packages/sie_server/src/sie_server/ipc_types.py
@@ -54,6 +54,7 @@ METHOD_PROCESS_SCORE_BATCH = "ProcessScoreBatch"
METHOD_PROCESS_EXTRACT_BATCH = "ProcessExtractBatch"
METHOD_PROCESS_GENERATE = "ProcessGenerate"
METHOD_WORKER_CAPABILITIES = "WorkerCapabilities"
+METHOD_NUMERICAL_PROFILE_SNAPSHOT = "NumericalProfileSnapshot"
METHOD_SIGNAL_GENERATE_CANCEL = "SignalGenerateCancel"
# RPC that accepts a whole pre-formed batch (single-op, mixed items)
# and returns ``BatchOutcome`` unchanged.
@@ -266,6 +267,22 @@ class WorkerCapabilitiesRequest(msgspec.Struct):
pass
+class NumericalProfileSnapshotRequest(msgspec.Struct):
+ pass
+
+
+class NumericalProfileObservation(msgspec.Struct):
+ model_id: str
+ local_identity: str | None = None
+ model_contract_sha256: str | None = None
+
+
+class NumericalProfileSnapshotResponse(msgspec.Struct):
+ runtime_instance_id: str | None = None
+ profiles: list[NumericalProfileObservation] = msgspec.field(default_factory=list)
+ complete: bool = False
+
+
class WorkerCapabilitiesResponse(msgspec.Struct):
supports_execution_authority_v1: bool = False
has_generation_models: bool = False
diff --git a/packages/sie_server/tests/test_ipc_server.py b/packages/sie_server/tests/test_ipc_server.py
index 1904487d4..ab722e523 100644
--- a/packages/sie_server/tests/test_ipc_server.py
+++ b/packages/sie_server/tests/test_ipc_server.py
@@ -6,6 +6,7 @@ import hashlib
import os
import struct
import tempfile
+import threading
import time
import uuid
from collections.abc import Iterator
@@ -23,8 +24,10 @@ import yaml
from sie_config.model_registry import ModelRegistry as ConfigModelRegistry
from sie_sdk.bundle_utils import match_bundle_models
from sie_server.api.ws import BundleConfigView, compute_bundle_config_hash_cached
+from sie_server.config.equivalence import model_contract_digest
from sie_server.config.model import ModelConfig
from sie_server.core.inference_output import ExtractOutput, ScoreOutput
+from sie_server.core.profile_identity import runtime_instance_id
from sie_server.core.readiness import mark_not_ready, mark_ready, register_liveness_probe
from sie_server.core.registry import ModelRegistry
from sie_server.core.timing import RequestTiming
@@ -37,6 +40,7 @@ from sie_server.ipc_types import (
ApplyModelConfigRequest,
BatchOutcome,
IpcResponseChunkV1,
+ NumericalProfileSnapshotRequest,
ProcessEncodeBatchRequest,
ProcessExtractBatchRequest,
ProcessGenerateRequest,
@@ -2673,6 +2677,96 @@ class TestHeartbeat:
class TestGenerationSidecarIpc:
+ @pytest.mark.asyncio
+ async def test_numerical_snapshot_reports_current_process_and_profile_contract(
+ self, monkeypatch: pytest.MonkeyPatch
+ ) -> None:
+ server, registry, _ = _pinned_execution_server(monkeypatch)
+ observed = []
+
+ def identity(config: ModelConfig, profile: str, **kwargs: object) -> str:
+ observed.append((config.sie_id, profile, kwargs))
+ return "v1:sha256:" + "a" * 64
+
+ monkeypatch.setattr(ipc_server_module, "local_profile_identity", identity)
+ config = registry.get_config("Qwen/Qwen3.6-27B")
+ response = await server._handle_numerical_profile_snapshot(NumericalProfileSnapshotRequest())
+ assert response.runtime_instance_id == runtime_instance_id()
+ assert response.complete
+ assert msgspec.to_builtins(response.profiles) == [
+ {
+ "model_id": config.sie_id,
+ "local_identity": "v1:sha256:" + "a" * 64,
+ "model_contract_sha256": model_contract_digest(config),
+ }
+ ]
+ assert observed == [
+ (
+ config.sie_id,
+ "default",
+ {
+ "device": registry.profile_execution_device(config.sie_id) or "",
+ "engine_config": registry.engine_config,
+ },
+ )
+ ]
+ assert not registry.loaded_model_names
+
+ @pytest.mark.asyncio
+ async def test_numerical_snapshot_failure_is_incomplete_and_exposes_no_exception(
+ self, caplog: pytest.LogCaptureFixture
+ ) -> None:
+ caplog.set_level("DEBUG", logger="sie_server.ipc_server")
+ executor, registry = _make_executor()
+ registry.get_configs_snapshot.side_effect = RuntimeError("private upstream credential")
+ async with IpcServer(_short_sock_path(), executor, worker_id="w") as server:
+ client = await _Client.connect(server.socket_path)
+ try:
+ response = await client.rpc("NumericalProfileSnapshot", {})
+ finally:
+ await client.close()
+ assert response["ok"]
+ assert response["body"] == {"runtime_instance_id": runtime_instance_id(), "profiles": [], "complete": False}
+ assert "private" not in str(response)
+ assert "Could not collect numerical profile snapshot (error_class=internal)" in caplog.text
+ assert "private upstream credential" not in caplog.text
+
+ @pytest.mark.asyncio
+ async def test_numerical_snapshot_pins_config_and_reports_a_bounded_roster(
+ self, monkeypatch: pytest.MonkeyPatch
+ ) -> None:
+ server, registry, _ = _pinned_execution_server(monkeypatch)
+ before = registry.get_config("Qwen/Qwen3.6-27B")
+ data = before.model_dump(mode="json")
+ data["profiles"]["default"]["max_batch_tokens"] += 1
+ after = ModelConfig.model_validate(data)
+ started, finish = threading.Event(), threading.Event()
+
+ def identity(_config: ModelConfig, _profile: str, **_kwargs: object) -> None:
+ started.set()
+ assert finish.wait(2)
+
+ monkeypatch.setattr(ipc_server_module, "local_profile_identity", identity)
+ snapshot = asyncio.create_task(server._handle_numerical_profile_snapshot(NumericalProfileSnapshotRequest()))
+ try:
+ assert await asyncio.to_thread(started.wait, 1)
+ reload = asyncio.create_task(registry.add_config_async(after))
+ await asyncio.sleep(0)
+ assert not reload.done()
+ finally:
+ finish.set()
+ response, _ = await asyncio.wait_for(asyncio.gather(snapshot, reload), 2)
+ assert response.complete
+ assert response.profiles[0].local_identity is None
+ assert response.profiles[0].model_contract_sha256 == model_contract_digest(before)
+ current = await server._handle_numerical_profile_snapshot(NumericalProfileSnapshotRequest())
+ assert current.profiles[0].model_contract_sha256 == model_contract_digest(after)
+ assert current.profiles[0].model_contract_sha256 != response.profiles[0].model_contract_sha256
+ monkeypatch.setattr(ipc_server_module, "_MAX_NUMERICAL_PROFILES", 0)
+ bounded = await server._handle_numerical_profile_snapshot(NumericalProfileSnapshotRequest())
+ assert not bounded.complete
+ assert bounded.profiles == []
+
@pytest.mark.asyncio
async def test_worker_capabilities_reports_generation_models(self) -> None:
executor, reg = _make_executor()
diff --git a/packages/sie_server_sidecar/docs/architecture-guide.md b/packages/sie_server_sidecar/docs/architecture-guide.md
index 88ddec1d2..4f2af4cae 100644
--- a/packages/sie_server_sidecar/docs/architecture-guide.md
+++ b/packages/sie_server_sidecar/docs/architecture-guide.md
@@ -322,6 +322,7 @@ The Rust and Python protocol copies define the same method names:
- `ProcessExtractBatch`
- `ProcessGenerate`
- `WorkerCapabilities`
+- `NumericalProfileSnapshot`
- `SignalGenerateCancel`
- `RunBatch`
- `RunBatchWithExecutionAuthorityV1`
@@ -333,6 +334,28 @@ The Rust and Python protocol copies define the same method names:
`tools/check_ipc_types_parity.py` checks the Rust protocol schema against
`packages/sie_server/src/sie_server/ipc_types.py`.
+### Numerical process observations (#415)
+
+`NumericalProfileSnapshot` is an optional, on-demand diagnostic RPC. The Python
+backend returns its process incarnation, registered model contract digests, and
+available local numerical profile identities under one configuration execution
+lease. It does not load model weights or run inference. Unsupported profiles
+retain an absent identity; failures return an incomplete snapshot without error
+details. A roster contains at most 1,024 models, with each model ID limited to
+1,024 UTF-8 bytes. Truncation or an invalid configuration makes it incomplete.
+
+The adapter pool retains one observation for every configured child, including
+unavailable and legacy backends. Missing fields are incomplete, malformed
+digests are invalid, and a duplicated process incarnation invalidates both
+children. Each call refreshes the observations so a replacement process does
+not inherit the previous incarnation. The Candle backend does not implement
+this optional method and is reported as unavailable.
+
+These observations do not change readiness, execution authority, or routing.
+They provide inputs for collecting process-bound numerical evidence; accepting
+that evidence still requires the entire reachable fleet and a queue execution
+fence that pins the proof, configuration, and process incarnation.
+
### Execution authority protocol amendment (#415)
Verified execution uses the two `WithExecutionAuthorityV1` methods. They
diff --git a/packages/sie_server_sidecar/src/backend/adapter_pool.rs b/packages/sie_server_sidecar/src/backend/adapter_pool.rs
index 4af57d76e..f25ded7a5 100644
--- a/packages/sie_server_sidecar/src/backend/adapter_pool.rs
+++ b/packages/sie_server_sidecar/src/backend/adapter_pool.rs
@@ -13,6 +13,7 @@ use std::time::Duration;
use async_trait::async_trait;
use futures_util::future::join_all;
+use serde::Serialize;
use tracing::{debug, info, warn};
use crate::backend::python_ipc::map_ipc_error;
@@ -20,13 +21,60 @@ use crate::backend::{BackendError, InferenceBackend};
use crate::ipc_client::{IpcClient, IpcError};
use crate::ipc_types::{
ApplyModelConfigRequest, ApplyModelConfigResponse, BatchOutcome, DrainResponse,
- EnsureModelReadyResponse, GenerateEvent, PingResponse, ProcessEncodeBatchRequest,
- ProcessExtractBatchRequest, ProcessGenerateRequest, ProcessScoreBatchRequest,
- ReplaceModelConfigsRequest, ReplaceModelConfigsResponse, RunBatchRequest,
- SetPinnedModelsResponse, SignalGenerateCancelResponse, WorkerCapabilitiesResponse,
+ EnsureModelReadyResponse, GenerateEvent, NumericalProfileSnapshotResponse, PingResponse,
+ ProcessEncodeBatchRequest, ProcessExtractBatchRequest, ProcessGenerateRequest,
+ ProcessScoreBatchRequest, ReplaceModelConfigsRequest, ReplaceModelConfigsResponse,
+ RunBatchRequest, SetPinnedModelsResponse, SignalGenerateCancelResponse,
+ WorkerCapabilitiesResponse,
};
use crate::runtime_state::RuntimeState;
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub enum NumericalSnapshotStatus {
+ Observed,
+ Incomplete,
+ Unavailable,
+ Invalid,
+}
+
+#[derive(Debug, Clone, Serialize)]
+pub struct NumericalProcessObservation {
+ pub child_index: usize,
+ pub status: NumericalSnapshotStatus,
+ pub snapshot: Option<NumericalProfileSnapshotResponse>,
+}
+
+fn sha256_digest(value: &str) -> bool {
+ value.len() == 64
+ && value
+ .bytes()
+ .all(|value| value.is_ascii_digit() || (b'a'..=b'f').contains(&value))
+}
+
+fn valid_numerical_snapshot(snapshot: &NumericalProfileSnapshotResponse) -> bool {
+ let mut models = HashSet::new();
+ snapshot
+ .runtime_instance_id
+ .as_deref()
+ .is_none_or(sha256_digest)
+ && snapshot.profiles.len() <= 1024
+ && snapshot.profiles.iter().all(|profile| {
+ !profile.model_id.is_empty()
+ && profile.model_id.len() <= 1024
+ && models.insert(&profile.model_id)
+ && profile
+ .model_contract_sha256
+ .as_deref()
+ .is_none_or(sha256_digest)
+ && profile.local_identity.as_deref().is_none_or(|identity| {
+ identity
+ .strip_prefix("v1:sha256:")
+ .is_some_and(sha256_digest)
+ })
+ })
+}
+
struct AdapterWorkerChild {
index: usize,
socket_path: PathBuf,
@@ -220,6 +268,63 @@ impl AdapterWorkerPool {
}
}
+ /// Diagnostic snapshots grant no routing authority or readiness capability.
+ pub async fn numerical_process_inventory(&self) -> Vec<NumericalProcessObservation> {
+ let mut observations = join_all(self.children.iter().map(|child| async move {
+ match child.ipc.numerical_profile_snapshot().await {
+ Ok(snapshot) if valid_numerical_snapshot(&snapshot) => {
+ NumericalProcessObservation {
+ child_index: child.index,
+ status: if snapshot.complete
+ && snapshot.runtime_instance_id.is_some()
+ && snapshot
+ .profiles
+ .iter()
+ .all(|profile| profile.model_contract_sha256.is_some())
+ {
+ NumericalSnapshotStatus::Observed
+ } else {
+ NumericalSnapshotStatus::Incomplete
+ },
+ snapshot: Some(snapshot),
+ }
+ }
+ Ok(_) => NumericalProcessObservation {
+ child_index: child.index,
+ status: NumericalSnapshotStatus::Invalid,
+ snapshot: None,
+ },
+ Err(_) => NumericalProcessObservation {
+ child_index: child.index,
+ status: NumericalSnapshotStatus::Unavailable,
+ snapshot: None,
+ },
+ }
+ }))
+ .await;
+ let mut counts = HashMap::new();
+ for observation in &observations {
+ if let Some(instance) = observation
+ .snapshot
+ .as_ref()
+ .and_then(|snapshot| snapshot.runtime_instance_id.as_ref())
+ {
+ *counts.entry(instance.clone()).or_insert(0usize) += 1;
+ }
+ }
+ for observation in &mut observations {
+ if observation
+ .snapshot
+ .as_ref()
+ .and_then(|snapshot| snapshot.runtime_instance_id.as_ref())
+ .is_some_and(|instance| counts[instance] > 1)
+ {
+ observation.status = NumericalSnapshotStatus::Invalid;
+ }
+ }
+ observations
+ }
+
pub async fn apply_model_config(
&self,
req: ApplyModelConfigRequest,
@@ -1064,6 +1169,132 @@ mod tests {
})
}
+ #[tokio::test]
+ async fn numerical_inventory_preserves_missing_legacy_and_replaced_processes() {
+ async fn spawn_snapshot_worker(
+ path: PathBuf,
+ snapshot: Arc<Mutex<serde_json::Value>>,
+ ) -> tokio::task::JoinHandle<()> {
+ let listener = UnixListener::bind(path).unwrap();
+ tokio::spawn(async move {
+ loop {
+ let Ok((mut socket, _)) = listener.accept().await else {
+ return;
+ };
+ let snapshot = Arc::clone(&snapshot);
+ tokio::spawn(async move {
+ loop {
+ let mut length = [0_u8; 4];
+ if socket.read_exact(&mut length).await.is_err() {
+ return;
+ }
+ let mut bytes = vec![0; u32::from_be_bytes(length) as usize];
+ if socket.read_exact(&mut bytes).await.is_err() {
+ return;
+ }
+ let request: serde_json::Value = rmp_serde::from_slice(&bytes).unwrap();
+ assert_eq!(request["method"], "NumericalProfileSnapshot");
+ let body = snapshot.lock().unwrap().clone();
+ let response = rmp_serde::to_vec_named(&serde_json::json!({"version": crate::ipc_types::IPC_VERSION, "request_id": request["request_id"], "ok": true, "body": body})).unwrap();
+ if socket
+ .write_all(&(response.len() as u32).to_be_bytes())
+ .await
+ .is_err()
+ || socket.write_all(&response).await.is_err()
+ {
+ return;
+ }
+ }
+ });
+ }
+ })
+ }
+ let dir = tempfile::Builder::new()
+ .prefix("sie-num-")
+ .tempdir_in("/tmp")
+ .unwrap();
+ let first_path = dir.path().join("first.sock");
+ let legacy_path = dir.path().join("legacy.sock");
+ let first = Arc::new(Mutex::new(
+ serde_json::json!({"runtime_instance_id": "a".repeat(64), "complete": true, "profiles": [{"model_id": "m", "local_identity": format!("v1:sha256:{}", "c".repeat(64)), "model_contract_sha256": "d".repeat(64)}]}),
+ ));
+ let legacy = Arc::new(Mutex::new(serde_json::json!({})));
+ let first_server = spawn_snapshot_worker(first_path.clone(), Arc::clone(&first)).await;
+ let legacy_server = spawn_snapshot_worker(legacy_path.clone(), Arc::clone(&legacy)).await;
+ let pool = pool_with_paths(&[first_path, legacy_path, dir.path().join("missing.sock")]);
+ let initial_ready = pool.ready_child_count();
+ let observations = pool.numerical_process_inventory().await;
+ assert_eq!(
+ observations
+ .iter()
+ .map(|observation| observation.child_index)
+ .collect::<Vec<_>>(),
+ vec![0, 1, 2]
+ );
+ assert_eq!(
+ observations
+ .iter()
+ .map(|observation| observation.status)
+ .collect::<Vec<_>>(),
+ vec![
+ NumericalSnapshotStatus::Observed,
+ NumericalSnapshotStatus::Incomplete,
+ NumericalSnapshotStatus::Unavailable
+ ]
+ );
+ assert_eq!(observations[0].snapshot.as_ref().unwrap().profiles.len(), 1);
+ assert!(!pool.execution_authority_v1().load(Ordering::Acquire));
+ assert_eq!(pool.ready_child_count(), initial_ready);
+ first.lock().unwrap()["profiles"][0]["model_contract_sha256"] = serde_json::Value::Null;
+ let missing_contract = pool.numerical_process_inventory().await;
+ assert_eq!(
+ missing_contract[0].status,
+ NumericalSnapshotStatus::Incomplete
+ );
+ first.lock().unwrap()["profiles"][0]["model_contract_sha256"] =
+ serde_json::json!("d".repeat(64));
+ first.lock().unwrap()["profiles"][0]["model_id"] = serde_json::json!("é".repeat(513));
+ let oversized = pool.numerical_process_inventory().await;
+ assert_eq!(oversized[0].status, NumericalSnapshotStatus::Invalid);
+ assert!(oversized[0].snapshot.is_none());
+ first.lock().unwrap()["profiles"][0]["model_id"] = serde_json::json!("m");
+ let profile = first.lock().unwrap()["profiles"][0].clone();
+ first.lock().unwrap()["profiles"] = serde_json::json!([profile.clone(), profile.clone()]);
+ let duplicate_model = pool.numerical_process_inventory().await;
+ assert_eq!(duplicate_model[0].status, NumericalSnapshotStatus::Invalid);
+ assert!(duplicate_model[0].snapshot.is_none());
+ first.lock().unwrap()["profiles"] = serde_json::json!([profile]);
+ first.lock().unwrap()["runtime_instance_id"] = serde_json::json!("b".repeat(64));
+ let replaced = pool.numerical_process_inventory().await;
+ assert_eq!(
+ replaced[0]
+ .snapshot
+ .as_ref()
+ .unwrap()
+ .runtime_instance_id
+ .as_deref(),
+ Some("b".repeat(64).as_str())
+ );
+ *legacy.lock().unwrap() = first.lock().unwrap().clone();
+ let duplicated = pool.numerical_process_inventory().await;
+ assert_eq!(duplicated[0].status, NumericalSnapshotStatus::Invalid);
+ assert_eq!(duplicated[1].status, NumericalSnapshotStatus::Invalid);
+ first.lock().unwrap()["profiles"][0]["local_identity"] =
+ serde_json::json!("private-invalid-identity");
+ let invalid = pool.numerical_process_inventory().await;
+ assert_eq!(invalid[0].status, NumericalSnapshotStatus::Invalid);
+ assert!(invalid[0].snapshot.is_none());
+ assert!(!serde_json::to_string(&invalid)
+ .unwrap()
+ .contains("private-invalid"));
+ let unavailable = pool_with_paths(&[dir.path().join("none.sock")]);
+ let unavailable = unavailable.numerical_process_inventory().await;
+ assert_eq!(unavailable.len(), 1);
+ assert_eq!(unavailable[0].status, NumericalSnapshotStatus::Unavailable);
+ first_server.abort();
+ legacy_server.abort();
+ }
+
#[tokio::test]
async fn every_child_must_support_authority_and_old_replacement_cannot_downgrade() {
let dir = tempfile::Builder::new()
diff --git a/packages/sie_server_sidecar/src/ipc_client.rs b/packages/sie_server_sidecar/src/ipc_client.rs
index de4151482..3f67a0d80 100644
--- a/packages/sie_server_sidecar/src/ipc_client.rs
+++ b/packages/sie_server_sidecar/src/ipc_client.rs
@@ -45,14 +45,15 @@ use tracing::{debug, info, warn};
use crate::ipc_mux::{mux_enabled, MuxClient, MuxError};
use crate::ipc_types::{
ApplyModelConfigRequest, ApplyModelConfigResponse, BatchOutcome, DrainRequest, DrainResponse,
- EnsureModelReadyRequest, EnsureModelReadyResponse, GenerateEvent, PingRequest, PingResponse,
+ EnsureModelReadyRequest, EnsureModelReadyResponse, GenerateEvent,
+ NumericalProfileSnapshotRequest, NumericalProfileSnapshotResponse, PingRequest, PingResponse,
ProcessEncodeBatchRequest, ProcessExtractBatchRequest, ProcessGenerateRequest,
ProcessScoreBatchRequest, ReplaceModelConfigsRequest, ReplaceModelConfigsResponse,
RequestEnvelope, ResponseEnvelope, RunBatchRequest, SetPinnedModelsRequest,
SetPinnedModelsResponse, SignalGenerateCancelRequest, SignalGenerateCancelResponse,
WorkerCapabilitiesRequest, WorkerCapabilitiesResponse, IPC_VERSION, METHOD_APPLY_MODEL_CONFIG,
- METHOD_DRAIN, METHOD_ENSURE_MODEL_READY, METHOD_PING, METHOD_PROCESS_ENCODE_BATCH,
- METHOD_PROCESS_EXTRACT_BATCH, METHOD_PROCESS_GENERATE,
+ METHOD_DRAIN, METHOD_ENSURE_MODEL_READY, METHOD_NUMERICAL_PROFILE_SNAPSHOT, METHOD_PING,
+ METHOD_PROCESS_ENCODE_BATCH, METHOD_PROCESS_EXTRACT_BATCH, METHOD_PROCESS_GENERATE,
METHOD_PROCESS_GENERATE_WITH_EXECUTION_AUTHORITY_V1, METHOD_PROCESS_SCORE_BATCH,
METHOD_REPLACE_MODEL_CONFIGS, METHOD_RUN_BATCH, METHOD_RUN_BATCH_WITH_EXECUTION_AUTHORITY_V1,
METHOD_SET_PINNED_MODELS, METHOD_SIGNAL_GENERATE_CANCEL, METHOD_WORKER_CAPABILITIES,
@@ -1038,6 +1039,16 @@ impl IpcClient {
.await
}
+ pub async fn numerical_profile_snapshot(
+ &self,
+ ) -> Result<NumericalProfileSnapshotResponse, IpcError> {
+ self.call(
+ METHOD_NUMERICAL_PROFILE_SNAPSHOT,
+ NumericalProfileSnapshotRequest {},
+ )
+ .await
+ }
+
pub async fn signal_generate_cancel(
&self,
request_id: impl Into<String>,
diff --git a/packages/sie_server_sidecar/src/protocol/ipc_types.rs b/packages/sie_server_sidecar/src/protocol/ipc_types.rs
index 918d027d3..5e15f4bf0 100644
--- a/packages/sie_server_sidecar/src/protocol/ipc_types.rs
+++ b/packages/sie_server_sidecar/src/protocol/ipc_types.rs
@@ -34,6 +34,7 @@ pub const METHOD_PROCESS_SCORE_BATCH: &str = "ProcessScoreBatch";
pub const METHOD_PROCESS_EXTRACT_BATCH: &str = "ProcessExtractBatch";
pub const METHOD_PROCESS_GENERATE: &str = "ProcessGenerate";
pub const METHOD_WORKER_CAPABILITIES: &str = "WorkerCapabilities";
+pub const METHOD_NUMERICAL_PROFILE_SNAPSHOT: &str = "NumericalProfileSnapshot";
pub const METHOD_SIGNAL_GENERATE_CANCEL: &str = "SignalGenerateCancel";
/// RPC that accepts a whole pre-formed batch (mixed op kinds illegal —
/// one `RunBatchRequest` is a single op) and returns today's
@@ -435,6 +436,30 @@ pub struct WorkerCapabilitiesRequest {
// No fields: the method asks the backend to describe its local registry.
}
+#[derive(Debug, Clone, Default, Serialize, Deserialize)]
+pub struct NumericalProfileSnapshotRequest {
+ // No caller-supplied process or profile identity.
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct NumericalProfileObservation {
+ pub model_id: String,
+ #[serde(default)]
+ pub local_identity: Option<String>,
+ #[serde(default)]
+ pub model_contract_sha256: Option<String>,
+}
+
+#[derive(Debug, Clone, Default, Serialize, Deserialize)]
+pub struct NumericalProfileSnapshotResponse {
+ #[serde(default)]
+ pub runtime_instance_id: Option<String>,
+ #[serde(default)]
+ pub profiles: Vec<NumericalProfileObservation>,
+ #[serde(default)]
+ pub complete: bool,
+}
+
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct WorkerCapabilitiesResponse {
#[serde(default)]