MCPcopy Create free account
hub / github.com/RightNow-AI/autokernel / build_report

Function build_report

profile.py:664–741  ·  view source on GitHub ↗

Build the profile_report.json structure.

(
    records: List[KernelRecord],
    gpu: GPUSpec,
    args: argparse.Namespace,
    model_desc: str,
)

Source from the content-addressed store, hash-verified

662
663
664def build_report(
665 records: List[KernelRecord],
666 gpu: GPUSpec,
667 args: argparse.Namespace,
668 model_desc: str,
669) -> Dict[str, Any]:
670 """Build the profile_report.json structure."""
671 total_gpu_time_us = sum(r.gpu_time_us for r in records)
672 total_gpu_time_ms = total_gpu_time_us / 1000.0
673
674 # Annotate records with roofline + supported
675 for r in records:
676 r.roofline = estimate_roofline_position(r.name, r.op_type, r.gpu_time_us, gpu)
677 r.supported = is_autokernel_supported(r.op_type)
678
679 # Build top_kernels list
680 top_kernels = []
681 cumulative_pct = 0.0
682 for i, r in enumerate(records):
683 pct = (r.gpu_time_us / total_gpu_time_us * 100.0) if total_gpu_time_us > 0 else 0.0
684 cumulative_pct += pct
685 top_kernels.append({
686 "rank": i + 1,
687 "name": r.name,
688 "op_type": r.op_type,
689 "shape_info": r.input_shapes,
690 "gpu_time_ms": round(r.gpu_time_us / 1000.0, 3),
691 "call_count": r.call_count,
692 "avg_time_us": round(r.gpu_time_us / max(r.call_count, 1), 2),
693 "pct_total": round(pct, 1),
694 "cumulative_pct": round(cumulative_pct, 1),
695 "roofline": r.roofline,
696 "autokernel_supported": r.supported,
697 "optimization_priority": _priority_label(pct),
698 })
699
700 # Optimization summary
701 supported_time_us = sum(r.gpu_time_us for r in records if r.supported)
702 supported_pct = (supported_time_us / total_gpu_time_us * 100.0) if total_gpu_time_us > 0 else 0.0
703
704 top5_time_us = sum(r.gpu_time_us for r in records[:5])
705 top5_pct = (top5_time_us / total_gpu_time_us * 100.0) if total_gpu_time_us > 0 else 0.0
706
707 # Estimated max speedup via Amdahl's law:
708 # If supported kernels can be made ~3x faster on average:
709 # S = 1 / ((1 - f) + f/s) where f = supported fraction, s = per-kernel speedup
710 f = supported_pct / 100.0
711 s = 3.0 # assume each supported kernel can be made 3x faster on average
712 if f > 0:
713 amdahl_speedup = 1.0 / ((1.0 - f) + f / s)
714 else:
715 amdahl_speedup = 1.0
716
717 input_shape = [int(x) for x in args.input_shape.split(",")]
718
719 report = {
720 "model": args.model or args.module,
721 "class_name": args.class_name,

Callers 1

mainFunction · 0.85

Calls 3

is_autokernel_supportedFunction · 0.85
_priority_labelFunction · 0.85

Tested by

no test coverage detected