(path: Path, summary: dict)
| 659 | |
| 660 | |
| 661 | def write_markdown(path: Path, summary: dict) -> None: |
| 662 | lines = [ |
| 663 | "# Hybrid PFlash Phase-Split Report", |
| 664 | "", |
| 665 | f"- PFlash backend: `{summary.get('pflash_backend', 'cuda')}`", |
| 666 | f"- PFlash GPU: `{summary['pflash_gpu']}`", |
| 667 | f"- PFlash daemon ready: `{fmt(summary['pflash_daemon_ready_s'])} s`", |
| 668 | f"- keep ratio: `{summary['keep_ratio']}`", |
| 669 | f"- lookahead: `{summary['lookahead']}`", |
| 670 | f"- PFlash K cache: `{summary.get('pflash_k_type', 'compute')}`", |
| 671 | "", |
| 672 | "## PFlash Resource Peak", |
| 673 | "", |
| 674 | "| gpu | samples | peak mem MiB/% | peak temp C | avg power W | peak power W | avg util % | peak util % |", |
| 675 | "|---:|---:|---:|---:|---:|---:|---:|---:|", |
| 676 | ] |
| 677 | def append_resource_rows(resources: dict) -> None: |
| 678 | if not resources: |
| 679 | lines.append("| n/a | 0 | n/a | n/a | n/a | n/a | n/a | n/a |") |
| 680 | return |
| 681 | for gpu, res in resources.items(): |
| 682 | lines.append( |
| 683 | "| {gpu} | {samples} | {mem} | {temp} | {pavg} | {pmax} | {uavg} | {umax} |".format( |
| 684 | gpu=gpu, |
| 685 | samples=res.get("samples", 0), |
| 686 | mem=fmt(res.get("mem_max_mib")), |
| 687 | temp=fmt(res.get("temp_max_c")), |
| 688 | pavg=fmt(res.get("power_avg_w")), |
| 689 | pmax=fmt(res.get("power_max_w")), |
| 690 | uavg=fmt(res.get("util_avg_pct")), |
| 691 | umax=fmt(res.get("util_max_pct")), |
| 692 | ) |
| 693 | ) |
| 694 | |
| 695 | append_resource_rows(summary.get("pflash_resource_summary") or { |
| 696 | str(summary["pflash_gpu"]): summary.get("resource_summary") or {} |
| 697 | }) |
| 698 | if summary.get("target", {}).get("enabled"): |
| 699 | lines.extend([ |
| 700 | "", |
| 701 | "## Target Resource Peak", |
| 702 | "", |
| 703 | "| gpu | samples | peak mem MiB/% | peak temp C | avg power W | peak power W | avg util % | peak util % |", |
| 704 | "|---:|---:|---:|---:|---:|---:|---:|---:|", |
| 705 | ]) |
| 706 | append_resource_rows(summary.get("target_resource_summary") or {}) |
| 707 | lines.extend([ |
| 708 | "", |
| 709 | "## Cases", |
| 710 | "", |
| 711 | "| case | source tokens | compressed tokens | ratio | PFlash s | PFlash tok/s | target input | target output | target s | target rc | key retained | answer retained |", |
| 712 | "|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|:---:|:---:|", |
| 713 | ]) |
| 714 | for case in summary["cases"]: |
| 715 | key = case.get("retained_key") |
| 716 | answer = case.get("retained_answer") |
| 717 | lines.append( |
| 718 | "| {name} | {source} | {compressed} | {ratio} | {secs} | {tps} | {tin} | {tout} | {twall} | {trc} | {key} | {answer} |".format( |
no test coverage detected