Run under nsys: warmup, sync ranks, then profile timed iterations.
(case: Case)
| 129 | |
| 130 | |
| 131 | def nsys_profile(case: Case) -> None: |
| 132 | """Run under nsys: warmup, sync ranks, then profile timed iterations.""" |
| 133 | fn = _prepare_case(case) |
| 134 | cache = create_l2_cache() |
| 135 | is_distributed = case.tp.size > 1 |
| 136 | for _ in range(case.n_runs_warmup): |
| 137 | clear_l2_cache(cache) |
| 138 | fn() |
| 139 | synchronize(is_distributed) |
| 140 | |
| 141 | torch.cuda.cudart().cudaProfilerStart() |
| 142 | synchronize(is_distributed) |
| 143 | |
| 144 | for _ in range(case.n_runs_benchmark): |
| 145 | clear_l2_cache(cache) |
| 146 | with torch.cuda.nvtx.range("kernel"): |
| 147 | fn() |
| 148 | |
| 149 | synchronize(is_distributed) |
| 150 | torch.cuda.cudart().cudaProfilerStop() |
| 151 | |
| 152 | |
| 153 | def benchmark_all(cases: list[Case]) -> pd.DataFrame: |
no test coverage detected