Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
test_partitioned_runtime_matrices.py
Go to the documentation of this file.
1 """Benchmark validation matrices for partitioned runtime evidence bundles."""
2 
3 from pathlib import Path
4 import sys
5 
6 REPO_ROOT = Path(__file__).resolve().parents[3]
7 if str(REPO_ROOT) not in sys.path:
8  sys.path.insert(0, str(REPO_ROOT))
9 
10 from benchmarks.density_matrix.partitioned_runtime.runtime_audit_validation import (
11  build_cases as build_runtime_audit_cases,
12 )
13 from benchmarks.density_matrix.partitioned_runtime.runtime_handoff_validation import (
14  build_cases as build_runtime_handoff_cases,
15 )
16 from benchmarks.density_matrix.partitioned_runtime.runtime_output_validation import (
17  build_cases as build_runtime_output_cases,
18 )
19 from benchmarks.density_matrix.partitioned_runtime.unsupported_runtime_validation import (
20  build_cases as build_unsupported_runtime_cases,
21 )
22 from squander.partitioning.noisy_runtime import (
23  PHASE3_RUNTIME_PATH_BASELINE,
24 )
25 
26 
28  cases = build_runtime_handoff_cases()
29  top_level_keys = {frozenset(case.keys()) for case in cases}
30  summary_key_sets = {frozenset(case["summary"].keys()) for case in cases}
31  partition_key_sets = {
32  frozenset(case["partitions"][0].keys()) for case in cases if case["partitions"]
33  }
34 
35  assert len(cases) == 3
36  assert len(top_level_keys) == 1
37  assert len(summary_key_sets) == 1
38  assert len(partition_key_sets) == 1
39 
40 
42  cases = build_runtime_output_cases()
43  exact_output_key_sets = {frozenset(case["exact_output"].keys()) for case in cases}
44 
45  assert len(cases) == 3
46  assert len(exact_output_key_sets) == 1
47  for case in cases:
48  assert case["result_output_pass"] is True
49  assert case["exact_output_present"] is True
50  assert "shape" in case["exact_output"]
51  assert "trace_real" in case["exact_output"]
52  assert "density_real" in case["exact_output"]
53  assert "density_imag" in case["exact_output"]
54 
55 
57  cases = build_runtime_audit_cases()
58  top_level_keys = {frozenset(case.keys()) for case in cases}
59  summary_key_sets = {frozenset(case["summary"].keys()) for case in cases}
60  partition_key_sets = {
61  frozenset(case["partitions"][0].keys()) for case in cases if case["partitions"]
62  }
63 
64  assert len(cases) == 3
65  assert len(top_level_keys) == 1
66  assert len(summary_key_sets) == 1
67  assert len(partition_key_sets) == 1
68  assert {case["runtime_path"] for case in cases} == {PHASE3_RUNTIME_PATH_BASELINE}
69  assert {case["requested_runtime_path"] for case in cases} == {PHASE3_RUNTIME_PATH_BASELINE}
70 
71 
73  cases = build_unsupported_runtime_cases()
74  expected_categories = {
75  "wrong_requested_mode": "runtime_request",
76  "parameter_count_mismatch": "runtime_request",
77  "unsupported_gate_name": "unsupported_runtime_operation",
78  "unsupported_noise_name": "unsupported_runtime_operation",
79  "gate_fixed_value": "descriptor_to_runtime_mismatch",
80  }
81 
82  assert {case["case_name"] for case in cases} == set(expected_categories)
83  for case in cases:
84  assert case["status"] == "unsupported"
85  assert case["unsupported_category"] == expected_categories[case["case_name"]]
86  assert case["supported_runtime_case_recorded"] is False