Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
unsupported_boundary_validation.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 """Unsupported-boundary (negative evidence) validation.
3 
4 Builds a stage-separated negative-evidence layer for planner-entry,
5 descriptor-generation, and runtime-stage unsupported or deferred behavior.
6 
7 Run with:
8  python benchmarks/density_matrix/correctness_evidence/unsupported_boundary_validation.py
9 """
10 
11 from __future__ import annotations
12 
13 from pathlib import Path
14 
15 from benchmarks.density_matrix.correctness_evidence.common import (
16  CORRECTNESS_EVIDENCE_NEGATIVE_RECORD_SCHEMA_VERSION,
17  correctness_evidence_output_dir,
18 )
19 from benchmarks.density_matrix.correctness_evidence.records import (
20  build_correctness_evidence_negative_records,
21 )
22 from benchmarks.density_matrix.correctness_evidence.validation_support import (
23  assemble_negative_boundary_bundle,
24 )
25 from benchmarks.density_matrix.validation_scaffold import (
26  require_bundle_fields,
27  run_case_slice_cli,
28 )
29 
30 SUITE_NAME = "correctness_evidence_unsupported_boundary"
31 ARTIFACT_FILENAME = "unsupported_boundary_bundle.json"
32 DEFAULT_OUTPUT_DIR = correctness_evidence_output_dir("unsupported_boundary")
33 ARTIFACT_CORE_FIELDS = (
34  "suite_name",
35  "status",
36  "negative_record_schema_version",
37  "software",
38  "selected_candidate",
39  "summary",
40  "cases",
41 )
42 
43 
44 def build_cases() -> list[dict]:
46 
47 
48 def build_artifact_bundle(cases: list[dict]) -> dict:
49  stage_counts = {
50  "planner_entry_cases": sum(case["boundary_stage"] == "planner_entry" for case in cases),
51  "descriptor_generation_cases": sum(
52  case["boundary_stage"] == "descriptor_generation" for case in cases
53  ),
54  "runtime_stage_cases": sum(case["boundary_stage"] == "runtime_stage" for case in cases),
55  }
56  status = "pass" if all(case["status"] == "unsupported" for case in cases) else "fail"
57  summary = {
58  "total_cases": len(cases),
59  **stage_counts,
60  "unsupported_cases": sum(case["status"] == "unsupported" for case in cases),
61  }
63  SUITE_NAME,
64  status,
65  CORRECTNESS_EVIDENCE_NEGATIVE_RECORD_SCHEMA_VERSION,
66  summary,
67  cases,
68  )
69  require_bundle_fields(bundle, ARTIFACT_CORE_FIELDS, "Unsupported boundary bundle")
70  return bundle
71 
72 
73 def main(argv: list[str] | None = None) -> int:
74  return run_case_slice_cli(
75  argv,
76  build_cases=build_cases,
77  build_artifact_bundle=build_artifact_bundle,
78  artifact_filename=ARTIFACT_FILENAME,
79  default_output_dir=DEFAULT_OUTPUT_DIR,
80  description=__doc__ or "",
81  output_dir_help="Directory to write the unsupported boundary bundle into.",
82  quiet_report=lambda b: print(
83  "planner_entry_cases={planner_entry_cases}, descriptor_generation_cases={descriptor_generation_cases}, runtime_stage_cases={runtime_stage_cases}".format(
84  **b["summary"]
85  )
86  ),
87  )
88 
89 
90 if __name__ == "__main__":
91  raise SystemExit(main())
def build_correctness_evidence_negative_records()