|
5 | 5 | import os |
6 | 6 | import random |
7 | 7 | import statistics |
| 8 | +import warnings |
8 | 9 | from contextlib import contextmanager, nullcontext |
9 | 10 | from dataclasses import dataclass, field |
10 | 11 | from pathlib import Path |
|
19 | 20 | from torch.cuda._memory_viz import profile_plot # type: ignore |
20 | 21 | from torch.profiler import profile, ProfilerActivity, record_function, schedule |
21 | 22 |
|
| 23 | +warnings.filterwarnings("ignore", message=".*SyncActivityProfilerHandler.*") |
| 24 | +warnings.filterwarnings("ignore", message=".*profiler_start.*") |
| 25 | +warnings.filterwarnings("ignore", message=".*profiler_stop.*") |
| 26 | + |
22 | 27 | logger = logging.getLogger(__name__) |
23 | 28 | logger.addHandler(logging.NullHandler()) |
24 | 29 |
|
@@ -265,7 +270,6 @@ def _call_do_bench_using_profiling( |
265 | 270 | return do_bench_using_profiling(fn, **call_kwargs) |
266 | 271 |
|
267 | 272 |
|
268 | | - |
269 | 273 | def _benchmark_cuda_graph_replay_samples_us( |
270 | 274 | func: Callable, |
271 | 275 | *args, |
@@ -310,7 +314,6 @@ def _benchmark_cuda_graph_replay_samples_us( |
310 | 314 | return samples_us |
311 | 315 |
|
312 | 316 |
|
313 | | - |
314 | 317 | def benchmark_cuda_function_stats(func: Callable, *args, **kwargs) -> CudaBenchmarkStats: |
315 | 318 | """Benchmark a CUDA callable and return median-centered summary stats. |
316 | 319 |
|
@@ -353,9 +356,7 @@ def benchmark_cuda_function_stats(func: Callable, *args, **kwargs) -> CudaBenchm |
353 | 356 | func, |
354 | 357 | *args, |
355 | 358 | NUM_ITERS=num_iters, |
356 | | - CUDAGRAPH_WARMUP_ITERS=kwargs.pop( |
357 | | - "CUDAGRAPH_WARMUP_ITERS", memory_warmup_iters |
358 | | - ), |
| 359 | + CUDAGRAPH_WARMUP_ITERS=kwargs.pop("CUDAGRAPH_WARMUP_ITERS", memory_warmup_iters), |
359 | 360 | LOCK_CLOCKS=kwargs.pop("LOCK_CLOCKS", False), |
360 | 361 | **kwargs, |
361 | 362 | ) |
@@ -424,7 +425,9 @@ def benchmark_cuda_function_in_microseconds(func: Callable, *args, **kwargs) -> |
424 | 425 | *args, |
425 | 426 | NUM_ITERS=num_iters, |
426 | 427 | LOCK_CLOCKS=kwargs.pop("LOCK_CLOCKS", False), |
427 | | - CUDAGRAPH_WARMUP_ITERS=kwargs.pop("CUDAGRAPH_WARMUP_ITERS", max(10, min(25, num_iters))), |
| 428 | + CUDAGRAPH_WARMUP_ITERS=kwargs.pop( |
| 429 | + "CUDAGRAPH_WARMUP_ITERS", max(10, min(25, num_iters)) |
| 430 | + ), |
428 | 431 | **kwargs, |
429 | 432 | ) |
430 | 433 | return statistics.median(samples_us) |
|
0 commit comments