2 """Comparable metric surface validation for performance evidence. 4 Verifies that counted and diagnosis-only benchmark cases share one comparable 5 metric vocabulary, including auditable repeated-timing fields for the 6 representative review set. 9 python benchmarks/density_matrix/performance_evidence/metric_surface_validation.py 12 from __future__
import annotations
15 from pathlib
import Path
17 REPO_ROOT = Path(__file__).resolve().parents[3]
18 if str(REPO_ROOT)
not in sys.path:
19 sys.path.insert(0, str(REPO_ROOT))
21 from benchmarks.density_matrix.performance_evidence.common
import (
22 performance_evidence_output_dir,
24 from benchmarks.density_matrix.performance_evidence.records
import (
25 build_performance_evidence_benchmark_records,
27 from benchmarks.density_matrix.performance_evidence.validation_support
import (
28 assemble_record_schema_case_bundle,
30 from benchmarks.density_matrix.validation_scaffold
import (
31 require_bundle_fields,
35 SUITE_NAME =
"performance_evidence_metric_surface" 36 ARTIFACT_FILENAME =
"metric_surface_bundle.json" 38 ARTIFACT_CORE_FIELDS = (
41 "record_schema_version",
54 metric_surface_pass = all(
55 case[
"runtime_ms"]
is not None 56 and case[
"peak_rss_kb"]
is not None 57 and case[
"planning_time_ms"]
is not None 58 and case[
"partition_count"]
is not None 59 and case[
"max_partition_span"]
is not None 60 and case[
"runtime_path"]
is not None 64 case[
"representative_review_case"]
65 and case[
"timing_mode"] ==
"median_3" 66 and len(case[
"sequential_runtime_ms_samples"]) == 3
67 and len(case[
"fused_runtime_ms_samples"]) == 3
69 or (
not case[
"representative_review_case"]
and case[
"timing_mode"] ==
"single_run")
72 status =
"pass" if metric_surface_pass
else "fail" 74 "total_cases": len(cases),
75 "representative_review_cases": sum(case[
"representative_review_case"]
for case
in cases),
76 "counted_supported_cases": sum(case[
"counted_supported_benchmark_case"]
for case
in cases),
77 "diagnosis_only_cases": sum(case[
"diagnosis_only_case"]
for case
in cases),
78 "single_run_cases": sum(case[
"timing_mode"] ==
"single_run" for case
in cases),
79 "median_timed_cases": sum(case[
"timing_mode"] ==
"median_3" for case
in cases),
86 def main(argv: list[str] |
None =
None) -> int:
89 build_cases=build_metric_surface_cases,
90 build_artifact_bundle=build_metric_surface_bundle,
91 artifact_filename=ARTIFACT_FILENAME,
92 default_output_dir=DEFAULT_OUTPUT_DIR,
93 description=__doc__
or "",
94 output_dir_help=
"Directory to write the metric surface bundle into.",
95 quiet_report=
lambda b: print(
96 "median_timed_cases={median_timed_cases}, single_run_cases={single_run_cases}".format(
103 if __name__ ==
"__main__":
104 raise SystemExit(
main())
def build_metric_surface_cases()
def build_performance_evidence_benchmark_records()
def build_metric_surface_bundle
def performance_evidence_output_dir
def assemble_record_schema_case_bundle
def require_bundle_fields