Skip to content

Commit f19baea

Browse files
committed
profiler tests
1 parent d36856c commit f19baea

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/tests_pytorch/profilers/test_profiler.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import logging
1515
import os
1616
import platform
17+
import sys
1718
import time
1819
from copy import deepcopy
1920
from unittest.mock import patch
@@ -35,6 +36,13 @@
3536
PROFILER_OVERHEAD_MAX_TOLERANCE = 0.0005
3637

3738

39+
# TODO: Nested profile calls are not supported and raise an error in Python 3.12+
40+
# https://github.com/Lightning-AI/pytorch-lightning/issues/19983
41+
skip_advanced_profiler_py312 = pytest.mark.skipif(
42+
sys.version_info >= (3, 12), reason="Nested profiler calls not supported."
43+
)
44+
45+
3846
def _get_python_cprofile_total_duration(profile):
3947
return sum(x.inlinetime for x in profile.getstats())
4048

@@ -333,6 +341,7 @@ def test_pytorch_profiler_describe(pytorch_profiler):
333341
assert len(data) > 0
334342

335343

344+
@skip_advanced_profiler_py312
336345
def test_advanced_profiler_cprofile_deepcopy(tmp_path):
337346
"""Checks for pickle issue reported in #6522."""
338347
model = BoringModel()
@@ -510,7 +519,11 @@ def __init__(self):
510519
assert "[pl][module]torch.nn.modules.linear.Linear: layer.2" in event_names
511520

512521

513-
@pytest.mark.parametrize("cls", [SimpleProfiler, AdvancedProfiler, PyTorchProfiler])
522+
@pytest.mark.parametrize("cls", [
523+
SimpleProfiler,
524+
PyTorchProfiler,
525+
pytest.param(AdvancedProfiler, marks=skip_advanced_profiler_py312),
526+
])
514527
def test_profiler_teardown(tmp_path, cls):
515528
"""This test checks if profiler teardown method is called when trainer is exiting."""
516529

0 commit comments

Comments
 (0)