Skip to content

armgit / sie

Public Imported from GitHub
0

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

fix(remote): keep instructions and unadmitted plans off numerical bridges (#600)

Krisztian Gajdarab016b13b441
diff --git a/packages/sie_gateway/docs/architecture-guide.md b/packages/sie_gateway/docs/architecture-guide.md
index 3e50fa331..728ce7326 100644
--- a/packages/sie_gateway/docs/architecture-guide.md
+++ b/packages/sie_gateway/docs/architecture-guide.md
@@ -970,14 +970,15 @@ gateway refuse a body-level `options.profile` selector, check the request
against the admission and replay the body remotely. The bridge decision is made
when the gateway is about to commit to the remote attempt:
-- The request sets no runtime option other than `is_query`, and every output it
- asks for (`dense` when an encode names none, `score` for score) is listed in
- the admission. Otherwise the remote process would refuse it, so the request
+- The request sets no instruction and no runtime option other than
+ `is_query`, and every output it asks for (`dense` when an encode names none,
+ `score` for score) is listed in the admission. Otherwise the remote process would refuse it, so the request
stays local:
- A request for an output that the model declares but the admission does not
list stays local with the reason `unmeasured_request`.
- - A request with another runtime option, or one that asks for an output the
- model does not declare, is not a bridge candidate on a fallback route. The
+ - A request with an instruction or another runtime option, or one that asks
+ for an output the model does not declare, is not a bridge candidate on a
+ fallback route. The
trigger leaves it on its ordinary local path instead of committing to the
local refusal, and no decision is recorded. On a `threshold` route it stays
local with the reason `unmeasured_request`.
@@ -1067,9 +1068,12 @@ lane. It is `false` by default and is a non-publishing hint.
1. The gateway wakes the lane through `publish_model_load` with the lane's
pool target, recording pending demand as for any cold lane.
2. It waits up to 2 s for the transport to accept the wake.
- 3. It makes the single remote attempt with `fallback_reason: provisioning`.
- - A wake that is not accepted leaves the caller with the local
- `503 PROVISIONING`.
+ 3. It admits the bridge again, and makes the single remote attempt with
+ `fallback_reason: provisioning`.
+ - A wake that is not accepted, or a bridge that is no longer admitted after
+ the wake, leaves the caller with the local `503 PROVISIONING`. A
+ `model_loading` bridge admits its plan again after its load-only wake in the
+ same way.
- **No bridge.** A request that is not bridged dispatches as before.
- **A remote attempt refused as `PROVISIONING`** received no answer. It
restores the local refusal with `X-SIE-Fallback-Error: QUEUE_FULL`.
diff --git a/packages/sie_gateway/src/handlers/proxy.rs b/packages/sie_gateway/src/handlers/proxy.rs
index 42d5dca07..10612ed36 100644
--- a/packages/sie_gateway/src/handlers/proxy.rs
+++ b/packages/sie_gateway/src/handlers/proxy.rs
@@ -2509,23 +2509,24 @@ fn admit_numerical(
Some(plan)
}
-/// The outputs a numerical request asks for, when it sets no runtime option
-/// that a numerical admission could not have measured and asks only for
-/// outputs the model declares. The remote process refuses any option except
-/// `is_query` that differs from the measured defaults, so a request with
-/// another option stays local. A request for an undeclared output is invalid
-/// on either side.
+/// The outputs a numerical request asks for, when it sets no instruction and
+/// no runtime option that a numerical admission could not have measured, and
+/// asks only for outputs the model declares. The remote process refuses an
+/// instruction and any option except `is_query` that differs from the
+/// measured defaults, so such a request stays local. A request for an
+/// undeclared output is invalid on either side.
fn numerical_request_outputs(
operation: &str,
parsed: Option<&(Vec<rmpv::Value>, publisher::WorkParams)>,
declared: &[String],
) -> Option<Vec<String>> {
let (_, params) = parsed?;
- let measured = match params.options.as_ref() {
- None | Some(Value::Null) => true,
- Some(Value::Object(options)) => options.keys().all(|key| key == "is_query"),
- Some(_) => false,
- };
+ let measured = params.instruction.is_none()
+ && match params.options.as_ref() {
+ None | Some(Value::Null) => true,
+ Some(Value::Object(options)) => options.keys().all(|key| key == "is_query"),
+ Some(_) => false,
+ };
if !measured {
return None;
}
@@ -3324,7 +3325,7 @@ async fn proxy_request_inner(
} else {
None
};
- if let Some(plan) = provisioning_bridge {
+ if provisioning_bridge.is_some() {
let refusal = build_provisioning_response_for_surface(&gpu, &bundle, provisioning_surface);
let target = lane_wake_target(
effective_pool,
@@ -3344,6 +3345,17 @@ async fn proxy_request_inner(
{
return refusal;
}
+ let Some(plan) = native_bridge_plan(
+ &state,
+ &req,
+ endpoint,
+ &model_name,
+ prepared_native_parsed.as_ref(),
+ body_held,
+ FallbackTrigger::Provisioning,
+ ) else {
+ return refusal;
+ };
begin_planned_native_fallback(&mut req, plan, refusal, FallbackTrigger::Provisioning);
if let Some(body) = prepared_native_body {
*req.body_mut() = Body::from(body);
@@ -3390,7 +3402,7 @@ async fn proxy_request_inner(
)
.await
{
- if native_fallback_plan(
+ if let Some(plan) = native_bridge_plan(
&state,
&req,
endpoint,
@@ -3398,36 +3410,21 @@ async fn proxy_request_inner(
prepared_native_parsed.as_ref(),
body_held,
trigger,
- )
- .is_some()
- {
+ ) {
state.demand_tracker.record(&physical_lane);
let refusal = local_spill_refusal(endpoint, trigger);
- match begin_native_fallback(
- &state,
- &mut req,
- endpoint,
- &model_name,
- prepared_native_parsed.as_ref(),
- body_held,
- refusal,
- trigger,
- ) {
- Err(refusal) => return refusal,
- Ok(()) => {
- if let Some(body) = prepared_native_body {
- *req.body_mut() = Body::from(body);
- }
- return Box::pin(proxy_request_inner(
- state,
- req,
- endpoint,
- provisioning_surface,
- inbound_publish_cx,
- ))
- .await;
- }
+ begin_planned_native_fallback(&mut req, plan, refusal, trigger);
+ if let Some(body) = prepared_native_body {
+ *req.body_mut() = Body::from(body);
}
+ return Box::pin(proxy_request_inner(
+ state,
+ req,
+ endpoint,
+ provisioning_surface,
+ inbound_publish_cx,
+ ))
+ .await;
}
}
}
@@ -3472,43 +3469,58 @@ async fn proxy_request_inner(
)
.await
{
- let refusal = model_loading_refusal(endpoint);
- if !warm_local_model(
+ if native_bridge_plan(
&state,
- work_publisher.as_ref(),
- &physical_lane,
- target,
- &engine,
- &bundle_config_hash,
- )
- .await
- {
- return refusal;
- }
- match begin_native_fallback(
- &state,
- &mut req,
+ &req,
endpoint,
&model_name,
prepared_native_parsed.as_ref(),
body_held,
- refusal,
FallbackTrigger::ModelLoading,
- ) {
- Err(refusal) => return refusal,
- Ok(()) => {
- if let Some(body) = prepared_native_body {
- *req.body_mut() = Body::from(body);
- }
- return Box::pin(proxy_request_inner(
- state,
- req,
- endpoint,
- provisioning_surface,
- inbound_publish_cx,
- ))
- .await;
+ )
+ .is_some()
+ {
+ let refusal = model_loading_refusal(endpoint);
+ if !warm_local_model(
+ &state,
+ work_publisher.as_ref(),
+ &physical_lane,
+ target,
+ &engine,
+ &bundle_config_hash,
+ )
+ .await
+ {
+ return refusal;
}
+ let Some(plan) = native_bridge_plan(
+ &state,
+ &req,
+ endpoint,
+ &model_name,
+ prepared_native_parsed.as_ref(),
+ body_held,
+ FallbackTrigger::ModelLoading,
+ ) else {
+ return refusal;
+ };
+ begin_planned_native_fallback(
+ &mut req,
+ plan,
+ refusal,
+ FallbackTrigger::ModelLoading,
+ );
+ if let Some(body) = prepared_native_body {
+ *req.body_mut() = Body::from(body);
+ }
+ return Box::pin(proxy_request_inner(
+ state,
+ req,
+ endpoint,
+ provisioning_surface,
+ inbound_publish_cx,
+ ))
+ .await;
}
}
}
@@ -21656,8 +21668,11 @@ mod tests {
json!({"output_dtype": "float32"}),
json!({"options": {"normalize": true}}),
json!({"options": {"max_seq_length": 16}}),
+ json!({"instruction": "Represent this sentence:"}),
+ json!({"instruction": ""}),
] {
assert_eq!(outputs("encode", params.clone()), None, "{params}");
+ assert_eq!(outputs("score", params.clone()), None, "{params}");
}
assert_eq!(numerical_request_outputs("encode", None, &declared), None);
assert_eq!(outputs("extract", json!({})), None);
diff --git a/packages/sie_gateway/src/handlers/serving_disclosure.rs b/packages/sie_gateway/src/handlers/serving_disclosure.rs
index c8ae6fbb5..534864216 100644
--- a/packages/sie_gateway/src/handlers/serving_disclosure.rs
+++ b/packages/sie_gateway/src/handlers/serving_disclosure.rs
@@ -3519,7 +3519,19 @@ mod tests {
_ => unreachable!(),
}
let response = encode(&gateway, body).await;
- assert!(!response.status().is_success(), "{case}");
+ let local_worker = matches!(
+ case,
+ "uncovered local identity" | "local worker without inventory"
+ );
+ assert_eq!(response.status().is_success(), local_worker, "{case}");
+ assert!(
+ gateway
+ .dispatcher
+ .dispatched()
+ .iter()
+ .all(|work| work.endpoint != "load"),
+ "{case}"
+ );
assert_numerical_work_stayed_local(&gateway, &response, case);
}
}
@@ -3643,6 +3655,7 @@ mod tests {
for params in [
json!({"output_dtype": "int8"}),
json!({"output_types": ["sparse"]}),
+ json!({"instruction": "Represent this sentence:"}),
] {
let gateway = numerical_gateway(NUMERICAL_FALLBACK, false).await;
gateway
@@ -3690,6 +3703,101 @@ mod tests {
}
}
+ /// A numerical model whose local worker reports `identity`, on a gateway
+ /// whose remote worker admits only `ADMITTED_IDENTITY`.
+ async fn numerical_gateway_with_local(
+ routing: &str,
+ loaded: &[&str],
+ identity: &str,
+ ) -> TestGateway {
+ let gateway = numerical_gateway(routing, false).await;
+ gateway
+ .add_numerical_worker(
+ "local-1",
+ LOCAL_LANE,
+ loaded,
+ true,
+ local_identity(identity),
+ )
+ .await;
+ gateway
+ }
+
+ #[tokio::test]
+ async fn a_cold_model_without_a_current_admission_waits_for_its_local_load() {
+ for (identity, bridged) in [(UNADMITTED_IDENTITY, false), (ADMITTED_IDENTITY, true)] {
+ let gateway = numerical_gateway_with_local(NUMERICAL_FALLBACK, &[], identity).await;
+ let response = encode(&gateway, json!({"items":[{"text":"hello"}]})).await;
+ let dispatched = gateway.dispatcher.dispatched();
+ if bridged {
+ assert_eq!(response.headers()["x-sie-fallback-reason"], "model_loading");
+ assert!(dispatched.iter().any(|work| work.endpoint == "load"));
+ assert!(dispatched.iter().any(|work| work.bundle == REMOTE_LANE.2));
+ } else {
+ assert_eq!(response.status(), StatusCode::OK);
+ assert!(!response.headers().contains_key("x-sie-fallback-reason"));
+ assert!(dispatched.iter().all(|work| work.endpoint != "load"));
+ assert!(dispatched.iter().all(|work| work.bundle != REMOTE_LANE.2));
+ assert!(dispatched.iter().any(|work| work.bundle == LOCAL_LANE.2));
+ }
+ }
+ }
+
+ #[tokio::test]
+ async fn a_saturated_model_without_a_current_admission_keeps_its_local_queue() {
+ let routing =
+ "\nrouting:\n policy: fallback\n fallback_profile: remote\n triggers: [saturated]\n";
+ for (identity, bridged) in [(UNADMITTED_IDENTITY, false), (ADMITTED_IDENTITY, true)] {
+ let gateway =
+ numerical_gateway_with_local(routing, &["acme/hybrid-encode"], identity).await;
+ gateway.dispatcher.saturate_local_queue();
+ let response = encode(&gateway, json!({"items":[{"text":"hello"}]})).await;
+ let dispatched = gateway.dispatcher.dispatched();
+ if bridged {
+ assert_eq!(response.headers()["x-sie-fallback-reason"], "saturated");
+ assert!(dispatched.iter().any(|work| work.bundle == REMOTE_LANE.2));
+ } else {
+ assert_eq!(response.status(), StatusCode::OK);
+ assert!(!response.headers().contains_key("x-sie-fallback-reason"));
+ assert!(dispatched.iter().all(|work| work.bundle != REMOTE_LANE.2));
+ assert!(dispatched.iter().any(|work| work.bundle == LOCAL_LANE.2));
+ }
+ }
+ }
+
+ #[tokio::test]
+ async fn an_admission_withdrawn_during_the_wake_keeps_the_local_refusal() {
+ for (gate, loaded) in [
+ ("model_loading", &[][..]),
+ ("provisioning", &["acme/hybrid-encode"][..]),
+ ] {
+ let gateway =
+ numerical_gateway_with_local(NUMERICAL_FALLBACK, loaded, ADMITTED_IDENTITY).await;
+ if gate == "provisioning" {
+ gateway.dispatcher.report_cold_local_lane();
+ }
+ let registry = Arc::clone(&gateway.state.registry);
+ gateway
+ .dispatcher
+ .on_model_load(Box::new(move || registry.health_subscription_started()));
+ let response = encode(&gateway, json!({"items":[{"text":"hello"}]})).await;
+ let dispatched = gateway.dispatcher.dispatched();
+ assert_eq!(response.status(), StatusCode::SERVICE_UNAVAILABLE, "{gate}");
+ assert!(
+ !response.headers().contains_key("x-sie-fallback-reason"),
+ "{gate}"
+ );
+ assert!(
+ dispatched.iter().any(|work| work.endpoint == "load"),
+ "{gate}"
+ );
+ assert!(
+ dispatched.iter().all(|work| work.bundle != REMOTE_LANE.2),
+ "{gate}"
+ );
+ }
+ }
+
#[tokio::test]
async fn an_admitted_numerical_bridge_accepts_a_query_flag() {
let gateway = numerical_gateway(NUMERICAL_FALLBACK, false).await;
diff --git a/packages/sie_gateway/src/handlers/test_support.rs b/packages/sie_gateway/src/handlers/test_support.rs
index 2503f0298..246d08984 100644
--- a/packages/sie_gateway/src/handlers/test_support.rs
+++ b/packages/sie_gateway/src/handlers/test_support.rs
@@ -176,9 +176,15 @@ pub(crate) struct RecordingDispatcher {
execution_authority: Mutex<Vec<bool>>,
fallback_reasons: Mutex<Vec<Option<FallbackTrigger>>>,
numerical_admissions: Mutex<Vec<Option<String>>>,
+ on_model_load: Mutex<Option<Box<dyn FnOnce() + Send>>>,
}
impl RecordingDispatcher {
+ /// Run `action` once, when the next load-only item is published.
+ pub(crate) fn on_model_load(&self, action: Box<dyn FnOnce() + Send>) {
+ *self.on_model_load.lock().unwrap() = Some(action);
+ }
+
/// Answer remote-lane work as a remote worker does when its upstream cannot
/// serve now: a published `code` error with the upstream's wait, if any.
pub(crate) fn refuse_remote_work(&self, code: &'static str, retry_after_s: Option<u32>) {
@@ -426,6 +432,9 @@ impl WorkDispatcher for RecordingDispatcher {
assert!(matches!(target, PublishTarget::VerifiedWorker { .. }));
}
self.record(Dispatched::new("load", &target));
+ if let Some(action) = self.on_model_load.lock().unwrap().take() {
+ action();
+ }
if self.load_refused.load(Ordering::SeqCst) {
return Err(DispatchError::Other("load was not durably accepted".into()));
}
diff --git a/packages/sie_server/REMOTE_BACKENDS.md b/packages/sie_server/REMOTE_BACKENDS.md
index 6f2325a14..6c6352faa 100644
--- a/packages/sie_server/REMOTE_BACKENDS.md
+++ b/packages/sie_server/REMOTE_BACKENDS.md
@@ -442,7 +442,8 @@ unidentified engines remain closed.
Every bridge rechecks the record and its age before loading or calling the remote
profile. Expired, missing, failed or mismatched evidence preserves the original
local refusal and retry hint while starting local warm-up. Valid local requests
-with unmeasured runtime overrides or non-float32 output also remain local;
+that set an instruction, unmeasured runtime overrides or non-float32 output also
+remain local;
explicit profiles still serve as requested. Rejection of one exported model
retains its current local configuration without blocking unrelated updates.
@@ -502,7 +503,8 @@ contract and serving-code digests. Admitted remote attempts travel on a worker
subject of their own that only a sidecar with the admission check consumes.
Before such a process sends an admitted remote attempt upstream, it derives its
admission again and refuses the item unless the item names the current digest,
-requests only admitted outputs and keeps the measured runtime options. A bridged
+requests only admitted outputs, sets no instruction and keeps the measured
+runtime options. A bridged
caller then receives its local refusal with
`X-SIE-Fallback-Error: INFERENCE_ERROR`. The check covers batches that start
after a change: a batch that has already passed it completes its upstream calls,
@@ -522,10 +524,10 @@ publishes load-only work or makes a decision, so an invalid request gets its
`400` and nothing else. It decides when it is about to commit to the remote
attempt:
-- The request must set no runtime option other than `is_query`, and every
- output it asks for must be listed in the admission. Any other option, such as
- `output_dtype`, keeps the request local, because the remote process would
- refuse it.
+- The request must set no instruction and no runtime option other than
+ `is_query`, and every output it asks for must be listed in the admission. An
+ instruction or any other option, such as `output_dtype`, keeps the request
+ local, because the remote process would refuse it.
- A remote-lane worker qualifies when it is fresh, eligible and positively
supports both execution authority and the numerical admission method,
consumes the admission subject, carries the remote profile's exact
@@ -559,13 +561,12 @@ Upgrade workers and gateways before applying a hybrid `encode` or `score`
configuration. A remote lane rolled back below the numerical admission subject
stops numerical bridging: its older sidecar never consumes admitted work, so
queued attempts time out instead of running unchecked, and a fenced sidecar
-that later consumes them drops those past their deadline. Configuring a numerical
-bridge also changes local behavior while no admission holds: a trigger that
-would bridge a request commits to its local refusal, so a cold model answers
-`MODEL_LOADING` instead of waiting for its load, and an opted-in `saturated` or
-`unhealthy` trigger refuses instead of queueing. A request that could never
-bridge, because it sets a runtime option other than `is_query` or asks for an
-output the model does not declare, keeps its ordinary local path.
+that later consumes them drops those past their deadline. While no admission
+holds, a trigger leaves the request on its ordinary local path, as without a
+bridge: a cold model's request waits for its load, and a saturated or unhealthy
+lane answers as it would without a bridge. So does a request that could never
+bridge, because it sets an instruction or a runtime option other than
+`is_query`, or asks for an output the model does not declare.
## Single-node generation fallback
diff --git a/packages/sie_server/src/sie_server/api/encode.py b/packages/sie_server/src/sie_server/api/encode.py
index 32380a0a2..5005175b9 100644
--- a/packages/sie_server/src/sie_server/api/encode.py
+++ b/packages/sie_server/src/sie_server/api/encode.py
@@ -327,6 +327,7 @@ async def encode(
profile=profile_name,
queued_items=len(request.items),
request_options={**(request_options or {}), "output_dtype": output_dtype},
+ instruction=params.instruction if params else None,
)
# Check if LoRA is specified and ensure it's loaded
diff --git a/packages/sie_server/src/sie_server/api/routing.py b/packages/sie_server/src/sie_server/api/routing.py
index b8261fcbf..69fdbdc17 100644
--- a/packages/sie_server/src/sie_server/api/routing.py
+++ b/packages/sie_server/src/sie_server/api/routing.py
@@ -160,6 +160,7 @@ async def route_request(
profile: object = None,
queued_items: int | None = None,
request_options: Mapping[str, object] | None = None,
+ instruction: str | None = None,
) -> ServingRoute:
"""Choose the registry entry that serves a request for ``model``, and make it ready to serve.
@@ -205,7 +206,9 @@ async def route_request(
trigger = _TRIGGER_BY_REFUSAL.get(error_code(refusal) or "")
if trigger is None or trigger not in triggers:
raise
- return await _bridge(request, registry, model, key, routing, trigger, refusal, span, request_options)
+ return await _bridge(
+ request, registry, model, key, routing, trigger, refusal, span, request_options, instruction
+ )
return ServingRoute(key=key)
@@ -265,6 +268,7 @@ async def _bridge(
refusal: HTTPException,
span: Span,
request_options: Mapping[str, object] | None = None,
+ instruction: str | None = None,
) -> ServingRoute:
await registry.start_load_async(key, registry.device)
remote_key = f"{model}:{routing.fallback_profile}"
@@ -280,7 +284,7 @@ async def _bridge(
config = registry.get_config(model)
if config.tasks.encode is not None or config.tasks.score is not None:
try:
- if hybrid_request_refusal(config, request_options) is not None:
+ if hybrid_request_refusal(config, request_options, instruction=instruction) is not None:
raise ValueError("hybrid request differs from its measured contract")
reason = await asyncio.to_thread(
numerical_evidence_refusal,
diff --git a/packages/sie_server/src/sie_server/api/score.py b/packages/sie_server/src/sie_server/api/score.py
index d5d9692f8..d372d9abb 100644
--- a/packages/sie_server/src/sie_server/api/score.py
+++ b/packages/sie_server/src/sie_server/api/score.py
@@ -253,6 +253,7 @@ async def score(
profile=request.options.get("profile") if request.options else None,
queued_items=len(items),
request_options=request.options,
+ instruction=request.instruction,
)
# Score using worker with batching
diff --git a/packages/sie_server/src/sie_server/config/hybrid_admission.py b/packages/sie_server/src/sie_server/config/hybrid_admission.py
index 4d6355dd0..99497d174 100644
--- a/packages/sie_server/src/sie_server/config/hybrid_admission.py
+++ b/packages/sie_server/src/sie_server/config/hybrid_admission.py
@@ -236,8 +236,12 @@ def openai_equivalence_refusal(
return None
-def hybrid_request_refusal(config: ModelConfig, request_options: Mapping[str, object] | None) -> str | None:
- """Keep valid local numerical overrides off a bridge measured at defaults."""
+def hybrid_request_refusal(
+ config: ModelConfig, request_options: Mapping[str, object] | None, *, instruction: str | None = None
+) -> str | None:
+ """Keep valid local numerical overrides and request instructions off a bridge measured at defaults."""
+ if instruction is not None:
+ return "hybrid request sets an instruction"
defaults = {"output_dtype": DEFAULT_OUTPUT_DTYPE, **config.resolve_profile("default").runtime}
try:
differs = any(
@@ -259,10 +263,11 @@ def bridged_item_refusal(
token: str | None,
outputs: Collection[str],
request_options: Mapping[str, object] | None,
+ instruction: str | None = None,
) -> str | None:
"""Refuse a bridged item unless it names the current admission and stays within it."""
if token != admission.sha256:
return "bridged item names a different numerical admission"
if not outputs or not set(outputs) <= admission.outputs:
return "bridged item requests outputs outside its numerical admission"
- return hybrid_request_refusal(config, request_options)
+ return hybrid_request_refusal(config, request_options, instruction=instruction)
diff --git a/packages/sie_server/src/sie_server/ipc_server.py b/packages/sie_server/src/sie_server/ipc_server.py
index fee65cb58..dcad88f87 100644
--- a/packages/sie_server/src/sie_server/ipc_server.py
+++ b/packages/sie_server/src/sie_server/ipc_server.py
@@ -871,6 +871,7 @@ class IpcServer:
token=item.encode.numerical_admission_sha256,
outputs=item.encode.output_types if item.encode.output_types is not None else ["dense"],
request_options=item.encode.options,
+ instruction=item.encode.instruction,
)
if item.op == "score" and item.score is not None:
return bridged_item_refusal(
@@ -879,6 +880,7 @@ class IpcServer:
token=item.score.numerical_admission_sha256,
outputs=["score"],
request_options=item.score.options,
+ instruction=item.score.instruction,
)
return "operation has no numerical admission"
diff --git a/packages/sie_server/tests/config/test_hybrid_admission.py b/packages/sie_server/tests/config/test_hybrid_admission.py
index 35052c984..d785d2e32 100644
--- a/packages/sie_server/tests/config/test_hybrid_admission.py
+++ b/packages/sie_server/tests/config/test_hybrid_admission.py
@@ -274,8 +274,10 @@ def test_validator_without_a_runtime_cannot_admit_operator_proof(admission: tupl
validate_model_routing(config)
[email protected]("expired", [False, True])
-async def test_prebridge_rechecks_freshness_while_preserving_local_warmup(admission: tuple, expired: bool) -> None:
[email protected](("expired", "instruction"), [(False, None), (True, None), (False, "Represent this sentence:")])
+async def test_prebridge_rechecks_freshness_while_preserving_local_warmup(
+ admission: tuple, expired: bool, instruction: str | None
+) -> None:
config, _, path, data = admission
_refresh_record(path, data)
if expired:
@@ -300,9 +302,9 @@ async def test_prebridge_rechecks_freshness_while_preserving_local_warmup(admiss
"app": SimpleNamespace(state=SimpleNamespace(registry=registry)),
}
)
- if expired:
+ if expired or instruction is not None:
with pytest.raises(HTTPException) as refused:
- await route_request(request, config.sie_id, trace.INVALID_SPAN)
+ await route_request(request, config.sie_id, trace.INVALID_SPAN, instruction=instruction)
assert refused.value.status_code == 503
assert refused.value.detail["code"] == "MODEL_LOADING"
assert refused.value.headers == {
@@ -340,6 +342,13 @@ def test_unmeasured_runtime_overrides_cannot_bridge(admission: tuple, options: d
assert hybrid_admission.hybrid_request_refusal(config, {"is_query": True}) is None
[email protected]("instruction", ["Represent this sentence:", ""])
+def test_a_request_instruction_cannot_bridge(admission: tuple, instruction: str) -> None:
+ config, _, _, _ = admission
+ assert hybrid_admission.hybrid_request_refusal(config, None, instruction=instruction) is not None
+ assert hybrid_admission.hybrid_request_refusal(config, {"is_query": True}, instruction=None) is None
+
+
@pytest.mark.parametrize(
("local", "remote", "admitted"),
[
@@ -833,6 +842,8 @@ def _expire(path: Path, data: dict[str, Any]) -> None:
(":remote", {}, "expire"),
(":remote", {}, "remove"),
(":remote", {}, "replace"),
+ (":remote", {"instruction": "Represent this sentence:"}, None),
+ (":remote", {"instruction": ""}, None),
],
)
async def test_fence_refuses_before_the_upstream_when_the_admission_does_not_cover_the_item(
diff --git a/telemetry/README.md b/telemetry/README.md
index 13d48409b..33756edc3 100644
--- a/telemetry/README.md
+++ b/telemetry/README.md
@@ -737,14 +737,14 @@ model, `admitted` or `refused`, and the reason: `none`, `no_admission` (no
eligible remote worker advertises a current admission), `local_unobserved` (a
live local worker reports no complete process inventory) or
`uncovered_identity` (a live local process reports an identity or model
-contract outside the admission) or `unmeasured_request` (the request sets a
-runtime option other than `is_query`, or asks for an output, that the admission
-did not measure). A local worker past the heartbeat timeout, and every worker
+contract outside the admission) or `unmeasured_request` (the request sets an
+instruction or a runtime option other than `is_query`, or asks for an output
+that the admission did not measure). A local worker past the heartbeat timeout, and every worker
until the gateway has heard worker health for one heartbeat timeout, counts as
`local_unobserved`. A request counts once, with the decision that applied. On a
-fallback route, a request that sets another runtime option or asks for an
-output the model does not declare is not a bridge candidate, so it records no
-decision. On a `threshold` route the same request records
+fallback route, a request that sets an instruction or another runtime option,
+or asks for an output the model does not declare, is not a bridge candidate, so
+it records no decision. On a `threshold` route the same request records
`unmeasured_request`. It
keeps its own 256-model bound with the same `other` overflow, and the
queue-routing dashboard displays it.