|
228 | 228 | PATH_C_FUSION_COMPILE_RECEIPT_PATH = ( |
229 | 229 | ROOT / "reports" / "path_c_fusion_compile_receipt.json" |
230 | 230 | ) |
| 231 | +PATH_C_FUSION_MATRIX_PROFILE_RECEIPT_ENV = ( |
| 232 | + "CPPMEGA_PATH_C_FUSION_MATRIX_PROFILE_RECEIPT" |
| 233 | +) |
| 234 | +PATH_C_FUSION_MATRIX_PROFILE_RECEIPT_PATH = ( |
| 235 | + ROOT / "reports" / "path_c_fusion_matrix_profile_receipt.json" |
| 236 | +) |
231 | 237 | FP8_PATH_C_BRIDGE_TARGET = "native_mlx_tvm_ffi_graph_bridge" |
232 | 238 | FP8_PATH_C_BRIDGE_STATUS = "m04_wired_for_native_tvm_ffi_graph_outputs" |
233 | 239 | FP8_PATH_C_CARRIER_DTYPE = "bfloat16" |
@@ -5767,10 +5773,114 @@ def _path_c_fusion_compile_receipt_payload( |
5767 | 5773 | } |
5768 | 5774 |
|
5769 | 5775 |
|
| 5776 | +def _path_c_fusion_matrix_profile_receipt_path() -> Path: |
| 5777 | + override = os.environ.get(PATH_C_FUSION_MATRIX_PROFILE_RECEIPT_ENV) |
| 5778 | + if override: |
| 5779 | + return Path(override).expanduser() |
| 5780 | + return PATH_C_FUSION_MATRIX_PROFILE_RECEIPT_PATH |
| 5781 | + |
| 5782 | + |
| 5783 | +def _path_c_fusion_matrix_profile_payload( |
| 5784 | + *, |
| 5785 | + schedule_spec: Any, |
| 5786 | + receipt_path: str | Path | None = None, |
| 5787 | +) -> dict[str, Any]: |
| 5788 | + """Validate 1B matrix/profile/cache evidence for a production schedule.""" |
| 5789 | + |
| 5790 | + receipt_path = ( |
| 5791 | + Path(receipt_path).expanduser() |
| 5792 | + if receipt_path is not None |
| 5793 | + else _path_c_fusion_matrix_profile_receipt_path() |
| 5794 | + ) |
| 5795 | + expected_schedule_id = str(schedule_spec.schedule_id) |
| 5796 | + expected_schedule_name = str(schedule_spec.schedule_name) |
| 5797 | + base: dict[str, Any] = { |
| 5798 | + "path": str(receipt_path), |
| 5799 | + "status": "missing", |
| 5800 | + "verified": False, |
| 5801 | + "schedule_id": None, |
| 5802 | + "schedule_name": None, |
| 5803 | + "failed_checks": [], |
| 5804 | + "reason": "production fused schedule 1B matrix/profile receipt is missing", |
| 5805 | + } |
| 5806 | + if not receipt_path.exists(): |
| 5807 | + return base |
| 5808 | + try: |
| 5809 | + receipt = json.loads(receipt_path.read_text(encoding="utf-8")) |
| 5810 | + except (OSError, json.JSONDecodeError) as exc: |
| 5811 | + return { |
| 5812 | + **base, |
| 5813 | + "status": "unreadable", |
| 5814 | + "reason": f"{type(exc).__name__}: {exc}", |
| 5815 | + } |
| 5816 | + |
| 5817 | + matrix_rows = receipt.get("matrix_rows", ()) |
| 5818 | + checks = { |
| 5819 | + "receipt_kind_ok": ( |
| 5820 | + receipt.get("kind") |
| 5821 | + == "cppmega_path_c_fusion_matrix_profile_receipt" |
| 5822 | + ), |
| 5823 | + "receipt_status_ok": receipt.get("status") == "ok", |
| 5824 | + "model_profile_matches": ( |
| 5825 | + receipt.get("model_profile") == REQUIRED_MODEL_PROFILE |
| 5826 | + ), |
| 5827 | + "schedule_id_matches": ( |
| 5828 | + str(receipt.get("schedule_id", "")) == expected_schedule_id |
| 5829 | + ), |
| 5830 | + "schedule_name_matches": ( |
| 5831 | + str(receipt.get("schedule_name", "")) == expected_schedule_name |
| 5832 | + ), |
| 5833 | + "full_1b_matrix_captured": ( |
| 5834 | + receipt.get("full_1b_matrix_captured") is True |
| 5835 | + ), |
| 5836 | + "profiling_traces_captured": ( |
| 5837 | + receipt.get("profiling_traces_captured") is True |
| 5838 | + ), |
| 5839 | + "memory_non_regression_ok": ( |
| 5840 | + receipt.get("memory_non_regression_ok") is True |
| 5841 | + ), |
| 5842 | + "cache_receipts_captured": ( |
| 5843 | + receipt.get("cache_receipts_captured") is True |
| 5844 | + ), |
| 5845 | + "path_b_baselines_clean": ( |
| 5846 | + receipt.get("path_b_baselines_clean") is True |
| 5847 | + ), |
| 5848 | + "path_c_default_gate_rows_passed": ( |
| 5849 | + receipt.get("path_c_default_gate_rows_passed") is True |
| 5850 | + ), |
| 5851 | + "path_c_peak_memory_non_regression": ( |
| 5852 | + receipt.get("path_c_peak_memory_non_regression") is True |
| 5853 | + ), |
| 5854 | + "path_c_warm_cache_hit_observed": ( |
| 5855 | + receipt.get("path_c_warm_cache_hit_observed") is True |
| 5856 | + ), |
| 5857 | + "matrix_rows_present": isinstance(matrix_rows, list) and bool(matrix_rows), |
| 5858 | + } |
| 5859 | + failed_checks = [name for name, ok in checks.items() if not ok] |
| 5860 | + verified = not failed_checks |
| 5861 | + return { |
| 5862 | + **base, |
| 5863 | + "status": "verified" if verified else "mismatch", |
| 5864 | + "verified": verified, |
| 5865 | + "schedule_id": receipt.get("schedule_id"), |
| 5866 | + "schedule_name": receipt.get("schedule_name"), |
| 5867 | + "checks": checks, |
| 5868 | + "failed_checks": failed_checks, |
| 5869 | + "matrix_row_count": len(matrix_rows) if isinstance(matrix_rows, list) else 0, |
| 5870 | + "reason": ( |
| 5871 | + "production fused schedule has matching full 1B matrix, profiling, " |
| 5872 | + "memory non-regression, and cache receipt evidence" |
| 5873 | + if verified |
| 5874 | + else "production fused schedule matrix/profile receipt does not match this route" |
| 5875 | + ), |
| 5876 | + } |
| 5877 | + |
| 5878 | + |
5770 | 5879 | def path_c_fusion_payload( |
5771 | 5880 | *, |
5772 | 5881 | model: Any | None = None, |
5773 | 5882 | compile_receipt_path: str | Path | None = None, |
| 5883 | + matrix_profile_receipt_path: str | Path | None = None, |
5774 | 5884 | bank_buffers: Mapping[str, Any] | None = None, |
5775 | 5885 | bank_buffer_owner: str | None = None, |
5776 | 5886 | bank_owner: Any | None = None, |
@@ -5825,6 +5935,13 @@ def path_c_fusion_payload( |
5825 | 5935 | receipt_path=compile_receipt_path, |
5826 | 5936 | ) |
5827 | 5937 | production_compile_verified = bool(compile_receipt.get("verified")) |
| 5938 | + matrix_profile_receipt = _path_c_fusion_matrix_profile_payload( |
| 5939 | + schedule_spec=schedule_spec, |
| 5940 | + receipt_path=matrix_profile_receipt_path, |
| 5941 | + ) |
| 5942 | + production_matrix_profile_verified = bool( |
| 5943 | + matrix_profile_receipt.get("verified") |
| 5944 | + ) |
5828 | 5945 | expected_bank_buffer_owner = ( |
5829 | 5946 | bank_buffer_owner |
5830 | 5947 | if bank_buffer_owner is not None |
@@ -6109,6 +6226,7 @@ def path_c_fusion_payload( |
6109 | 6226 | fused_train_block_training_contract |
6110 | 6227 | ), |
6111 | 6228 | "production_compile_receipt": compile_receipt, |
| 6229 | + "production_matrix_profile_receipt": matrix_profile_receipt, |
6112 | 6230 | "direct_chained_fusion": { |
6113 | 6231 | **_path_c_direct_chain_plan_payload(direct_chain), |
6114 | 6232 | "construction": direct_chain_construction, |
@@ -6264,16 +6382,31 @@ def path_c_fusion_payload( |
6264 | 6382 | if not runtime_fused_route_bound |
6265 | 6383 | else [] |
6266 | 6384 | ), |
6267 | | - { |
6268 | | - "kind": "production_1b_matrix_profile_missing", |
6269 | | - "schedule_id": schedule_spec.schedule_id, |
6270 | | - "schedule_name": schedule_spec.schedule_name, |
6271 | | - "reason": ( |
6272 | | - "the full 1B Path B/Path C matrix, profiling traces, memory " |
6273 | | - "non-regression evidence, and cache receipts have not been " |
6274 | | - "captured for this production schedule" |
6275 | | - ), |
6276 | | - }, |
| 6385 | + *( |
| 6386 | + [ |
| 6387 | + { |
| 6388 | + "kind": "production_1b_matrix_profile_missing", |
| 6389 | + "schedule_id": schedule_spec.schedule_id, |
| 6390 | + "schedule_name": schedule_spec.schedule_name, |
| 6391 | + "matrix_profile_receipt_status": ( |
| 6392 | + matrix_profile_receipt.get("status") |
| 6393 | + ), |
| 6394 | + "matrix_profile_receipt_path": ( |
| 6395 | + matrix_profile_receipt.get("path") |
| 6396 | + ), |
| 6397 | + "failed_checks": list( |
| 6398 | + matrix_profile_receipt.get("failed_checks", ()) |
| 6399 | + ), |
| 6400 | + "reason": ( |
| 6401 | + "the full 1B Path B/Path C matrix, profiling traces, " |
| 6402 | + "memory non-regression evidence, and cache receipts " |
| 6403 | + "have not been captured for this production schedule" |
| 6404 | + ), |
| 6405 | + } |
| 6406 | + ] |
| 6407 | + if not production_matrix_profile_verified |
| 6408 | + else [] |
| 6409 | + ), |
6277 | 6410 | *( |
6278 | 6411 | [ |
6279 | 6412 | { |
@@ -6352,6 +6485,9 @@ def path_c_fusion_payload( |
6352 | 6485 | "requires_ready_fusion_plan": True, |
6353 | 6486 | "requires_compile_verified_single_kernel": True, |
6354 | 6487 | "current_compile_receipt_verified": production_compile_verified, |
| 6488 | + "current_matrix_profile_verified": ( |
| 6489 | + production_matrix_profile_verified |
| 6490 | + ), |
6355 | 6491 | "requires_verified_schedule_contract": True, |
6356 | 6492 | "requires_complete_real_abi_contract": True, |
6357 | 6493 | "current_plan_default_eligible": False, |
|
0 commit comments