Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
counted_supported_validation.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 """Counted-supported gate validation for performance evidence.
3 
4 Verifies that positive benchmark evidence closes only from correctness-preserving
5 supported cases with stable provenance and explicit runtime-path identity.
6 
7 Run with:
8  python benchmarks/density_matrix/performance_evidence/counted_supported_validation.py
9 """
10 
11 from __future__ import annotations
12 
13 import sys
14 from pathlib import Path
15 
16 REPO_ROOT = Path(__file__).resolve().parents[3]
17 if str(REPO_ROOT) not in sys.path:
18  sys.path.insert(0, str(REPO_ROOT))
19 
20 from benchmarks.density_matrix.performance_evidence.common import (
21  performance_evidence_output_dir,
22 )
23 from benchmarks.density_matrix.performance_evidence.records import (
24  build_performance_evidence_core_benchmark_records,
25  performance_evidence_counted_supported_case,
26 )
27 from benchmarks.density_matrix.performance_evidence.validation_support import (
28  assemble_record_schema_case_bundle,
29 )
30 from benchmarks.density_matrix.validation_scaffold import (
31  require_bundle_fields,
32  run_case_slice_cli,
33 )
34 
35 SUITE_NAME = "performance_evidence_counted_supported"
36 ARTIFACT_FILENAME = "counted_supported_bundle.json"
37 DEFAULT_OUTPUT_DIR = performance_evidence_output_dir("counted_supported")
38 ARTIFACT_CORE_FIELDS = (
39  "suite_name",
40  "status",
41  "record_schema_version",
42  "software",
43  "selected_candidate",
44  "summary",
45  "cases",
46 )
47 
48 
49 def build_counted_supported_cases() -> list[dict]:
51 
52 
53 def build_counted_supported_bundle(cases: list[dict]) -> dict:
54  counted_supported_cases = [
55  case for case in cases if performance_evidence_counted_supported_case(case)
56  ]
57  status = (
58  "pass"
59  if len(counted_supported_cases) == len(cases)
60  and all(case["benchmark_status"] != "excluded" for case in counted_supported_cases)
61  else "fail"
62  )
63  summary = {
64  "total_cases": len(cases),
65  "counted_supported_cases": len(counted_supported_cases),
66  "excluded_cases": len(cases) - len(counted_supported_cases),
67  "correctness_evidence_reference_available": sum(
68  case["correctness_evidence_reference_available"] for case in cases
69  ),
70  "correctness_evidence_counted_reference_available": sum(
71  case["correctness_evidence_counted_reference_available"] for case in cases
72  ),
73  "supported_runtime_cases": sum(case["supported_runtime_case"] for case in cases),
74  }
75  bundle = assemble_record_schema_case_bundle(SUITE_NAME, status, summary, cases)
76  require_bundle_fields(bundle, ARTIFACT_CORE_FIELDS, "Counted-supported bundle")
77  return bundle
78 
79 
80 def main(argv: list[str] | None = None) -> int:
81  return run_case_slice_cli(
82  argv,
83  build_cases=build_counted_supported_cases,
84  build_artifact_bundle=build_counted_supported_bundle,
85  artifact_filename=ARTIFACT_FILENAME,
86  default_output_dir=DEFAULT_OUTPUT_DIR,
87  description=__doc__ or "",
88  output_dir_help="Directory to write the counted-supported bundle into.",
89  quiet_report=lambda b: print(
90  "counted_supported_cases={counted_supported_cases}, excluded_cases={excluded_cases}".format(
91  **b["summary"]
92  )
93  ),
94  )
95 
96 
97 if __name__ == "__main__":
98  raise SystemExit(main())
def build_performance_evidence_core_benchmark_records()
def performance_evidence_counted_supported_case