diff --git a/tests/tests_pytorch/profilers/test_profiler.py b/tests/tests_pytorch/profilers/test_profiler.py index 44ce7c4a3a41d..ec609f3a256ee 100644 --- a/tests/tests_pytorch/profilers/test_profiler.py +++ b/tests/tests_pytorch/profilers/test_profiler.py @@ -14,6 +14,7 @@ import logging import os import platform +import sys import time from copy import deepcopy from unittest.mock import patch @@ -35,6 +36,13 @@ PROFILER_OVERHEAD_MAX_TOLERANCE = 0.0005 +# TODO: Nested profile calls are not supported and raise an error in Python 3.12+ +# https://github.com/Lightning-AI/pytorch-lightning/issues/19983 +skip_advanced_profiler_py312 = pytest.mark.skipif( + sys.version_info >= (3, 12), reason="Nested profiler calls not supported." +) + + def _get_python_cprofile_total_duration(profile): return sum(x.inlinetime for x in profile.getstats()) @@ -333,6 +341,7 @@ def test_pytorch_profiler_describe(pytorch_profiler): assert len(data) > 0 +@skip_advanced_profiler_py312 def test_advanced_profiler_cprofile_deepcopy(tmp_path): """Checks for pickle issue reported in #6522.""" model = BoringModel() @@ -510,7 +519,11 @@ def __init__(self): assert "[pl][module]torch.nn.modules.linear.Linear: layer.2" in event_names -@pytest.mark.parametrize("cls", [SimpleProfiler, AdvancedProfiler, PyTorchProfiler]) +@pytest.mark.parametrize("cls", [ + SimpleProfiler, + PyTorchProfiler, + pytest.param(AdvancedProfiler, marks=skip_advanced_profiler_py312), +]) def test_profiler_teardown(tmp_path, cls): """This test checks if profiler teardown method is called when trainer is exiting."""