(
pinned,
streamed,
)
| 169 | |
| 170 | # Our profiler: profiles the `inner` function and stores the results in a .json file |
| 171 | def benchmark_with_profiler( |
| 172 | pinned, |
| 173 | streamed, |
| 174 | ) -> None: |
| 175 | torch._C._profiler._set_cuda_sync_enabled_val(True) |
| 176 | wait, warmup, active = 1, 1, 2 |
| 177 | num_steps = wait + warmup + active |
| 178 | rank = 0 |
| 179 | with torch.profiler.profile( |
| 180 | activities=[ |
| 181 | torch.profiler.ProfilerActivity.CPU, |
| 182 | torch.profiler.ProfilerActivity.CUDA, |
| 183 | ], |
| 184 | schedule=torch.profiler.schedule( |
| 185 | wait=wait, warmup=warmup, active=active, repeat=1, skip_first=1 |
| 186 | ), |
| 187 | ) as prof: |
| 188 | for step_idx in range(1, num_steps + 1): |
| 189 | inner(streamed=streamed, pinned=pinned) |
| 190 | if rank is None or rank == 0: |
| 191 | prof.step() |
| 192 | prof.export_chrome_trace(f"trace_streamed{int(streamed)}_pinned{int(pinned)}.json") |
| 193 | |
| 194 | |
| 195 | ###################################################################### |
no test coverage detected