1 """Regression tests for the Phase 3.1 hybrid performance pilot (P31-S09-E01).""" 3 from __future__
import annotations
5 from pathlib
import Path
10 REPO_ROOT = Path(__file__).resolve().parents[3]
11 if str(REPO_ROOT)
not in sys.path:
12 sys.path.insert(0, str(REPO_ROOT))
14 from benchmarks.density_matrix.performance_evidence.case_selection
import (
15 BENCHMARK_SLICE_PHASE31_HYBRID_PILOT,
16 PHASE31_HYBRID_PILOT_WORKLOAD_ID,
17 build_phase31_hybrid_pilot_case_context,
18 build_phase31_performance_inventory_cases,
19 iter_phase31_performance_cases,
21 from benchmarks.density_matrix.performance_evidence.common
import (
22 PERFORMANCE_EVIDENCE_CASE_SCHEMA_VERSION,
23 PERFORMANCE_EVIDENCE_REPETITIONS,
25 from benchmarks.density_matrix.performance_evidence.phase31_hybrid_pilot_validation
import (
26 build_phase31_hybrid_pilot_bundle,
27 build_phase31_hybrid_pilot_cases,
29 from benchmarks.density_matrix.performance_evidence.records
import (
30 _PHASE31_HYBRID_DECISION_CLASSES,
31 _PHASE31_HYBRID_DIAGNOSIS_TAGS,
32 build_phase31_hybrid_pilot_record,
35 _FROZEN_DECISION_CLASSES = frozenset(_PHASE31_HYBRID_DECISION_CLASSES)
36 _FROZEN_DIAGNOSIS_TAGS = frozenset(_PHASE31_HYBRID_DIAGNOSIS_TAGS)
41 assert ctx.descriptor_set.workload_id == PHASE31_HYBRID_PILOT_WORKLOAD_ID
42 assert ctx.metadata[
"benchmark_slice"] == BENCHMARK_SLICE_PHASE31_HYBRID_PILOT
47 assert record[
"workload_id"] == PHASE31_HYBRID_PILOT_WORKLOAD_ID
48 assert record[
"timing_mode"] ==
"median_3" 49 n = PERFORMANCE_EVIDENCE_REPETITIONS
50 assert len(record[
"sequential_runtime_ms_samples"]) == n
51 assert len(record[
"phase3_fused_runtime_ms_samples"]) == n
52 assert len(record[
"phase31_hybrid_runtime_ms_samples"]) == n
53 assert len(record[
"sequential_peak_rss_kb_samples"]) == n
54 assert len(record[
"phase3_fused_peak_rss_kb_samples"]) == n
55 assert len(record[
"phase31_hybrid_peak_rss_kb_samples"]) == n
57 "sequential_median_runtime_ms",
58 "phase3_fused_median_runtime_ms",
59 "phase31_hybrid_median_runtime_ms",
61 assert record[key] > 0.0
63 "sequential_median_peak_rss_kb",
64 "phase3_fused_median_peak_rss_kb",
65 "phase31_hybrid_median_peak_rss_kb",
67 assert record[key] >= 0
69 "channel_native_partition_count",
70 "phase3_routed_partition_count",
71 "channel_native_member_count",
72 "phase3_routed_member_count",
75 assert record[key] >= 0
76 assert record[
"channel_native_partition_count"] > 0
77 assert record[
"channel_native_member_count"] > 0
78 assert record[
"decision_class"]
in _FROZEN_DECISION_CLASSES
79 assert record[
"diagnosis_tag"]
in _FROZEN_DIAGNOSIS_TAGS
80 assert isinstance(record[
"hybrid_partition_route_records"], list)
81 assert len(record[
"hybrid_partition_route_records"]) == record[
82 "phase31_hybrid_partition_count" 84 assert record[
"phase3_fused_internal_reference_pass"]
is True 85 assert record[
"phase31_hybrid_internal_reference_pass"]
is True 90 cn = record[
"channel_native_partition_count"]
91 fused_ms = record[
"phase3_fused_median_runtime_ms"]
92 hybrid_ms = record[
"phase31_hybrid_median_runtime_ms"]
93 speedup = fused_ms / hybrid_ms
if hybrid_ms > 0.0
else 0.0
94 positive = speedup >= 1.2
95 tag = record[
"diagnosis_tag"]
96 decision = record[
"decision_class"]
98 assert tag ==
"phase31_positive_gain" 99 assert decision ==
"phase31_justified" 101 assert tag ==
"limited_channel_native_coverage" 102 assert decision ==
"phase3_sufficient" 104 assert tag ==
"hybrid_overhead_dominant" 105 assert decision ==
"phase31_not_justified_yet" 111 assert bundle[
"status"] ==
"pass" 112 assert bundle[
"record_schema_version"] == PERFORMANCE_EVIDENCE_CASE_SCHEMA_VERSION
113 s = bundle[
"summary"]
114 assert s[
"total_cases"] == 1
115 assert s[
"pilot_workload_id"] == PHASE31_HYBRID_PILOT_WORKLOAD_ID
116 assert s[
"pilot_case_name"] == cases[0][
"case_name"]
117 assert s[
"timing_mode"] ==
"median_3" 118 assert s[
"decision_class"] == cases[0][
"decision_class"]
119 assert s[
"diagnosis_tag"] == cases[0][
"diagnosis_tag"]
120 assert s[
"channel_native_partition_count"] == cases[0][
"channel_native_partition_count"]
121 assert s[
"phase3_routed_partition_count"] == cases[0][
"phase3_routed_partition_count"]
125 """Guards Phase 3.1 planning helpers (control branch uses DEFAULT_STRUCTURED_SEED).""" 127 assert len(inventory) == 26
129 c.get(
"benchmark_slice") ==
"phase31_control_performance" for c
in inventory
132 assert len(contexts) == 26
134 ctx.metadata.get(
"benchmark_slice") ==
"phase31_control_performance" def test_phase31_hybrid_pilot_bundle_schema()
def test_phase31_hybrid_pilot_decision_consistent_with_tags()
def build_phase31_hybrid_pilot_case_context()
def build_phase31_hybrid_pilot_record(case_context)
def build_phase31_hybrid_pilot_cases()
def build_phase31_hybrid_pilot_bundle
def build_phase31_performance_inventory_cases()
def iter_phase31_performance_cases()
def test_phase31_hybrid_pilot_record_baseline_trio_and_routes()
def test_phase31_hybrid_pilot_workload_id_frozen()
def test_phase31_performance_helpers_inventory_and_iter_regression()