Linux / keyless-cuda-gate (pull_request) Skipped
Linux / verify (pull_request) Successful in 4m32s
Linux / keyless-cuda (pull_request) Skipped
Linux / static-cuda-package (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-cli-container (pull_request) Successful in 1m38s
Linux / linux-static-cli (pull_request) Successful in 11m8s
Linux / release-cli (pull_request) Skipped
503 lines
24 KiB
Python
503 lines
24 KiB
Python
#!/usr/bin/env python3
|
|
"""Descriptively compare two private, sequential bench-chat-paired.py runs.
|
|
|
|
No performance/model-quality qualification follows from this offline report.
|
|
"""
|
|
|
|
import argparse
|
|
import datetime as dt
|
|
import json
|
|
import math
|
|
import os
|
|
from pathlib import Path
|
|
import statistics
|
|
import sys
|
|
|
|
MAX_INPUT_BYTES = 32 * 1024 * 1024
|
|
MAX_CASES = 64
|
|
MAX_PAIRS = 4096
|
|
MAX_REPEATS = 100
|
|
MAX_NUMBER = 1e12
|
|
COUNT_FIELDS = {"prompt_n", "predicted_n", "cache_n", "draft_n", "draft_accepted_n"}
|
|
USAGE_COUNTS = {"prompt_tokens", "completion_tokens", "total_tokens", "input_tokens",
|
|
"output_tokens", "cached_tokens", "reasoning_tokens",
|
|
"accepted_prediction_tokens", "rejected_prediction_tokens"}
|
|
# Canonical private metadata keys. Presence is an operator assertion, not proof.
|
|
PROVENANCE_FIELDS = (
|
|
"engine_commit", "control_plane_commit", "model_sha256", "quantization",
|
|
"gpu", "driver", "cuda_toolkit", "power_limit_watts", "context_tokens",
|
|
"kv_configuration", "slots", "batch_size", "speculation", "cache_state",
|
|
"workload_sha256", "quality_gate_result", "draft_acceptance_rate",
|
|
"expert_cache_hit_rate", "kv_streaming_hit_rate",
|
|
)
|
|
LIMITATION = (
|
|
"Descriptive only: sequential model loads and requests may drift with I/O, "
|
|
"cache state and load order; repeats may be correlated. Synthetic/CPU "
|
|
"results and supplied metadata do not qualify GPU inference, end-to-end "
|
|
"agent performance or model quality. Pooled cases/categories depend on "
|
|
"their case composition; uncertainty assumes independent pairs sharing "
|
|
"a common population median."
|
|
)
|
|
|
|
|
|
def reject(message):
|
|
# Fixed field names only; never include values from a private report.
|
|
raise ValueError(message)
|
|
|
|
|
|
def integer(value, minimum=0, maximum=int(MAX_NUMBER)):
|
|
return type(value) is int and minimum <= value <= maximum
|
|
|
|
|
|
def number(value, positive=False):
|
|
return (type(value) in (int, float) and math.isfinite(value)
|
|
and (value > 0 if positive else value >= 0) and value <= MAX_NUMBER)
|
|
|
|
|
|
def label(value):
|
|
return isinstance(value, str) and bool(value.strip()) and len(value) <= 128
|
|
|
|
|
|
def unique_object(items):
|
|
result = {}
|
|
for key, value in items:
|
|
if key in result:
|
|
reject("duplicate JSON field")
|
|
result[key] = value
|
|
return result
|
|
|
|
|
|
def finite_float(text):
|
|
value = float(text)
|
|
if not math.isfinite(value):
|
|
reject("nonfinite JSON number")
|
|
return value
|
|
|
|
|
|
def bounded_tree(report):
|
|
# Keep only one iterator per depth, not a second copy of a wide JSON array.
|
|
stack = [(iter((report,)), 0)]
|
|
nodes = 0
|
|
while stack:
|
|
iterator, depth = stack[-1]
|
|
try:
|
|
value = next(iterator)
|
|
except StopIteration:
|
|
stack.pop()
|
|
continue
|
|
nodes += 1
|
|
if depth > 32 or nodes > 1_000_000:
|
|
reject("report exceeds structure limit")
|
|
if isinstance(value, dict):
|
|
stack.append((iter(value.values()), depth + 1))
|
|
elif isinstance(value, list):
|
|
stack.append((iter(value), depth + 1))
|
|
elif type(value) is float and not math.isfinite(value):
|
|
reject("nonfinite JSON number")
|
|
|
|
|
|
def load_report(path):
|
|
with path.open("rb") as source:
|
|
raw = source.read(MAX_INPUT_BYTES + 1)
|
|
if len(raw) > MAX_INPUT_BYTES:
|
|
reject("report exceeds input byte limit")
|
|
try:
|
|
report = json.loads(raw, object_pairs_hook=unique_object, parse_float=finite_float,
|
|
parse_constant=lambda _: reject("nonfinite JSON number"))
|
|
except (UnicodeError, json.JSONDecodeError, RecursionError):
|
|
reject("invalid report JSON")
|
|
bounded_tree(report)
|
|
validate_report(report)
|
|
return report
|
|
|
|
|
|
def normalized(row):
|
|
try:
|
|
choices = row["response"]["choices"]
|
|
if not isinstance(choices, list) or len(choices) != 1:
|
|
return None
|
|
choice = choices[0]
|
|
message = choice["message"]
|
|
if message.get("role") != "assistant" or choice.get("finish_reason") not in ("stop", "tool_calls"):
|
|
return None
|
|
content = message.get("content")
|
|
if content is not None and not isinstance(content, str):
|
|
return None
|
|
calls = message.get("tool_calls")
|
|
if calls is None:
|
|
calls = []
|
|
if not isinstance(calls, list) or len(calls) > 128:
|
|
return None
|
|
if bool(calls) != (choice["finish_reason"] == "tool_calls"):
|
|
return None
|
|
tools, call_ids = [], set()
|
|
for call in calls:
|
|
call_id = call.get("id")
|
|
if not label(call_id) or call_id in call_ids:
|
|
return None
|
|
call_ids.add(call_id)
|
|
function = call["function"]
|
|
if call.get("type") != "function" or not label(function["name"]):
|
|
return None
|
|
if not isinstance(function["arguments"], str):
|
|
return None
|
|
arguments = json.loads(function["arguments"], object_pairs_hook=unique_object, parse_float=finite_float,
|
|
parse_constant=lambda _: reject("nonfinite tool JSON"))
|
|
if not isinstance(arguments, dict):
|
|
return None
|
|
bounded_tree(arguments)
|
|
tools.append({"name": function["name"], "arguments": arguments})
|
|
if content is None and not tools:
|
|
return None
|
|
return {"content": content, "tool_calls": tools}
|
|
except (KeyError, IndexError, TypeError, ValueError, AttributeError, RecursionError):
|
|
return None
|
|
|
|
|
|
def validate_usage(usage):
|
|
if usage is None:
|
|
return
|
|
if not isinstance(usage, dict):
|
|
reject("usage must be an object")
|
|
for key, value in usage.items():
|
|
if key in USAGE_COUNTS and not integer(value):
|
|
reject("usage token count must be a bounded nonnegative integer")
|
|
if key in ("prompt_tokens_details", "completion_tokens_details",
|
|
"input_tokens_details", "output_tokens_details"):
|
|
if not isinstance(value, dict):
|
|
reject("usage token details must be an object")
|
|
validate_usage(value)
|
|
if all(key in usage for key in ("prompt_tokens", "completion_tokens", "total_tokens")):
|
|
if usage["prompt_tokens"] + usage["completion_tokens"] != usage["total_tokens"]:
|
|
reject("usage total_tokens is inconsistent")
|
|
for prefix in ("prompt", "input"):
|
|
total = usage.get(prefix + "_tokens")
|
|
cached = usage.get(prefix + "_tokens_details", {}).get("cached_tokens")
|
|
if total is not None and cached is not None and cached > total:
|
|
reject("usage cached_tokens exceeds input tokens")
|
|
|
|
|
|
def validate_report(report):
|
|
if not isinstance(report, dict) or type(report.get("schema")) is not int or report["schema"] != 1:
|
|
reject("unsupported report schema")
|
|
digest = report.get("suite_sha256")
|
|
if (not isinstance(digest, str) or len(digest) != 64
|
|
or any(char not in "0123456789abcdefABCDEF" for char in digest)):
|
|
reject("suite_sha256 must be a SHA-256 digest")
|
|
if not label(report.get("model")):
|
|
reject("model must be a bounded nonempty string")
|
|
config = report.get("configuration")
|
|
if not isinstance(config, dict) or not integer(config.get("repeats"), 1, MAX_REPEATS):
|
|
reject("configuration.repeats is invalid")
|
|
for field in ("max_tokens", "seed"):
|
|
if field in config and not integer(config[field], 1 if field == "max_tokens" else 0):
|
|
reject("configuration integer is invalid")
|
|
if "temperature" in config and not number(config["temperature"]):
|
|
reject("configuration.temperature is invalid")
|
|
if "stream" in config and config["stream"] is not False:
|
|
reject("configuration.stream must be false")
|
|
for field in ("reasoning_effort", "cache_state"):
|
|
if field in config and (not isinstance(config[field], str) or not config[field].strip() or len(config[field]) > 1024):
|
|
reject("configuration text field is invalid")
|
|
if not isinstance(report.get("metadata", {}), dict):
|
|
reject("metadata must be an object")
|
|
rows = report.get("rows")
|
|
if not isinstance(rows, list) or not rows or len(rows) > MAX_PAIRS + MAX_CASES:
|
|
reject("rows exceed report limits or are empty")
|
|
cases, measured, warmups, arms = {}, set(), set(), set()
|
|
for row in rows:
|
|
if not isinstance(row, dict) or not label(row.get("case_id")) or not label(row.get("category")):
|
|
reject("row case_id/category is invalid")
|
|
if row.get("arm") not in ("baseline", "candidate"):
|
|
reject("row arm is invalid")
|
|
arms.add(row["arm"])
|
|
case = row["case_id"]
|
|
if case in cases and cases[case] != row["category"]:
|
|
reject("case category changes between rows")
|
|
cases[case] = row["category"]
|
|
if type(row.get("warmup")) is not bool:
|
|
reject("row warmup must be boolean")
|
|
if row["warmup"]:
|
|
if row.get("repeat") is not None or case in warmups:
|
|
reject("invalid or duplicate warmup")
|
|
warmups.add(case)
|
|
else:
|
|
repeat = row.get("repeat")
|
|
if not integer(repeat, 0, config["repeats"] - 1) or (case, repeat) in measured:
|
|
reject("invalid or duplicate measured repeat")
|
|
measured.add((case, repeat))
|
|
if not number(row.get("wall_seconds"), positive=True):
|
|
reject("wall_seconds must be finite and positive")
|
|
if not integer(row.get("http_status"), 100, 599):
|
|
reject("http_status is invalid")
|
|
quality = row.get("quality")
|
|
if not isinstance(quality, dict) or type(quality.get("passed")) is not bool:
|
|
reject("quality.passed must be boolean")
|
|
response = row.get("response")
|
|
if not isinstance(response, dict):
|
|
reject("response must be an object")
|
|
if quality["passed"] and (row["http_status"] != 200 or normalized(row) is None):
|
|
reject("quality.passed contradicts HTTP/terminal response")
|
|
validate_usage(response.get("usage"))
|
|
timing = response.get("timings")
|
|
if timing is not None:
|
|
if not isinstance(timing, dict):
|
|
reject("timings must be an object")
|
|
for key, value in timing.items():
|
|
if key in COUNT_FIELDS or key.endswith("_n"):
|
|
if not integer(value):
|
|
reject("timing token count must be a bounded nonnegative integer")
|
|
elif not number(value):
|
|
reject("optional timing must be finite and nonnegative")
|
|
if (len(arms) != 1 or len(cases) > MAX_CASES or len(measured) > MAX_PAIRS
|
|
or warmups != cases.keys()
|
|
or len(measured) != len(cases) * config["repeats"]):
|
|
reject("report must contain one arm and complete warmup/repeat coverage")
|
|
|
|
|
|
def selected(report):
|
|
return {(row["case_id"], row["repeat"]): row for row in report["rows"] if not row["warmup"]}
|
|
|
|
|
|
def percentile(values, fraction):
|
|
position = (len(values) - 1) * fraction
|
|
lower = int(position)
|
|
remainder = position - lower
|
|
return values[lower] * (1 - remainder) + values[min(lower + 1, len(values) - 1)] * remainder
|
|
|
|
|
|
def median_interval(values):
|
|
"""Exact distribution-free paired median order-statistic interval.
|
|
|
|
Pick the narrowest symmetric interval with >=95% binomial coverage.
|
|
Below six pairs no finite two-sided 95% interval exists; disclose null bounds.
|
|
"""
|
|
n = len(values)
|
|
total = 1 << n
|
|
weight, tail, chosen, chosen_tail = 1, 0, 0, 0
|
|
for k in range(1, n // 2 + 1):
|
|
tail += weight
|
|
if 40 * tail > total:
|
|
break
|
|
chosen, chosen_tail = k, tail
|
|
weight = weight * (n - k + 1) // k
|
|
return {
|
|
"method": "exact paired median order-statistic interval",
|
|
"confidence_level": 0.95,
|
|
"coverage_lower_bound": 1 - 2 * chosen_tail / total if chosen else None,
|
|
"lower": values[chosen - 1] if chosen else None,
|
|
"upper": values[n - chosen] if chosen else None,
|
|
"finite_interval_available": bool(chosen),
|
|
"assumption": "independent pairs with a common population median; ties are conservative",
|
|
}
|
|
|
|
|
|
def distribution(values, uncertainty=False):
|
|
values = sorted(values)
|
|
result = {"sample_count": len(values), "mean": statistics.fmean(values),
|
|
"median": statistics.median(values), "p10": percentile(values, 0.1),
|
|
"p90": percentile(values, 0.9), "small_sample": len(values) < 30}
|
|
if uncertainty:
|
|
result["median_confidence_interval"] = median_interval(values)
|
|
return result
|
|
|
|
|
|
def ratio(candidate, baseline):
|
|
result = candidate / baseline
|
|
if not math.isfinite(result) or result <= 0:
|
|
reject("paired ratio is not finite and positive")
|
|
return result
|
|
|
|
|
|
def throughput(pairs, field):
|
|
measured = [(pair["baseline_timings"].get(field), pair["candidate_timings"].get(field))
|
|
for pair in pairs]
|
|
valid = [(a, b) for a, b in measured if a is not None and b is not None and a > 0 and b > 0]
|
|
if not valid:
|
|
return None
|
|
ratios = [ratio(b, a) for a, b in valid]
|
|
return {
|
|
"pairs": len(valid), "unavailable_pairs": len(pairs) - len(valid),
|
|
"baseline_median_tokens_per_second": statistics.median(a for a, _ in valid),
|
|
"candidate_median_tokens_per_second": statistics.median(b for _, b in valid),
|
|
"candidate_over_baseline_median_ratio": statistics.median(ratios),
|
|
"baseline_distribution": distribution([a for a, _ in valid]),
|
|
"candidate_distribution": distribution([b for _, b in valid]),
|
|
"candidate_over_baseline_ratio_distribution": distribution(ratios, uncertainty=True),
|
|
}
|
|
|
|
|
|
def group_summary(pairs):
|
|
baseline_failed = sum(not pair["baseline_quality_passed"] for pair in pairs)
|
|
candidate_failed = sum(not pair["candidate_quality_passed"] for pair in pairs)
|
|
mismatched = sum(not pair["same_normalized_output"] for pair in pairs)
|
|
return {
|
|
"pairs": len(pairs),
|
|
"same_normalized_output": len(pairs) - mismatched,
|
|
"both_quality_passed": sum(pair["baseline_quality_passed"] and
|
|
pair["candidate_quality_passed"] for pair in pairs),
|
|
"candidate_over_baseline_wall_median_ratio": statistics.median(
|
|
pair["candidate_over_baseline_wall_ratio"] for pair in pairs),
|
|
"wall_seconds": {
|
|
"baseline": distribution([pair["baseline_wall_seconds"] for pair in pairs]),
|
|
"candidate": distribution([pair["candidate_wall_seconds"] for pair in pairs]),
|
|
},
|
|
"candidate_over_baseline_wall_ratio_distribution": distribution(
|
|
[pair["candidate_over_baseline_wall_ratio"] for pair in pairs], uncertainty=True),
|
|
"quality": {"baseline_failed": baseline_failed, "candidate_failed": candidate_failed,
|
|
"normalized_output_mismatches": mismatched,
|
|
"baseline_http_or_protocol_failed": sum(pair["baseline_protocol_failed"] for pair in pairs),
|
|
"candidate_http_or_protocol_failed": sum(pair["candidate_protocol_failed"] for pair in pairs),
|
|
"observed_checks_passed": not (baseline_failed or candidate_failed or mismatched)},
|
|
"timing_coverage": {
|
|
field: {"available_pairs": sum(pair["baseline_timings"].get(field, 0) > 0 and
|
|
pair["candidate_timings"].get(field, 0) > 0 for pair in pairs),
|
|
"total_pairs": len(pairs)}
|
|
for field in ("prompt_per_second", "predicted_per_second")
|
|
},
|
|
"prefill": throughput(pairs, "prompt_per_second"),
|
|
"decode": throughput(pairs, "predicted_per_second"),
|
|
}
|
|
|
|
|
|
def initial_requests(base, candidate):
|
|
b_rows = {row["case_id"]: row for row in base["rows"] if row["warmup"]}
|
|
c_rows = {row["case_id"]: row for row in candidate["rows"] if row["warmup"]}
|
|
if b_rows.keys() != c_rows.keys():
|
|
reject("initial requests differ between arms")
|
|
result = {}
|
|
for case in sorted(b_rows):
|
|
b, c = b_rows[case], c_rows[case]
|
|
if b["category"] != c["category"]:
|
|
reject("initial case category differs")
|
|
b_timing, c_timing = b["response"].get("timings") or {}, c["response"].get("timings") or {}
|
|
result[case] = {
|
|
"baseline_wall_seconds": b["wall_seconds"], "candidate_wall_seconds": c["wall_seconds"],
|
|
"baseline_quality_passed": b["quality"]["passed"], "candidate_quality_passed": c["quality"]["passed"],
|
|
"baseline_prompt_tokens_processed": b_timing.get("prompt_n"),
|
|
"candidate_prompt_tokens_processed": c_timing.get("prompt_n"),
|
|
"baseline_cached_prompt_tokens": b_timing.get("cache_n"),
|
|
"candidate_cached_prompt_tokens": c_timing.get("cache_n"),
|
|
"baseline_prompt_tokens_per_second": b_timing.get("prompt_per_second"),
|
|
"candidate_prompt_tokens_per_second": c_timing.get("prompt_per_second"),
|
|
}
|
|
return result
|
|
|
|
|
|
def provenance(report):
|
|
metadata = report.get("metadata", {})
|
|
missing = [field for field in PROVENANCE_FIELDS if metadata.get(field) in (None, "", [], {})]
|
|
measured = [row for row in report["rows"] if not row["warmup"]]
|
|
if not all(any((row["response"].get("timings") or {}).get(key, 0) > 0
|
|
for key in ("ttft_ms", "ttft_seconds")) for row in measured):
|
|
missing.append("ttft")
|
|
if not all(all(key in (row["response"].get("usage") or {})
|
|
for key in ("prompt_tokens", "completion_tokens")) for row in measured):
|
|
missing.append("prompt_output_token_counts")
|
|
return {"missing_fields": missing, "metadata_presence_is_not_verified_evidence": True}
|
|
|
|
|
|
def compare(base, candidate):
|
|
for field in ("schema", "suite_sha256", "model", "configuration"):
|
|
if base[field] != candidate[field]:
|
|
reject("reports differ in " + field)
|
|
# An intended code/codec change may differ between arms, but a declared
|
|
# different workload/hardware/cache setup cannot be pooled as matched pairs.
|
|
for field in ("gpu", "driver", "power_limit_watts", "model_sha256", "context_tokens",
|
|
"kv_configuration", "slots", "batch_size", "speculation", "cache_state", "workload_sha256"):
|
|
b_value, c_value = base.get("metadata", {}).get(field), candidate.get("metadata", {}).get(field)
|
|
if b_value not in (None, "", [], {}) and c_value not in (None, "", [], {}) and b_value != c_value:
|
|
reject("incompatible paired provenance field")
|
|
b_rows, c_rows = selected(base), selected(candidate)
|
|
if not b_rows or b_rows.keys() != c_rows.keys():
|
|
reject("reports do not contain the same measured cases")
|
|
pairs = []
|
|
for key in sorted(b_rows):
|
|
b, c = b_rows[key], c_rows[key]
|
|
if b["category"] != c["category"]:
|
|
reject("case category differs")
|
|
b_normal, c_normal = normalized(b), normalized(c)
|
|
pairs.append({
|
|
"case_id": key[0], "repeat": key[1], "category": b["category"],
|
|
"baseline_wall_seconds": b["wall_seconds"], "candidate_wall_seconds": c["wall_seconds"],
|
|
"candidate_over_baseline_wall_ratio": ratio(c["wall_seconds"], b["wall_seconds"]),
|
|
"baseline_quality_passed": b["quality"]["passed"], "candidate_quality_passed": c["quality"]["passed"],
|
|
"baseline_protocol_failed": b["http_status"] != 200 or b_normal is None,
|
|
"candidate_protocol_failed": c["http_status"] != 200 or c_normal is None,
|
|
"same_normalized_output": b["http_status"] == c["http_status"] == 200 and b_normal is not None and b_normal == c_normal,
|
|
"baseline_usage": b["response"].get("usage"), "candidate_usage": c["response"].get("usage"),
|
|
"baseline_timings": b["response"].get("timings") or {}, "candidate_timings": c["response"].get("timings") or {},
|
|
})
|
|
grouped_cases, grouped_categories = {}, {}
|
|
for pair in pairs:
|
|
grouped_cases.setdefault(pair["case_id"], []).append(pair)
|
|
grouped_categories.setdefault(pair["category"], []).append(pair)
|
|
categories = {category: group_summary(members) for category, members in sorted(grouped_categories.items())}
|
|
summary = group_summary(pairs)
|
|
summary.update({
|
|
"baseline_quality_passed": sum(p["baseline_quality_passed"] for p in pairs),
|
|
"candidate_quality_passed": sum(p["candidate_quality_passed"] for p in pairs),
|
|
"categories": categories,
|
|
"cases": {case: group_summary(members) for case, members in sorted(grouped_cases.items())},
|
|
"failed_quality_categories": [name for name, result in categories.items()
|
|
if not result["quality"]["observed_checks_passed"]],
|
|
})
|
|
warmups = initial_requests(base, candidate)
|
|
summary["initial_request_quality_failed"] = sum(
|
|
not (row["baseline_quality_passed"] and row["candidate_quality_passed"]) for row in warmups.values())
|
|
return {"summary": summary, "pairs": pairs, "initial_requests": warmups,
|
|
"provenance": {"baseline": provenance(base), "candidate": provenance(candidate)},
|
|
"qualification": {"performance_qualified": False, "model_quality_qualified": False,
|
|
"reason": "descriptive offline comparison; separate charter gates required"}}
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("baseline", type=Path)
|
|
parser.add_argument("candidate", type=Path)
|
|
parser.add_argument("--output", type=Path, required=True)
|
|
args = parser.parse_args()
|
|
try:
|
|
repository = Path(__file__).resolve().parent.parent
|
|
if args.output.is_symlink():
|
|
reject("output must not be a symbolic link")
|
|
output = args.output.resolve()
|
|
if output == repository or repository in output.parents or any((parent / ".git").exists() for parent in output.parents):
|
|
reject("output must be outside Git repositories")
|
|
base, candidate = load_report(args.baseline), load_report(args.candidate)
|
|
report = {"schema": 1, "created_utc": dt.datetime.now(dt.timezone.utc).isoformat(),
|
|
"baseline_report": str(args.baseline.resolve()), "candidate_report": str(args.candidate.resolve()),
|
|
"baseline_metadata": base.get("metadata", {}), "candidate_metadata": candidate.get("metadata", {}),
|
|
"comparison_limit": LIMITATION, **compare(base, candidate)}
|
|
payload = (json.dumps(report, indent=2, ensure_ascii=False, allow_nan=False) + "\n").encode("utf-8")
|
|
old_mask = os.umask(0o077)
|
|
try:
|
|
output.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
|
|
fd = os.open(output, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
|
|
finally:
|
|
os.umask(old_mask)
|
|
try:
|
|
with os.fdopen(fd, "wb") as destination:
|
|
destination.write(payload)
|
|
except BaseException:
|
|
output.unlink(missing_ok=True)
|
|
raise
|
|
summary = report["summary"]
|
|
print(json.dumps({"pairs": summary["pairs"],
|
|
"baseline_quality_passed": summary["baseline_quality_passed"],
|
|
"candidate_quality_passed": summary["candidate_quality_passed"],
|
|
"same_normalized_output": summary["same_normalized_output"],
|
|
"failed_quality_category_count": len(summary["failed_quality_categories"]),
|
|
"performance_qualified": False, "model_quality_qualified": False}))
|
|
except (ValueError, TypeError, OverflowError, RecursionError):
|
|
print("paired report rejected: invalid or incompatible report data", file=sys.stderr)
|
|
return 1
|
|
except OSError:
|
|
print("paired report rejected: private input/output unavailable or output already exists", file=sys.stderr)
|
|
return 1
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|