|
14 | 14 | import logging
|
15 | 15 | import os
|
16 | 16 | import platform
|
| 17 | +import sys |
17 | 18 | import time
|
18 | 19 | from copy import deepcopy
|
19 | 20 | from unittest.mock import patch
|
|
35 | 36 | PROFILER_OVERHEAD_MAX_TOLERANCE = 0.0005
|
36 | 37 |
|
37 | 38 |
|
| 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 | + |
38 | 46 | def _get_python_cprofile_total_duration(profile):
|
39 | 47 | return sum(x.inlinetime for x in profile.getstats())
|
40 | 48 |
|
@@ -333,6 +341,7 @@ def test_pytorch_profiler_describe(pytorch_profiler):
|
333 | 341 | assert len(data) > 0
|
334 | 342 |
|
335 | 343 |
|
| 344 | +@skip_advanced_profiler_py312 |
336 | 345 | def test_advanced_profiler_cprofile_deepcopy(tmp_path):
|
337 | 346 | """Checks for pickle issue reported in #6522."""
|
338 | 347 | model = BoringModel()
|
@@ -510,7 +519,11 @@ def __init__(self):
|
510 | 519 | assert "[pl][module]torch.nn.modules.linear.Linear: layer.2" in event_names
|
511 | 520 |
|
512 | 521 |
|
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 | +]) |
514 | 527 | def test_profiler_teardown(tmp_path, cls):
|
515 | 528 | """This test checks if profiler teardown method is called when trainer is exiting."""
|
516 | 529 |
|
|
0 commit comments