Files
aituner/runs/opprof-phase5/test_phase5_tools.py
Gahow Wang d5b276180d Add OpProf campaign: protocols, results, patches, run evidence (P0-P6)
Workload-conditioned operator profiling on patched vLLM 0.24.0 +
Qwen3-30B-A3B/H20. H1b PASS (irregular patterns carry +23-45pp R64
raggedness, 8-45% token-efficiency loss vs rectangular controls);
mechanism decomposition kills the padding narrative and finds the
arrival-uniformization artifact (-12.9%); cross-version churn surface
shows TP2/MNS64 -29.4% across vLLM 0.20->0.24 while the argmax held.
Raw Layer-1 JSONL streams (507 MB) stay on disk, git-ignored; footer
sidecars and metrics are tracked.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 11:06:10 +08:00

69 lines
2.5 KiB
Python

#!/usr/bin/env python3
from __future__ import annotations
import json
import subprocess
import sys
import tempfile
from pathlib import Path
HERE = Path(__file__).resolve().parent
CLIENT = HERE / "opprof_phase5_client.py"
def write_jsonl(path: Path, rows: list[dict]) -> None:
path.write_text("".join(json.dumps(row) + "\n" for row in rows))
def run(command: list[str]) -> None:
completed = subprocess.run(command, text=True, capture_output=True)
if completed.returncode:
raise RuntimeError(f"command failed: {completed.stderr}")
def main() -> None:
with tempfile.TemporaryDirectory() as tmp_text:
tmp = Path(tmp_text)
manifest = tmp / "p3.jsonl"
source = tmp / "source.jsonl"
base = tmp / "base.jsonl"
a1 = tmp / "a1.jsonl"
rows = []
source_rows = []
lengths = [128, 8192, 256, 4096] * 8
for index, length in enumerate(lengths):
rows.append({
"request_id": f"P10-{index}", "pattern_id": "P10",
"input_tokens": length, "output_tokens": 8,
"arrival": "steady", "kind": "private-trace",
"source_index": index, "prompt": f"private-{index}",
})
source_rows.append({"timestamp": index * 0.1, "prompt": f"private-{index}"})
write_jsonl(manifest, rows)
write_jsonl(source, source_rows)
common = [
sys.executable, str(CLIENT), "transform", "--in", str(manifest),
"--take-first", "32", "--timestamp-source", str(source),
"--join-key", "source_index", "--timestamp-field", "timestamp",
"--arrival", "recorded-scaled", "--target-rate", "0.5",
]
run(common + ["--service-order", "original", "--out", str(base)])
run(common + [
"--service-order", "length-binned", "--reorder-block-size", "32",
"--analysis-cohort-size", "16", "--max-added-delay-seconds", "64",
"--out", str(a1),
])
base_summary = json.loads((base.with_suffix(".jsonl.summary.json")).read_text())
a1_summary = json.loads((a1.with_suffix(".jsonl.summary.json")).read_text())
assert base_summary["rows"] == a1_summary["rows"] == 32
assert base_summary["request_id_set_sha256"] == a1_summary["request_id_set_sha256"]
assert a1_summary["r16"] < base_summary["r16"]
assert a1_summary["max_added_delay_seconds"] <= 64
assert "private-" not in json.dumps(a1_summary)
print("phase5 tools: PASS")
if __name__ == "__main__":
main()