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(examples): retain server timing headers in Earnings21 evidence (#690)

svonava1689b17362f8
diff --git a/examples/speech-to-text/earnings21/README.md b/examples/speech-to-text/earnings21/README.md
index 222c41aab..11f01b885 100644
--- a/examples/speech-to-text/earnings21/README.md
+++ b/examples/speech-to-text/earnings21/README.md
@@ -105,6 +105,13 @@ Successful text survives in a partly failed call, with separate error and
completeness metadata. Exit 0 means all pieces succeeded, 1 means retained
incomplete/failed results, and 2 means a caller/setup failure.
+When provided by the server, response evidence also retains `X-Queue-Time`,
+`X-Tokenization-Time`, `X-Inference-Time`, `X-Postprocessing-Time` and
+`X-Total-Time`, in milliseconds. These help separate queueing, preparation and
+handler inference within a request. Handler inference can include processor,
+model generation and decoding work; interpreting hardware performance requires
+the serving implementation and profile. Missing timing headers remain absent.
+
The frozen primary comparator is P2, `gpt-transcribe` on the same piece bytes;
whole-call P1 is secondary. If a separately obtained P2 call JSONL is available,
run the unchanged scorer explicitly:
diff --git a/examples/speech-to-text/earnings21/tests/test_caller.py b/examples/speech-to-text/earnings21/tests/test_caller.py
index 57b0a9e0c..0dbed44e4 100644
--- a/examples/speech-to-text/earnings21/tests/test_caller.py
+++ b/examples/speech-to-text/earnings21/tests/test_caller.py
@@ -341,6 +341,30 @@ class Controls(unittest.TestCase):
self.assertFalse(halt.is_set())
self.assertEqual(json.loads((folder / "sdk-result.json").read_bytes())["data"]["text"], "fixture text")
+ def test_server_stage_timings_survive_saved_response_evidence(self):
+ timings = {
+ "X-Queue-Time": "12.25",
+ "X-Tokenization-Time": "3.50",
+ "X-Inference-Time": "8.00",
+ "X-Postprocessing-Time": "0.75",
+ "X-Total-Time": "25.00",
+ }
+ response = terminal_response()
+ response.headers.update(timings)
+ response.headers.update(
+ {"Set-Cookie": "private-cookie", "Authorization": "private-token", "X-Internal-Debug": "private-detail"}
+ )
+ row, folder, halt = self.worker(lambda _: response)
+ self.assertEqual(row["status"], "ok")
+ self.assertEqual(row["physical_posts"], 1)
+ self.assertFalse(halt.is_set())
+ for name in ("wire-000-headers.json", "wire-000.json"):
+ headers = json.loads((folder / name).read_bytes())["headers"]
+ for key, value in timings.items():
+ self.assertEqual(headers[key.lower()], value)
+ for key in ("set-cookie", "authorization", "x-internal-debug"):
+ self.assertNotIn(key, headers)
+
def test_absent_api_key_does_not_read_ambient_sdk_key(self):
self.settings["api_key"] = ""
with patch.dict(os.environ, {"SIE_API_KEY": "unintended-ambient-key"}):
diff --git a/examples/speech-to-text/earnings21/transport.py b/examples/speech-to-text/earnings21/transport.py
index 02d9ac09b..77dc5682c 100644
--- a/examples/speech-to-text/earnings21/transport.py
+++ b/examples/speech-to-text/earnings21/transport.py
@@ -29,6 +29,11 @@ SAFE_HEADERS = {
"x-sie-units-input-tokens",
"x-sie-units-output-tokens",
"x-sie-units-audio-ms",
+ "x-queue-time",
+ "x-tokenization-time",
+ "x-inference-time",
+ "x-postprocessing-time",
+ "x-total-time",
}