1 """Regression tests for shared density-matrix evidence core (Story 1).""" 3 from __future__
import annotations
5 from pathlib
import Path
8 REPO_ROOT = Path(__file__).resolve().parents[3]
9 if str(REPO_ROOT)
not in sys.path:
10 sys.path.insert(0, str(REPO_ROOT))
12 from benchmarks.density_matrix.evidence_core
import (
13 RUNTIME_CORRECTNESS_BRIDGE_FIELD_NAMES,
14 counted_supported_case,
16 from benchmarks.density_matrix.correctness_evidence.records
import (
17 build_correctness_evidence_positive_records,
19 from benchmarks.density_matrix.performance_evidence.records
import (
20 build_performance_evidence_core_benchmark_records,
24 _EXPECTED_SORTED_BRIDGE_FIELD_NAMES: tuple[str, ...] = (
25 "actual_fused_execution",
26 "continuity_energy_error",
27 "continuity_energy_pass",
28 "continuity_energy_required",
29 "deferred_region_count",
30 "descriptor_member_count",
31 "exact_output_present",
32 "external_frobenius_norm_diff",
33 "external_max_abs_diff",
34 "external_reference_pass",
35 "frobenius_norm_diff",
39 "internal_reference_pass",
43 "output_integrity_pass",
44 "parameter_routing_segment_count",
46 "partition_member_counts",
49 "remapped_partition_count",
54 "supported_runtime_case",
55 "supported_unfused_gate_count",
56 "supported_unfused_region_count",
62 assert tuple(sorted(RUNTIME_CORRECTNESS_BRIDGE_FIELD_NAMES)) == _EXPECTED_SORTED_BRIDGE_FIELD_NAMES
66 correctness_by_workload = {
70 if not perf[
"correctness_evidence_reference_available"]:
72 ce = correctness_by_workload[perf[
"workload_id"]]
75 assert ce_counted == perf_counted
76 assert perf_counted == perf[
"counted_supported_benchmark_case"]
80 correctness_by_workload = {
84 if not perf[
"correctness_evidence_reference_available"]:
86 ce = correctness_by_workload[perf[
"workload_id"]]
87 for field
in RUNTIME_CORRECTNESS_BRIDGE_FIELD_NAMES:
88 assert perf[field] == ce[field], field
93 "supported_runtime_case":
True,
94 "internal_reference_pass":
True,
95 "output_integrity_pass":
True,
96 "continuity_energy_required":
False,
97 "continuity_energy_pass":
True,
98 "external_reference_required":
False,
99 "external_reference_pass":
True,
104 assert counted_supported_case({**base,
"continuity_energy_required":
True,
"continuity_energy_pass":
False})
is False 106 {**base,
"external_reference_required":
True,
"external_reference_pass":
False}
def test_runtime_correctness_bridge_field_names_stable()
def test_bridge_fields_match_correctness_when_reference_available()
def build_correctness_evidence_positive_records()
def build_performance_evidence_core_benchmark_records()
def test_counted_supported_case_synthetic_examples()
def test_counted_supported_matches_between_pipelines_when_reference_available()
def counted_supported_case