Skip to content

Commit 5f2d436

Browse files
committed
repro
1 parent c9c4c2b commit 5f2d436

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

test/test_benchmark_stats.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
import pytest
24

35
from transformer_nuggets.utils.benchmark import (
@@ -57,3 +59,26 @@ def benchmark_gpu(self, fn, **kwargs):
5759
assert stats.quantiles_us == pytest.approx((10.0, 10.0, 10.0))
5860
assert stats.median_us == pytest.approx(10.0)
5961
assert stats.median_ci_us == pytest.approx((10.0, 10.0))
62+
63+
64+
@pytest.mark.parametrize(
65+
"message",
66+
[
67+
"CUDA warning: SyncActivityProfilerHandler::start failed to stop cleanly",
68+
"Detected call of profiler_start while another profiler is active",
69+
"Detected call of profiler_stop without a matching start",
70+
],
71+
)
72+
def test_benchmark_utils_suppresses_known_profiler_warnings(message):
73+
with warnings.catch_warnings(record=True) as caught:
74+
warnings.warn(message, UserWarning, stacklevel=1)
75+
76+
assert caught == []
77+
78+
79+
def test_benchmark_utils_does_not_suppress_unrelated_warnings():
80+
with warnings.catch_warnings(record=True) as caught:
81+
warnings.warn("transformer-nuggets unrelated benchmark warning", UserWarning, stacklevel=1)
82+
83+
assert len(caught) == 1
84+
assert str(caught[0].message) == "transformer-nuggets unrelated benchmark warning"

0 commit comments

Comments
 (0)