2 """Diagnosis-path validation for performance evidence. 4 Verifies that representative cases which do not satisfy the measurable-benefit path 5 remain benchmark-grounded, carry explicit bottleneck reasons, and preserve follow-on 9 python benchmarks/density_matrix/performance_evidence/diagnosis_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 build_boundary_evidence,
23 performance_evidence_output_dir,
25 from benchmarks.density_matrix.performance_evidence.records
import (
26 build_performance_evidence_benchmark_records,
28 from benchmarks.density_matrix.performance_evidence.validation_support
import (
29 assemble_record_schema_case_bundle,
31 from benchmarks.density_matrix.validation_scaffold
import (
32 require_bundle_fields,
36 SUITE_NAME =
"performance_evidence_diagnosis" 37 ARTIFACT_FILENAME =
"diagnosis_bundle.json" 39 ARTIFACT_CORE_FIELDS = (
42 "record_schema_version",
54 if case[
"diagnosis_only_case"]
59 diagnosis_surface_pass = all(case[
"diagnosis_reasons"]
for case
in cases)
60 status =
"pass" if diagnosis_surface_pass
else "fail" 62 "total_cases": len(cases),
64 "no_real_fused_coverage_cases": sum(
65 "no_real_fused_coverage" in case[
"diagnosis_reasons"]
for case
in cases
67 "limited_fused_coverage_cases": sum(
68 "limited_fused_coverage_due_to_noise_boundaries" in case[
"diagnosis_reasons"]
71 "runtime_slower_cases": sum(
72 "fused_runtime_slower_than_sequential_reference" in case[
"diagnosis_reasons"]
81 def main(argv: list[str] |
None =
None) -> int:
84 build_cases=build_diagnosis_cases,
85 build_artifact_bundle=build_diagnosis_bundle,
86 artifact_filename=ARTIFACT_FILENAME,
87 default_output_dir=DEFAULT_OUTPUT_DIR,
88 description=__doc__
or "",
89 output_dir_help=
"Directory to write the diagnosis bundle into.",
90 quiet_report=
lambda b: print(
91 "total_cases={total_cases}, limited_fused_coverage_cases={limited_fused_coverage_cases}, runtime_slower_cases={runtime_slower_cases}".format(
98 if __name__ ==
"__main__":
99 raise SystemExit(
main())
def build_performance_evidence_benchmark_records()
def build_boundary_evidence()
def performance_evidence_output_dir
def assemble_record_schema_case_bundle
def build_diagnosis_bundle
def build_diagnosis_cases()
def require_bundle_fields