Download code/analysis/build_common_recovered_excel.py from ergt2025/baseline_pdexp_result: direct link, hf CLI and curl.
- Browser
- Download file 8.03 kB
-
https://huggingface.co/datasets/ergt2025/baseline_pdexp_result/resolve/main/code/analysis/build_common_recovered_excel.py
- Command line
-
hf download hf://datasets/ergt2025/baseline_pdexp_result/code/analysis/build_common_recovered_excel.py
-
curl -L -o build_common_recovered_excel.py https://huggingface.co/datasets/ergt2025/baseline_pdexp_result/resolve/main/code/analysis/build_common_recovered_excel.py
8.03 kB
| #!/usr/bin/env python3 | |
| """Build the copy-ready, single-sheet, exact-28-column recovered workbook.""" | |
| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| from openpyxl import Workbook, load_workbook | |
| from openpyxl.comments import Comment | |
| from openpyxl.styles import Alignment, Border, Font, PatternFill, Side | |
| from openpyxl.utils import get_column_letter | |
| ROOT = Path(__file__).resolve().parent | |
| SOURCE = ROOT / "common-3p5d-c64-c96-c128-recovered-metrics.json" | |
| EXTRA_SOURCES = ( | |
| ROOT / "common-4p4d-c96-recovered-metrics.json", | |
| ROOT / "common-4p4d-c128-recovered-metrics.json", | |
| ROOT / "common-morphosis-4p4d-c96-c128-metrics.json", | |
| ROOT / "common-morphosis-5p3d-c96-c128-metrics.json", | |
| ) | |
| OUTPUT = ROOT / "common-3p5d-c64-c96-c128-recovered-28col.xlsx" | |
| EXPECTED_COLUMNS = [ | |
| "Model", | |
| "GPU", | |
| "# node", | |
| "workload", | |
| "topology", | |
| "parallelism", | |
| "routing policy", | |
| "concurrency", | |
| "hicache", | |
| "L3 backend", | |
| "L1 size", | |
| "L2 size", | |
| "L3 size", | |
| "kv dtype", | |
| "MTP", | |
| "avg ttft", | |
| "avg toks/s/user", | |
| "kv cache hit rate", | |
| "ideal kv cache hit rate", | |
| "avg rqst e2e latency", | |
| "avg prefill latency", | |
| "avg prefill queue latency", | |
| "bootstrap latency", | |
| "avg decode latency", | |
| "avg prefill toks/rqst", | |
| "avg decode toks/rqst", | |
| "req/s", | |
| "chunk size", | |
| ] | |
| PERCENT_COLUMNS = { | |
| "kv cache hit rate", | |
| "ideal kv cache hit rate", | |
| } | |
| THREE_DECIMAL_COLUMNS = { | |
| "avg ttft", | |
| "avg rqst e2e latency", | |
| "avg prefill latency", | |
| "avg prefill queue latency", | |
| "bootstrap latency", | |
| "avg decode latency", | |
| "req/s", | |
| } | |
| TWO_DECIMAL_COLUMNS = {"avg toks/s/user"} | |
| ONE_DECIMAL_COLUMNS = { | |
| "avg prefill toks/rqst", | |
| "avg decode toks/rqst", | |
| } | |
| COMMENTS = { | |
| "avg ttft": ( | |
| "OMP rows: recovered server metric from full-hour SGLang counters and " | |
| "TP0 ReqTimeStats. Morphosis rows: direct strict-replay request timing; " | |
| "both request start and completion must be in [900,3600)." | |
| ), | |
| "avg rqst e2e latency": ( | |
| "OMP rows use recovered server counters. Morphosis rows use direct " | |
| "strict-replay request timing in [900,3600)." | |
| ), | |
| "avg decode latency": ( | |
| "Enforced identity for every row: Avg E2E = Avg TTFT + Avg Decode." | |
| ), | |
| "avg toks/s/user": ( | |
| "OMP rows use recovered TP0 Decode timing. Morphosis rows use each " | |
| "strict request's (output tokens - 1) / client-observed decode duration." | |
| ), | |
| "avg prefill latency": ( | |
| "OMP rows use the recovered SGLang stage anchor. Morphosis rows use TP0 " | |
| "Prefill ReqTimeStats forward_duration with entry and finish in-window." | |
| ), | |
| "avg prefill queue latency": "Direct TP0 Prefill ReqTimeStats in [900,3600).", | |
| "bootstrap latency": "Direct TP0 Prefill ReqTimeStats in [900,3600).", | |
| "kv cache hit rate": "Exact completion-population, token-weighted cache hit.", | |
| "ideal kv cache hit rate": ( | |
| "Exact completion-population strict-token reusable prefix, aligned to " | |
| "the DSV4 256-token page override." | |
| ), | |
| } | |
| NAVY = "17365D" | |
| WHITE = "FFFFFF" | |
| LIGHT_BLUE = "EAF3F8" | |
| GRID = Side(style="thin", color="B7B7B7") | |
| def main() -> None: | |
| payload = json.loads(SOURCE.read_text(encoding="utf-8")) | |
| columns = payload["table_columns"] | |
| if columns != EXPECTED_COLUMNS: | |
| raise RuntimeError("Recovered data does not have the requested 28-column schema") | |
| rows = [cell["table_row"] for cell in payload["cells"]] | |
| if [row["concurrency"] for row in rows] != [64, 96, 128]: | |
| raise RuntimeError("Expected C64, C96, C128 rows") | |
| for extra_source in EXTRA_SOURCES: | |
| if not extra_source.exists(): | |
| continue | |
| extra = json.loads(extra_source.read_text(encoding="utf-8")) | |
| if extra["table_columns"] != EXPECTED_COLUMNS: | |
| raise RuntimeError("4P4D data does not use the same 28-column schema") | |
| rows.extend(cell["table_row"] for cell in extra["cells"]) | |
| if [ | |
| (row["workload"], row["topology"], row["concurrency"]) | |
| for row in rows | |
| ] != [ | |
| ("RoadmapBench OMP80 (15-60m)", "3P5D", 64), | |
| ("RoadmapBench OMP80 (15-60m)", "3P5D", 96), | |
| ("RoadmapBench OMP80 (15-60m)", "3P5D", 128), | |
| ("RoadmapBench OMP80 (15-60m)", "4P4D", 96), | |
| ("RoadmapBench OMP80 (15-60m)", "4P4D", 128), | |
| ("Morphosis dynamic100 r6 (15-60m)", "4P4D", 96), | |
| ("Morphosis dynamic100 r6 (15-60m)", "4P4D", 128), | |
| ("Morphosis dynamic100 r6 (15-60m)", "5P3D", 96), | |
| ("Morphosis dynamic100 r6 (15-60m)", "5P3D", 128), | |
| ]: | |
| raise RuntimeError("Unexpected completed-cell row set") | |
| wb = Workbook() | |
| wb.properties.title = "Recovered Common DSV4 OMP and Morphosis profile" | |
| wb.properties.subject = "Requested 28-column schema, scoring window [900,3600)" | |
| wb.properties.creator = "Cursor" | |
| ws = wb.active | |
| ws.title = "Metrics" | |
| ws.sheet_view.showGridLines = False | |
| for column, name in enumerate(columns, 1): | |
| cell = ws.cell(1, column, name) | |
| cell.fill = PatternFill("solid", fgColor=NAVY) | |
| cell.font = Font(color=WHITE, bold=True) | |
| cell.alignment = Alignment(horizontal="center", vertical="center", wrap_text=True) | |
| cell.border = Border(left=GRID, right=GRID, top=GRID, bottom=GRID) | |
| if name in COMMENTS: | |
| cell.comment = Comment(COMMENTS[name], "Cursor") | |
| ws.row_dimensions[1].height = 48 | |
| for row_index, source in enumerate(rows, 2): | |
| for column, name in enumerate(columns, 1): | |
| value = source[name] | |
| if value is None: | |
| raise RuntimeError(f"Missing value: row={row_index} column={name}") | |
| cell = ws.cell(row_index, column, value) | |
| cell.fill = PatternFill( | |
| "solid", fgColor=WHITE if row_index % 2 == 0 else LIGHT_BLUE | |
| ) | |
| cell.border = Border(left=GRID, right=GRID, top=GRID, bottom=GRID) | |
| cell.alignment = Alignment(horizontal="center", vertical="center", wrap_text=True) | |
| if name in PERCENT_COLUMNS: | |
| cell.number_format = "0.00%" | |
| elif name in THREE_DECIMAL_COLUMNS: | |
| cell.number_format = "0.000" | |
| elif name in TWO_DECIMAL_COLUMNS: | |
| cell.number_format = "0.00" | |
| elif name in ONE_DECIMAL_COLUMNS: | |
| cell.number_format = "0.0" | |
| ws.row_dimensions[row_index].height = 40 | |
| widths = { | |
| "Model": 28, | |
| "GPU": 14, | |
| "# node": 10, | |
| "workload": 29, | |
| "topology": 12, | |
| "parallelism": 18, | |
| "routing policy": 31, | |
| "concurrency": 13, | |
| "hicache": 31, | |
| "L3 backend": 13, | |
| "L1 size": 25, | |
| "L2 size": 21, | |
| "L3 size": 12, | |
| "kv dtype": 13, | |
| "MTP": 27, | |
| "chunk size": 12, | |
| } | |
| for column, name in enumerate(columns, 1): | |
| ws.column_dimensions[get_column_letter(column)].width = widths.get(name, 20) | |
| ws.freeze_panes = "A2" | |
| ws.auto_filter.ref = f"A1:AB{len(rows) + 1}" | |
| wb.save(OUTPUT) | |
| check = load_workbook(OUTPUT, read_only=False, data_only=False) | |
| if check.sheetnames != ["Metrics"]: | |
| raise RuntimeError(f"Unexpected sheets: {check.sheetnames}") | |
| sheet = check["Metrics"] | |
| if sheet.max_row != len(rows) + 1 or sheet.max_column != 28: | |
| raise RuntimeError( | |
| f"Unexpected workbook shape: {sheet.max_row}x{sheet.max_column}" | |
| ) | |
| if [sheet.cell(1, index).value for index in range(1, 29)] != EXPECTED_COLUMNS: | |
| raise RuntimeError("Workbook headers changed") | |
| for row in range(2, len(rows) + 2): | |
| e2e = float(sheet.cell(row, 20).value) | |
| ttft = float(sheet.cell(row, 16).value) | |
| decode = float(sheet.cell(row, 24).value) | |
| if not abs(e2e - ttft - decode) < 1e-12: | |
| raise RuntimeError(f"E2E identity failed in workbook row {row}") | |
| check.close() | |
| print(OUTPUT) | |
| if __name__ == "__main__": | |
| main() | |