Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
phase31_hybrid_pilot_validation.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 """Phase 3.1 hybrid performance pilot artifact (P31-S09-E01).
3 
4 Materializes one frozen structured case with sequential, Phase 3 fused, and hybrid
5 timings, route coverage, and a small decision/diagnosis tag.
6 
7 Run with:
8  python benchmarks/density_matrix/performance_evidence/phase31_hybrid_pilot_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.case_selection import (
21  PHASE31_HYBRID_PILOT_WORKLOAD_ID,
22  build_phase31_hybrid_pilot_case_context,
23 )
24 from benchmarks.density_matrix.performance_evidence.common import (
25  performance_evidence_output_dir,
26 )
27 from benchmarks.density_matrix.performance_evidence.records import (
28  build_phase31_hybrid_pilot_record,
29 )
30 from benchmarks.density_matrix.performance_evidence.validation_support import (
31  assemble_record_schema_case_bundle,
32 )
33 from benchmarks.density_matrix.validation_scaffold import (
34  require_bundle_fields,
35  run_case_slice_cli,
36 )
37 
38 SUITE_NAME = "performance_evidence_phase31_hybrid_pilot"
39 ARTIFACT_FILENAME = "phase31_hybrid_pilot_bundle.json"
40 DEFAULT_OUTPUT_DIR = performance_evidence_output_dir("phase31_hybrid_pilot")
41 ARTIFACT_CORE_FIELDS = (
42  "suite_name",
43  "status",
44  "record_schema_version",
45  "software",
46  "selected_candidate",
47  "summary",
48  "cases",
49 )
50 
51 
54 
55 
56 def build_phase31_hybrid_pilot_bundle(cases: list[dict]) -> dict:
57  if len(cases) != 1:
58  raise ValueError("phase31 hybrid pilot bundle expects exactly one case")
59  case = cases[0]
60  correctness_pass = bool(
61  case.get("phase3_fused_internal_reference_pass")
62  and case.get("phase31_hybrid_internal_reference_pass")
63  )
64  summary = {
65  "total_cases": len(cases),
66  "pilot_case_name": case["case_name"],
67  "pilot_workload_id": PHASE31_HYBRID_PILOT_WORKLOAD_ID,
68  "timing_mode": case["timing_mode"],
69  "decision_class": case["decision_class"],
70  "diagnosis_tag": case["diagnosis_tag"],
71  "channel_native_partition_count": case["channel_native_partition_count"],
72  "phase3_routed_partition_count": case["phase3_routed_partition_count"],
73  }
75  SUITE_NAME,
76  "pass" if correctness_pass else "fail",
77  summary,
78  cases,
79  )
80  require_bundle_fields(bundle, ARTIFACT_CORE_FIELDS, "Phase 3.1 hybrid pilot bundle")
81  return bundle
82 
83 
84 def main(argv: list[str] | None = None) -> int:
85  return run_case_slice_cli(
86  argv,
87  build_cases=build_phase31_hybrid_pilot_cases,
88  build_artifact_bundle=build_phase31_hybrid_pilot_bundle,
89  artifact_filename=ARTIFACT_FILENAME,
90  default_output_dir=DEFAULT_OUTPUT_DIR,
91  description=__doc__ or "",
92  output_dir_help="Directory to write the Phase 3.1 hybrid pilot bundle into.",
93  quiet_report=lambda b: print(
94  "pilot={pilot_case_name}, decision={decision_class}, diagnosis={diagnosis_tag}, "
95  "cn_partitions={channel_native_partition_count}, p3_partitions={phase3_routed_partition_count}, "
96  "status={status}".format(status=b["status"], **b["summary"])
97  ),
98  )
99 
100 
101 if __name__ == "__main__":
102  raise SystemExit(main())
def build_phase31_hybrid_pilot_record(case_context)