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(remote): measure the local serving envelope in the equivalence probe (#588)
Krisztian Gajdar43157baa32af
diff --git a/packages/sie_server/MIGRATING_TO_SELF_HOSTED.md b/packages/sie_server/MIGRATING_TO_SELF_HOSTED.mdindex 026b29861..adddb188c 100644--- a/packages/sie_server/MIGRATING_TO_SELF_HOSTED.md+++ b/packages/sie_server/MIGRATING_TO_SELF_HOSTED.md@@ -33,8 +33,8 @@ Use the same weights revision and the intended pooling, normalization,truncation and instruction behavior. Load it on a separate test deploymentbefore changing the serving deployment's default profile.-Compare two local runs to measure their noise, then compare the remote-baseline against them. Check short and long inputs, the truncation boundary+Compare repeated local runs, including runs inside larger batches, to measure+their noise, then compare the remote baseline against them. Check short and long inputs, the truncation boundaryand instruction prefixes. For reranking, compare score scale as well asordering. For extraction, compare schemas and extracted results. A sharedmodel name or matching vector dimension alone does not prove equivalence.diff --git a/packages/sie_server/REMOTE_BACKENDS.md b/packages/sie_server/REMOTE_BACKENDS.mdindex 6aa4ffbc6..7e54a0343 100644--- a/packages/sie_server/REMOTE_BACKENDS.md+++ b/packages/sie_server/REMOTE_BACKENDS.md@@ -301,8 +301,10 @@ mise exec -- uv run --frozen --project . python tools/remote_equivalence.py \The API key argument names an environment variable; omit it for a server thatdoes not require authentication. The output path must be new. Each case makes-two local calls with remote serving forbidden, followed by one explicit remote-call. Cases cover short and long inputs, both sides of the pinned tokenizer's+four local calls with remote serving forbidden, followed by one explicit remote+call. Two local calls send the case alone, one sends it beside a longer item and+one sends it inside a batch of sixteen items, because the batch a worker forms+changes its numerical output. Cases cover short and long inputs, both sides of the pinned tokenizer'struncation boundary including the local instruction prefix, query and documentinstruction prefixes, default query instructions, empty prefixes, and score scalewhen scoring is declared. All declared encode/score outputs must be measured.@@ -316,8 +318,11 @@ adds, omits or changes an option is refused by the probe and by admission, andeach measured profile receives its own options. Older records must be remeasured.A pass requires matching layouts and finite values whose maximum absolute-error against both local runs does not exceed the difference measured between-those local runs. Identical local runs require identical remote values. Matching+error against every local observation does not exceed the local serving+envelope: the largest difference measured between any two local observations.+Identical local observations require identical remote values. There is no+tolerance setting. Each case records the batch composition of every local+observation; records that list none measured two single-request runs. Matchingboundary input refusals are recorded; a suite of refusals cannot establishnumerical equivalence. Endpoint/model contracts and local identity must remainunchanged throughout the probe. Every local and remote observation, including@@ -452,8 +457,8 @@ fallback.Servers with different hardware, drivers, inference libraries or settingsreport different local identities, and each identity needs its own-measurement: two local runs and one explicit remote run on a server with that-identity. The bundle tool collects one version 3 record per identity into one+measurement: the local observations and one explicit remote run on a server+with that identity. The bundle tool collects one version 3 record per identity into oneevidence file, which an upstream's `record_files` entry can name in place of asingle record. It accepts repeated `--record` paths, writes a new `--output`file, and checks a `--max-age-s` window from 1 to 604800 seconds (default 3600):diff --git a/packages/sie_server/src/sie_server/config/equivalence.py b/packages/sie_server/src/sie_server/config/equivalence.pyindex a4063a121..4227fbc8b 100644--- a/packages/sie_server/src/sie_server/config/equivalence.py+++ b/packages/sie_server/src/sie_server/config/equivalence.py@@ -1,4 +1,4 @@-"""Bounded, versioned evidence from two local runs and one remote run.+"""Bounded, versioned evidence from several local observations and one remote run.Records are operator artifacts, never caller assertions. They contain hashesand measured errors, not request bodies, vectors or credentials. A record binds@@ -13,7 +13,7 @@ import hashlibimport jsonimport osimport stat-from collections.abc import Mapping+from collections.abc import Mapping, Sequencefrom datetime import UTC, datetime, timedeltafrom pathlib import Pathfrom typing import Any, Literal@@ -38,9 +38,12 @@ ProbeCategory = Literal[ProbeOperation = Literal["encode", "score"]ProbeOutput = Literal["dense", "sparse", "multivector", "score"]ProbeOutcome = Literal["ok", "invalid_input", "input_too_long", "shape_mismatch"]+ProbeComposition = Literal["alone", "companion", "full"]_HASH_PATTERN = r"^[0-9a-f]{64}$"_MAX_VALUES = 100_000_000_MAX_TOKENS = 100_000+_MIN_LOCAL_OBSERVATIONS = 2+_MAX_LOCAL_OBSERVATIONS = 16_MAX_RECORD_BYTES = 512 << 10_MAX_EVIDENCE_BYTES = 8 << 20_CATEGORIES = frozenset(@@ -130,27 +133,38 @@ class ErrorMeasurement(BaseModel):return self.remote_error <= self.noise_floor-def measure_values(first: np.ndarray, second: np.ndarray, remote: np.ndarray) -> ErrorMeasurement:- """Compare absolute error to the actual two-run local noise floor.+def measure_values(local: Sequence[np.ndarray], remote: np.ndarray) -> ErrorMeasurement:+ """Compare absolute error to the measured local serving envelope.- There is no caller-selected tolerance. The remote run must be within the- measured floor of both local observations. Layout changes fail separately.+ The envelope is the largest difference between any two local observations+ of one input, across repeated runs and the batch compositions a worker+ forms. The remote output must lie within it of every local observation.+ There is no caller-selected tolerance. Layout changes fail separately."""- if first.shape != second.shape or first.shape != remote.shape or first.size == 0 or first.size > _MAX_VALUES:+ observations = (*local, remote)+ if (+ not _MIN_LOCAL_OBSERVATIONS <= len(local) <= _MAX_LOCAL_OBSERVATIONS+ or any(value.shape != remote.shape for value in local)+ or remote.size == 0+ or remote.size > _MAX_VALUES+ ):raise ValueError("probe output layout differs or exceeds the limit")if any(- value.dtype not in (np.dtype("float16"), np.dtype("float32"), np.dtype("float64"))- for value in (first, second, remote)+ value.dtype not in (np.dtype("float16"), np.dtype("float32"), np.dtype("float64")) for value in observations):raise ValueError("probe output must use a supported floating precision")- arrays = [np.asarray(value, dtype=np.float64) for value in (first, second, remote)]+ arrays = [np.asarray(value, dtype=np.float64) for value in observations]if any(not np.isfinite(value).all() for value in arrays):raise ValueError("probe output is not finite")- a, b, r = arrays+ *measured, observed = arrays+ high, low = measured[0].copy(), measured[0].copy()+ for value in measured[1:]:+ np.maximum(high, value, out=high)+ np.minimum(low, value, out=low)return ErrorMeasurement(- noise_floor=float(np.max(np.abs(a - b))),- remote_error=float(max(np.max(np.abs(a - r)), np.max(np.abs(b - r)))),- values=int(a.size),+ noise_floor=float(np.max(high - low)),+ remote_error=float(max(np.max(high - observed), np.max(observed - low))),+ values=int(observed.size),)@@ -161,22 +175,35 @@ class ProbeCase(BaseModel):category: ProbeCategoryinput_sha256: str = Field(pattern=_HASH_PATTERN)token_counts: tuple[int, ...] = Field(min_length=1, max_length=32)- outcomes: tuple[ProbeOutcome, ProbeOutcome, ProbeOutcome]+ # The local observations in order, then the remote observation.+ outcomes: tuple[ProbeOutcome, ...] = Field(+ min_length=_MIN_LOCAL_OBSERVATIONS + 1, max_length=_MAX_LOCAL_OBSERVATIONS + 1+ )+ # The batch composition of each local observation; absent in records that+ # measured repeated single-request runs only.+ local_compositions: tuple[ProbeComposition, ...] | None = Nonemeasurements: dict[ProbeOutput, ErrorMeasurement] = Field(max_length=4)@model_validator(mode="after")def coherent(self) -> ProbeCase:if any(value < 0 or value > _MAX_TOKENS for value in self.token_counts):raise ValueError("probe token count is out of range")- if self.outcomes == ("ok", "ok", "ok") and not self.measurements:+ local = _MIN_LOCAL_OBSERVATIONS if self.local_compositions is None else len(self.local_compositions)+ if local != len(self.outcomes) - 1:+ raise ValueError("every local observation needs one batch composition")+ if self.succeeded and not self.measurements:raise ValueError("successful runs require measured evidence")- if self.outcomes != ("ok", "ok", "ok") and self.measurements:+ if not self.succeeded and self.measurements:raise ValueError("refused or incompatible outputs cannot report measured errors")return self+ @property+ def succeeded(self) -> bool:+ return all(outcome == "ok" for outcome in self.outcomes)+@propertydef passed(self) -> bool:- if self.outcomes == ("ok", "ok", "ok"):+ if self.succeeded:return all(value.passed for value in self.measurements.values())return len(set(self.outcomes)) == 1 and self.outcomes[0] in ("invalid_input", "input_too_long")@@ -220,7 +247,7 @@ class EquivalenceRecord(BaseModel):raise ValueError("probe suite must cover lengths, truncation and both instruction prefixes")expected = {output for output in self.outputs if (output == "score") == (operation == "score")}for case in selected:- if case.outcomes == ("ok", "ok", "ok") and set(case.measurements) != expected:+ if case.succeeded and set(case.measurements) != expected:raise ValueError("every successful probe must measure every declared output")if case.category == "boundary_before" and max(case.token_counts) > self.context_length:raise ValueError("before-boundary probe must fit the context")@@ -232,7 +259,7 @@ class EquivalenceRecord(BaseModel):def passed(self) -> bool:# A set of matching refusals does not establish numerical equivalence.return all(case.passed for case in self.cases) and all(- case.outcomes == ("ok", "ok", "ok")+ case.succeededfor case in self.casesif case.category in ("short", "long", "score_scale", "query_default", "empty_prefix"))diff --git a/packages/sie_server/tests/config/test_equivalence.py b/packages/sie_server/tests/config/test_equivalence.pyindex 95187dfbd..141be6518 100644--- a/packages/sie_server/tests/config/test_equivalence.py+++ b/packages/sie_server/tests/config/test_equivalence.py@@ -114,28 +114,51 @@ def record(*, outputs: frozenset[str] = frozenset({"dense"})) -> EquivalenceRecodef test_noise_floor_is_measured_and_remote_must_match_both_local_runs() -> None:- result = measure_values(np.array([1.0, 2.0]), np.array([1.25, 2.0]), np.array([1.125, 2.0]))+ result = measure_values([np.array([1.0, 2.0]), np.array([1.25, 2.0])], np.array([1.125, 2.0]))assert result.noise_floor == 0.25assert result.remote_error == 0.125assert result.passed- assert not measure_values(np.array([1.0]), np.array([1.25]), np.array([1.5])).passed+ assert not measure_values([np.array([1.0]), np.array([1.25])], np.array([1.5])).passeddef test_deterministic_local_runs_require_identical_remote_values() -> None:- assert measure_values(np.array([1.0]), np.array([1.0]), np.array([1.0])).passed- assert not measure_values(np.array([1.0]), np.array([1.0]), np.array([1.000001])).passed+ assert measure_values([np.array([1.0]), np.array([1.0])], np.array([1.0])).passed+ assert not measure_values([np.array([1.0]), np.array([1.0])], np.array([1.000001])).passed+++def test_the_envelope_spans_every_local_observation() -> None:+ local = [np.array([1.0, 2.0]), np.array([1.0, 2.0]), np.array([1.25, 2.0]), np.array([1.0, 1.75])]+ result = measure_values(local, np.array([1.125, 1.875]))+ assert (result.noise_floor, result.remote_error) == (0.25, 0.125)+ assert result.passed+ assert measure_values(local, np.array([1.25, 1.75])).passed+ outside = measure_values(local, np.array([1.3, 2.0]))+ assert (outside.noise_floor, outside.remote_error) == (0.25, 0.30000000000000004)+ assert not outside.passed+ assert not measure_values(local, np.array([1.0, 1.7])).passed+ near_first_only = measure_values([np.array([1.0]), np.array([1.25])], np.array([0.9375]))+ assert near_first_only.remote_error == 0.3125+ assert not near_first_only.passed++[email protected]("count", [1, 17])+def test_the_envelope_needs_a_bounded_number_of_local_observations(count: int) -> None:+ with pytest.raises(ValueError, match="probe output layout"):+ measure_values([np.array([1.0])] * count, np.array([1.0]))@pytest.mark.parametrize("remote", [np.array([np.nan]), np.array([np.inf]), np.array([1 + 1j]), np.array(["1"])])def test_invalid_output_cannot_be_measured(remote: np.ndarray) -> None:with pytest.raises(ValueError, match="probe output"):- measure_values(np.array([1.0]), np.array([1.0]), remote)+ measure_values([np.array([1.0]), np.array([1.0])], remote)def test_output_shape_changes_and_empty_values_are_refused() -> None:for remote in (np.array([[1.0]]), np.array([])):with pytest.raises(ValueError, match="probe output layout"):- measure_values(np.array([1.0]), np.array([1.0]), remote)+ measure_values([np.array([1.0]), np.array([1.0])], remote)+ with pytest.raises(ValueError, match="probe output layout"):+ measure_values([np.array([1.0]), np.array([1.0, 2.0])], np.array([1.0]))@pytest.mark.parametrize("value", [-1.0, float("inf"), float("nan")])@@ -208,20 +231,68 @@ def test_rejected_or_malformed_outputs_cannot_claim_measurements() -> None:)+def _case(outcomes: tuple[str, ...], compositions: tuple[str, ...] | None) -> ProbeCase:+ return ProbeCase.model_validate_json(+ json.dumps(+ {+ "operation": "encode",+ "category": "short",+ "input_sha256": "a" * 64,+ "token_counts": [5],+ "outcomes": list(outcomes),+ "local_compositions": None if compositions is None else list(compositions),+ "measurements": {"dense": {"noise_floor": 0.0, "remote_error": 0.0, "values": 384}}+ if all(outcome == "ok" for outcome in outcomes)+ else {},+ }+ )+ )+++def test_a_case_names_the_batch_composition_of_each_local_observation() -> None:+ compositions = ("alone", "alone", "companion", "full")+ assert _case(("ok",) * 5, compositions).passed+ assert _case(("ok",) * 3, None).passed+ assert _case(("input_too_long",) * 5, compositions).passed+ assert not _case(("ok", "ok", "ok", "ok", "input_too_long"), compositions).passed+ for outcomes, labels in [+ (("ok",) * 5, ("alone", "alone")),+ (("ok",) * 5, None),+ (("ok",) * 2, None),+ (("ok",) * 18, None),+ ]:+ with pytest.raises(ValidationError):+ _case(outcomes, labels)+ with pytest.raises(ValidationError):+ _case(("ok",) * 3, ("alone", "batched"))++class _Tokenizer:def encode(self, text: str, *, add_special_tokens: bool) -> list[int]:return [1] * (len(text.split()) + (2 if add_special_tokens else 0))+def test_a_full_batch_holds_sixteen_items_whatever_the_case() -> None:+ suite = probe._cases(_Tokenizer(), 32)+ assert any(len(case.texts) > 1 for case in suite)+ long_text = next(case.texts[0] for case in suite if case.category == "long")+ for case in suite:+ assert len(case.texts) + len(probe._companions(suite, case, "full")) == 16, case.category+ assert probe._companions(suite, case, "companion") == (long_text,)+ assert probe._companions(suite, case, "alone") == ()++@pytest.mark.parametrize(- ("remote_offset", "contract_mismatch", "instance_mismatch", "remote_execution"),+ ("remote_offset", "contract_mismatch", "instance_mismatch", "remote_execution", "batch_offset"),[- (0.0, False, None, "8" * 64),- (0.01, False, None, "8" * 64),- (0.0, True, None, "8" * 64),- (0.0, False, "local", "8" * 64),- (0.0, False, "remote", "8" * 64),- (0.0, False, None, None),+ (0.0, False, None, "8" * 64, 0.0),+ (0.01, False, None, "8" * 64, 0.0),+ (0.0, True, None, "8" * 64, 0.0),+ (0.0, False, "local", "8" * 64, 0.0),+ (0.0, False, "remote", "8" * 64, 0.0),+ (0.0, False, None, None, 0.0),+ (0.0625, False, None, "8" * 64, 0.125),+ (0.25, False, None, "8" * 64, 0.125),],)def test_full_cli_runs_real_sdk_transport_and_only_writes_evidence(@@ -231,6 +302,7 @@ def test_full_cli_runs_real_sdk_transport_and_only_writes_evidence(contract_mismatch: bool,instance_mismatch: str | None,remote_execution: str | None,+ batch_offset: float,) -> None:requests: list[tuple[dict[str, Any], bool]] = []remote_contract: str | None = None@@ -259,7 +331,8 @@ def test_full_cli_runs_real_sdk_transport_and_only_writes_evidence(body = unpackb(self.rfile.read(int(self.headers["Content-Length"])), numeric_arrays=False)forbid = self.headers.get("X-SIE-Remote") == "forbid"requests.append((body, forbid))- offset = 0.0 if forbid else remote_offset+ # A local worker's output shifts with the batch it forms.+ offset = (batch_offset if len(body["items"]) > 1 else 0.0) if forbid else remote_offsetrows = [{"id": item["id"], "dense": {"dims": 2, "values": np.asarray([1.0 + offset, 2.0], dtype=np.float32)}}for item in body["items"]@@ -349,21 +422,25 @@ profiles:returnif instance_mismatch:assert result == 2- assert len(requests) == (3 if instance_mismatch == "remote" else 1)+ assert len(requests) == (5 if instance_mismatch == "remote" else 1)assert not output.exists()return- assert result == (0 if remote_offset == 0 else 1)+ assert result == (0 if remote_offset <= batch_offset else 1)evidence = EquivalenceRecord.model_validate_json(output.read_bytes())- assert evidence.passed == (remote_offset == 0)+ assert evidence.passed == (remote_offset <= batch_offset)+ short = next(case for case in evidence.cases if case.category == "short")+ assert short.measurements["dense"].noise_floor == pytest.approx(batch_offset)assert evidence.version == 3assert evidence.remote_execution_sha256 == remote_executionassert "local_instance_id" not in evidence.model_dump()assert evidence.runtime_options_sha256 == canonical_digest({"normalize": True})assert all(body["params"]["options"]["normalize"] is True for body, _ in requests)assert all(body["params"]["output_dtype"] == "float32" for body, _ in requests)- assert len(requests) == 24- assert [forbid for _, forbid in requests] == [True, True, False] * 8- assert [body["params"]["options"]["profile"] for body, _ in requests] == ["default", "default", "remote"] * 8+ assert len(requests) == 40+ assert [forbid for _, forbid in requests] == [True, True, True, True, False] * 8+ assert [body["params"]["options"]["profile"] for body, _ in requests] == (["default"] * 4 + ["remote"]) * 8+ assert [len(body["items"]) for body, _ in requests] == [1, 1, 2, 16, 1] * 8+ assert all(case.local_compositions == ("alone", "alone", "companion", "full") for case in evidence.cases)serialized = output.read_text()assert "retrieval " not in serializedassert "Represent this text" not in serialized@@ -432,7 +509,7 @@ def test_sparse_layout_and_score_order_are_compared_by_identity() -> None:"sparse",dimension=4,)- assert not measure_values(*sparse).passed+ assert not measure_values(sparse[:-1], sparse[-1]).passedscores = probe._values([{"scores": [{"item_id": "b", "score": 0.2}, {"item_id": "a", "score": 0.1}]},@@ -441,7 +518,7 @@ def test_sparse_layout_and_score_order_are_compared_by_identity() -> None:],"score",)- assert measure_values(*scores).passed+ assert measure_values(scores[:-1], scores[-1]).passed@pytest.mark.parametrize("index", [-1, 1.5, True, "not-an-index", 4])@@ -459,7 +536,7 @@ def test_consistently_wrong_dimensions_are_not_equivalence() -> None:def test_integer_conversion_cannot_hide_numerical_differences() -> None:with pytest.raises(ValueError, match="floating precision"):- measure_values(np.array([2**53]), np.array([2**53]), np.array([2**53 + 1]))+ measure_values([np.array([2**53]), np.array([2**53])], np.array([2**53 + 1]))@pytest.mark.parametrize("shape", [(1, 1), (0, 4), (33, 4), (4,)])@@ -874,8 +951,8 @@ def test_cluster_probe_attributes_observations_to_one_identity_from_cluster_statassert evidence.remote_execution_sha256 == _REMOTE_EXECUTIONassert evidence.remote_contract_sha256 == remote_contractassert evidence.local_observation_sha256 == canonical_digest({"identity": _IDENTITY_L4, "revision": "a" * 40})- assert events == ["wake", "wake", "status", *["probe"] * 24, "status"]- assert [headers.get("x-sie-remote") for _, headers in requests] == ["forbid", None] + ["forbid", "forbid", None] * 8+ assert events == ["wake", "wake", "status", *["probe"] * 40, "status"]+ assert [headers.get("x-sie-remote") for _, headers in requests] == ["forbid", None] + (["forbid"] * 4 + [None]) * 8assert all("x-sie-machine-profile" not in headers for _, headers in requests)assert all(body["params"]["options"]["profile"] in ("default", "remote") for body, _ in requests)@@ -905,7 +982,7 @@ def test_cluster_probe_refuses_a_fleet_that_changes_during_the_run(after[0]["numerical_process_inventory"]["children"][0]["snapshot"]["runtime_instance_id"] = "d" * 64result, _, output = _run_cluster_probe(tmp_path, monkeypatch, [before, after], [])assert result == 2- assert events == ["wake", "wake", "status", *["probe"] * 24, "status"]+ assert events == ["wake", "wake", "status", *["probe"] * 40, "status"]assert not output.exists()diff --git a/tools/remote_equivalence.py b/tools/remote_equivalence.pyindex ef0f32f0a..043b558c9 100755--- a/tools/remote_equivalence.py+++ b/tools/remote_equivalence.py@@ -1,5 +1,9 @@#!/usr/bin/env python3-"""Measure a configured remote profile against two local SIE runs.+"""Measure a configured remote profile against the local serving envelope.++Each case is observed locally several times, alone and inside the batch+compositions a worker forms, and once remotely. The remote output must stay+within the largest difference between the local observations.Run from the locked public workspace. Credential arguments name environmentvariables; no credential, request body or vector is written to the evidence.@@ -54,6 +58,9 @@ _MATRIX_NDIM = 2_PREFIX = "Represent this text for retrieval:"_SCORE_QUERY = "relevant documents for search"_IDENTITY = re.compile(r"v[12]:sha256:[0-9a-f]{64}")+# Repeated runs alone, beside a longer item and inside a full request batch.+_LOCAL_COMPOSITIONS = ("alone", "alone", "companion", "full")+_FULL_BATCH_ITEMS = 16@dataclass(frozen=True)@@ -332,6 +339,16 @@ def _cluster_provenance(return _Provenance(identity, cast("str", config.hf_revision), cast("str", remote_execution), None, processes)+def _companions(suite: list[_Case], case: _Case, composition: str) -> tuple[str, ...]:+ """Items sent beside a case's own inputs to vary the batch a worker forms."""+ short, long_text = (next(other.texts[0] for other in suite if other.category == name) for name in ("short", "long"))+ if composition == "companion":+ return (long_text,)+ if composition == "full":+ return tuple(long_text if index % 2 else short for index in range(_FULL_BATCH_ITEMS - len(case.texts)))+ return ()++def _request(client: SIEClient,config: ModelConfig,@@ -343,6 +360,7 @@ def _request(upstream: str,local_instance: str | None,machine_profile: str | None = None,+ companions: tuple[str, ...] = (),) -> tuple[str, Any]:common: dict[str, Any] = {"options": {**config.resolve_profile(profile).runtime, "profile": profile},@@ -355,6 +373,7 @@ def _request(common["gpu"] = machine_profiletry:items: list[Item] = [{"id": f"probe-{index}", "text": text} for index, text in enumerate(case.texts)]+ items += [{"id": f"probe-companion-{index}", "text": text} for index, text in enumerate(companions)]if operation == "score":result = client.score(config.sie_id, {"text": _SCORE_QUERY}, items, **common)if {value["item_id"] for value in result["scores"]} != {value["id"] for value in items} or len(@@ -381,7 +400,11 @@ def _request(raise ValueError("probe serving provenance is missing or differs")if local_instance is not None and evidence.get("runtime_instance_id") != local_instance:raise ValueError("probe serving runtime instance differs")- return "ok", result+ targets = len(case.texts)+ if operation == "score":+ own = {f"probe-{index}" for index in range(targets)}+ return "ok", {**result, "scores": [value for value in result["scores"] if value["item_id"] in own]}+ return "ok", rows[:targets]except RequestError as error:if local_instance is not None and (error.request or {}).get("runtime_instance_id") != local_instance:raise ValueError("probe refusal runtime instance differs") from None@@ -436,9 +459,8 @@ def run_probe(selected_outputs = {output for output in outputs if (output == "score") == (operation == "score")}if not selected_outputs:continue- for case in _cases(- tokenizer, config.max_sequence_length, default_instruction=default_runtime.get("instruction")- ):+ suite = _cases(tokenizer, config.max_sequence_length, default_instruction=default_runtime.get("instruction"))+ for case in suite:if operation == "encode" and case.category == "score_scale":continueobservations = [@@ -452,27 +474,30 @@ def run_probe(upstream=upstream_name,local_instance=before.local_instance,machine_profile=machine_profile,+ companions=_companions(suite, case, composition),+ )+ for client, selected, composition in (+ *((local, "default", composition) for composition in _LOCAL_COMPOSITIONS),+ (remote, profile, "alone"),)- for client, selected in ((local, "default"), (local, "default"), (remote, profile))]outcomes = tuple(observation[0] for observation in observations)measurements = {}- if outcomes == ("ok", "ok", "ok"):+ if all(outcome == "ok" for outcome in outcomes):results = [observation[1] for observation in observations]try:- measurements = {- output: measure_values(- *_values(- results,- output,- dimension=getattr(getattr(config.tasks.encode, output, None), "dim", None),- context_length=config.max_sequence_length,- )+ measurements = {}+ for output in sorted(selected_outputs):+ *measured, observed = _values(+ results,+ output,+ dimension=getattr(getattr(config.tasks.encode, output, None), "dim", None),+ context_length=config.max_sequence_length,)- for output in sorted(selected_outputs)- }+ measurements[output] = measure_values(measured, observed)except (KeyError, TypeError, ValueError):- outcomes = ("shape_mismatch",) * 3+ measurements = {}+ outcomes = ("shape_mismatch",) * len(observations)cases.append(ProbeCase(operation=cast("Any", operation),@@ -487,6 +512,7 @@ def run_probe(),token_counts=case.token_counts,outcomes=cast("Any", outcomes),+ local_compositions=cast("Any", _LOCAL_COMPOSITIONS),measurements=cast("Any", measurements),))