-
Notifications
You must be signed in to change notification settings - Fork 28
Add OptimizationOrchestrator for hardware-guided kernel optimization #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Consolidates previous kernel_benchmark.py and pytorch_benchmark.py into a streamlined 3-file architecture with clear separation of concerns: Architecture: - benchmark.py (299 lines): Main Benchmark class with simplified API - benchmark_kernel(): Always uses subprocess for crash protection - benchmark_pytorch(): Always uses direct mode for stable code - BenchmarkLockManager: GPU lock management for multi-worker scenarios - timing.py (437 lines): Complete timing infrastructure - Timing: time_with_cuda_events(), time_with_triton_do_bench() - Loading: prepare_pytorch_model(), load_kernel_function() - Stats: compute_timing_stats() with essential metrics (mean/std/min/max) - kernel_subprocess.py (442 lines): Subprocess runner for kernel isolation - Crash protection for potentially buggy kernels - Clean CUDA state between runs - Timeout handling Key improvements: - Eliminated string code generation (was generating Python as strings) - Removed unnecessary statistics (median, p25/p75/p95/p99) - Removed confusing use_subprocess parameter (behavior now deterministic) - Fixed dtype bug causing incorrect speedup measurements - Reduced from 5 files to 3 files with clearer naming - Code reduction: ~1,400 lines → 1,178 lines Simple API: bench = Benchmark(logger, temp_dir, lock, worker_id) pytorch_result = bench.benchmark_pytorch(problem_file) kernel_result = bench.benchmark_kernel(kernel_file, problem_file) speedup = pytorch_result['stats']['mean'] / kernel_result['time_ms']
Jack-Khuu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed just OptOrchest since i assume that is the main delta
| from kernel_perf_agent.kernel_opt.roofline.ncu_roofline import RooflineAnalyzer | ||
| from triton_kernel_agent.prompt_manager import PromptManager | ||
| from triton_kernel_agent.worker import VerificationWorker | ||
| from triton_kernel_agent.worker_util import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto this file doesn't exist anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the functions*
| # Fallback: return first kernel if no Triton kernel found | ||
| return next(iter(ncu_metrics.values()), {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we return the first kernel if there are no Triton kernels? This seems like unexpected behavior?
| if self.pytorch_baseline_time is not None: | ||
| pytorch_baseline_time = self.pytorch_baseline_time | ||
| if pytorch_baseline_time != float("inf"): | ||
| self.logger.info( | ||
| f"📊 PyTorch baseline: {pytorch_baseline_time:.4f} ms (pre-computed)" | ||
| ) | ||
| else: | ||
| pytorch_baseline_time = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if self.pytorch_baseline_time is not None: | |
| pytorch_baseline_time = self.pytorch_baseline_time | |
| if pytorch_baseline_time != float("inf"): | |
| self.logger.info( | |
| f"📊 PyTorch baseline: {pytorch_baseline_time:.4f} ms (pre-computed)" | |
| ) | |
| else: | |
| pytorch_baseline_time = None | |
| if self.pytorch_baseline_time is not None and self.pytorch_baseline_time != float("inf"): | |
| self.logger.info( | |
| f"📊 PyTorch baseline: {pytorch_baseline_time:.4f} ms (pre-computed)" | |
| ) | |
| else: | |
| pytorch_baseline_time = None |
Summary: