diff --git a/docs/build-validation.md b/docs/build-validation.md index bfad8f4c..49897b5c 100644 --- a/docs/build-validation.md +++ b/docs/build-validation.md @@ -228,3 +228,4 @@ The test toolchain was installed into ignored `artifacts/tool-venv/` for this ru - `scripts/bench-chat-paired.py` and a public three-case synthetic suite now record per-case quality and paired wall time when two endpoints exist. The current server initially returned HTTP 400 while its `/health` reported `loaded: true` with `max_context: 0`; the harness now optionally waits for nonzero context before sending requests. After the model became ready, 15/15 timed baseline responses passed arithmetic, retrieval, and function-call checks (five repetitions each). Median HTTP wall time was 0.0959 s overall, 0.0959 s arithmetic, 0.0670 s retrieval, and 0.1613 s function call. The private response report and hardware/config metadata are on the remote NTFS experiment volume. Archive transfer and conversion were concurrently active, and no compressed endpoint exists, so this is a functional warm control arm, not a paired A/B speed result. The standard server was unloaded through its API after the run; VRAM use returned to 34 MiB. - `scripts/check-kar-cuda-records.py` compared Rust CPU and CUDA reconstruction checksums for all 22 records in the private level-3 precision overlay. The checksum matched for **22/22** real records: full output for records up to one million values and row 0 for larger records. Thirty warm CUDA iterations per record gave isolated median decode times from 0.002496 to 0.003200 ms; recorded compressed residency ranged from 53,792 to 13,762,592 bytes. Transfer/setup time, matrix multiplication, and model-level quality are outside this measurement. The independent paired full-record L2 report for those same 22 records has median relative L2 0.50735 at base level 2 and 0.22608 at overlay level 3; this improvement is numerical, not a passed model-quality gate. The model-free temporary GPU fixture was removed after validation. - A local release CLI independently verified the complete 55,295,529,472-byte v4 archive and decoded row 0 of `per_layer_token_embd.weight#strata-part-001-of-002` at level 2. Its 160 F32 values have FNV-1a `c6f74b955ce5a5ae`. This is the CPU oracle for a later GPU check after the remote v4 transfer finishes and its SHA-256 is verified. The temporary local Cargo build directory was removed after this run. +- The local CI entry point now checks Python syntax for both new offline measurement scripts and runs a mock HTTP A/B test. That test delays readiness until `max_context` becomes nonzero, requires bearer authentication, checks three case results per arm and paired output equality, and confirms the private report has mode 0600 without the token. It passed locally with Python 3; hosted GitHub Actions still cannot run until a repository is created. diff --git a/scripts/check-local.sh b/scripts/check-local.sh index ad61afd1..3dbe1b33 100755 --- a/scripts/check-local.sh +++ b/scripts/check-local.sh @@ -3,6 +3,9 @@ set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +python3 -m py_compile "${repo_root}/scripts/bench-chat-paired.py" "${repo_root}/scripts/check-kar-cuda-records.py" +python3 "${repo_root}/scripts/test-benchmark-harness.py" + cargo fmt --manifest-path "${repo_root}/control-plane/Cargo.toml" --check cargo clippy --manifest-path "${repo_root}/control-plane/Cargo.toml" --locked --all-targets -- -D warnings cargo test --manifest-path "${repo_root}/control-plane/Cargo.toml" --locked diff --git a/scripts/test-benchmark-harness.py b/scripts/test-benchmark-harness.py new file mode 100644 index 00000000..6a488d97 --- /dev/null +++ b/scripts/test-benchmark-harness.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python3 +"""Exercise paired benchmark ordering, readiness, quality and secret handling.""" + +import http.server +import json +import pathlib +import stat +import subprocess +import tempfile +import threading + + +TOKEN = "fixture-token-do-not-log" +HEALTH_CHECKS = 0 + + +class Handler(http.server.BaseHTTPRequestHandler): + def do_GET(self): + global HEALTH_CHECKS + HEALTH_CHECKS += 1 + self.reply({"loaded": True, "max_context": 0 if HEALTH_CHECKS == 1 else 262144}) + + def do_POST(self): + if self.headers.get("Authorization") != "Bearer " + TOKEN: + self.send_error(401) + return + body = json.loads(self.rfile.read(int(self.headers["Content-Length"]))) + if "tools" in body: + message = {"role": "assistant", "content": None, + "tool_calls": [{"function": {"name": "get_weather", + "arguments": '{"city":"Paris"}'}}]} + finish = "tool_calls" + else: + question = body["messages"][0]["content"] + message = {"role": "assistant", "content": "323" if "17 * 19" in question else "Cora"} + finish = "stop" + self.reply({"choices": [{"message": message, "finish_reason": finish}], + "usage": {"prompt_tokens": 20, "completion_tokens": 2}}) + + def reply(self, payload): + data = json.dumps(payload).encode() + self.send_response(200) + self.send_header("Content-Type", "application/json") + self.send_header("Content-Length", str(len(data))) + self.end_headers() + self.wfile.write(data) + + def log_message(self, *_args): + pass + + +def main(): + root = pathlib.Path(__file__).resolve().parent.parent + server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Handler) + thread = threading.Thread(target=server.serve_forever, daemon=True) + thread.start() + try: + with tempfile.TemporaryDirectory() as directory: + private = pathlib.Path(directory) + config = private / "config.json" + config.write_text(json.dumps({"api_key": TOKEN})) + report = private / "report.json" + url = f"http://127.0.0.1:{server.server_port}" + subprocess.run([ + "python3", str(root / "scripts/bench-chat-paired.py"), + "--suite", str(root / "benchmarks/fixtures/chat/paired-smoke.json"), + "--baseline-url", url + "/chat", "--candidate-url", url + "/chat", + "--baseline-ready-url", url + "/health", + "--candidate-ready-url", url + "/health", + "--baseline-auth-config", str(config), + "--model", "mock", "--repeats", "1", "--output", str(report), + ], check=True, capture_output=True, text=True) + data = report.read_text() + assert TOKEN not in data + assert stat.S_IMODE(report.stat().st_mode) == 0o600 + summary = json.loads(data)["summary"] + assert summary["baseline"]["quality_passed"] == 3 + assert summary["candidate"]["quality_passed"] == 3 + assert summary["paired"]["pairs"] == 3 + assert summary["paired"]["same_normalized_output"] == 3 + assert HEALTH_CHECKS >= 3 + finally: + server.shutdown() + server.server_close() + print("paired benchmark harness: OK") + + +if __name__ == "__main__": + main()